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. It also serves the Physician Portal β€” a React single-page application embedded in the same container.

Overview

Location: services/api_gateway/

Technology Stack:

  • FastAPI with Pydantic validation
  • SQLAlchemy 2.0 (async) with asyncpg
  • PostgreSQL 16
  • AWS S3 (boto3) for image storage
  • httpx for AI Service communication
  • Physician Portal: React 19 + Vite 6 + TypeScript + Tailwind CSS v4 + React Router v7

Default Port: 8080

Components

Physician Portal (physician_portal/)

A React SPA served directly from FastAPI at the root path (/). Built with Vite and embedded in the Docker image via a multi-stage build. Physicians use it to run AI-assisted dermatological diagnoses through a guided questionnaire and image upload flow.

  • Static assets served from /assets/*
  • All other routes (/{path}) return index.html for client-side routing
  • Communicates with the FastAPI backend via /api/* endpoints
  • Bearer token authentication stored in localStorage

FastAPI Backend (src/)

Handles all /api/* routes:

AI-Driven Diagnosis

  • POST /api/ai/next_question β€” adaptive questionnaire driven by the AI service
  • POST /api/diagnosis β€” combined endpoint: validates image, runs ML prediction, checks red flags

Authentication

  • POST /api/auth/login β€” returns JWT access token
  • POST /api/auth/register β€” new user registration
  • GET /api/users/me β€” current user profile

Database Layer

  • SQLAlchemy 2.0 async models (User, etc.)
  • Alembic migrations for schema versioning

Health Checks

  • GET /healthy β€” simple liveness probe
  • GET /health β€” liveness + database connectivity

Architecture at a Glance

Browser (Physician Portal SPA) β”‚ static assets β†’ FastAPI /assets/* β”‚ API calls β†’ FastAPI /api/* β–Ό API Gateway (FastAPI + React bundle) β”œβ”€β”€ PostgreSQL (users, cases) β”œβ”€β”€ AWS S3 (uploaded images) └── AI Service (inference)

In development, the Vite dev server runs separately (port 3000) and proxies /api calls to the FastAPI process (port 8081). In production and Docker, the pre-built React bundle is served directly by FastAPI.

Last updated on