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}) returnindex.htmlfor 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 servicePOST /api/diagnosisβ combined endpoint: validates image, runs ML prediction, checks red flags
Authentication
POST /api/auth/loginβ returns JWT access tokenPOST /api/auth/registerβ new user registrationGET /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 probeGET /healthβ liveness + database connectivity
Quick Links
- Setup & Configuration β
- API Endpoints β
- Architecture & Design β
- Testing β
- Troubleshooting β
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.