Skip to Content
ServicesAPI GatewayAPI Gateway Service

API Gateway Service

The API Gateway is the main entry point for all client applications in the DermaDetect platform. It handles authentication, case management, image storage, and orchestrates calls to the AI Service.

Overview

Location: services/api_gateway/

Technology Stack:

  • FastAPI with Pydantic validation
  • SQLAlchemy 2.0 (async) with asyncpg
  • PostgreSQL 16
  • Azure Blob Storage SDK
  • httpx for AI Service communication

Default Port: 8000

Key Responsibilities

Current Implementation βœ…

AI Service Integration

  • Proxies 5 AI endpoints (diagnosis, red flags, triage, image validity, next question)
  • Async HTTP client with comprehensive error handling
  • Typed responses with Pydantic schemas

Image Upload

  • Base64 image upload to Azure Blob Storage
  • File type validation (JPEG, PNG)
  • Tenant-based organization

Database Layer

  • SQLAlchemy 2.0 async models (User, Case, Physician, etc.)
  • Connection pooling and session management
  • Alembic migrations for schema versioning

Health Checks

  • Simple /healthy endpoint
  • Detailed /health with database connectivity

Comprehensive Testing

  • 40 passing tests (unit + integration)
  • Mocked dependencies (AI service, Azure Storage)
  • Real PostgreSQL via testcontainers

Planned Features πŸ”²

Authentication & Authorization

  • JWT token generation and validation
  • SAML/SSO integration for enterprise
  • Multi-tenant isolation and routing

Case Management

  • Create and submit patient cases
  • List, filter, and search cases
  • Update case status and assignment

Physician Workflow

  • Case assignment based on specialty
  • Annotation creation and templates
  • Private pool management

Additional Features

  • Rate limiting per user/tenant
  • Request counting and quota management
  • PDF report generation

Architecture at a Glance

Client Apps β†’ API Gateway β†’ AI Service ↓ PostgreSQL ↓ Azure Storage

The API Gateway handles all client requests, persists data to PostgreSQL, uploads images to Azure Blob Storage, and orchestrates ML inference by calling the AI Service.

Last updated on