# aadarshsahu04/retinai architecture

> Architecture diagram of the GitHub repository aadarshsahu04/retinai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aadarshsahu04/retinai
- Repository: https://github.com/aadarshsahu04/retinai

## Overview

RetinAI is a web application for analyzing retinal fundus images for diabetic retinopathy and managing patient records and diagnostic PDFs. The main workflow is patient and image entry in the upload page, API submission, image validation and storage, ML classification, and patient-record persistence; results then appear in the UI. The dashboard also supports record browsing and report downloads, as documented. Edges reflect sampled calls and README-documented capabilities; unsampled dashboard wiring is not asserted.

Main entry points: [`backend/routes/api.py`](https://github.com/aadarshsahu04/retinai/blob/main/backend/routes/api.py) (API routes), [`frontend/src/api.js`](https://github.com/aadarshsahu04/retinai/blob/main/frontend/src/api.js) (API client), [`frontend/src/pages/UploadPage.jsx`](https://github.com/aadarshsahu04/retinai/blob/main/frontend/src/pages/UploadPage.jsx) (Scan form), [`frontend/src/pages/DashboardPage.jsx`](https://github.com/aadarshsahu04/retinai/blob/main/frontend/src/pages/DashboardPage.jsx) (Patient dashboard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Clinical UI"]
  node_upload["Scan form<br/>[UploadPage.jsx]"]
  node_dropzone["Image dropzone<br/>[ImageDropzone.jsx]"]
  node_result["Result card<br/>[ResultCard.jsx]"]
  node_api_client["API client<br/>[api.js]"]
  node_dashboard["Patient dashboard<br/>[DashboardPage.jsx]"]
  node_app["App router<br/>[App.jsx]"]
end

subgraph group_api["API workflow"]
  node_routes["API routes<br/>[api.py]"]
  node_schemas["Response schemas<br/>[schemas.py]"]
  node_backend["FastAPI startup<br/>[main.py]"]
end

subgraph group_analysis["Image analysis"]
  node_ml["DR classifier<br/>[ml_service.py]"]
  node_image_files["Uploaded images<br/>[api.py]"]
end

subgraph group_records["Patient records"]
  node_models["ORM models<br/>[models.py]"]
  node_database[("PostgreSQL<br/>[database.py]")]
end

subgraph group_reports["Diagnostic reports"]
  node_report_service["PDF generator<br/>[report_service.py]"]
  node_report_files["PDF reports<br/>[api.py]"]
end

node_clinician(("Clinician"))

node_clinician -->|"enters scan"| node_upload
node_upload -->|"selects image"| node_dropzone
node_upload -->|"submits scan"| node_api_client
node_api_client -->|"posts scan"| node_routes
node_routes -->|"writes image"| node_image_files
node_routes -->|"runs inference"| node_ml
node_ml -->|"returns prediction"| node_routes
node_routes -->|"creates patient"| node_models
node_routes -->|"queries and commits"| node_database
node_routes -->|"serializes response"| node_schemas
node_api_client -->|"shows prediction"| node_result
node_result -->|"opens dashboard"| node_dashboard
node_clinician -->|"reviews records"| node_dashboard
node_dashboard -.->|"requests records"| node_api_client
node_api_client -.->|"requests records"| node_routes
node_clinician -->|"downloads report"| node_report_files
node_routes -->|"generates PDF"| node_report_service
node_report_service -->|"writes PDF"| node_report_files
node_routes -->|"streams PDF"| node_report_files
node_backend -->|"registers routes"| node_routes
node_backend -->|"creates tables"| node_database
node_backend -->|"loads service"| node_ml
node_app -->|"routes to"| node_upload
node_app -->|"routes to"| node_dashboard

click node_upload "https://github.com/aadarshsahu04/retinai/blob/main/frontend/src/pages/UploadPage.jsx"
click node_dropzone "https://github.com/aadarshsahu04/retinai/blob/main/frontend/src/components/ImageDropzone.jsx"
click node_result "https://github.com/aadarshsahu04/retinai/blob/main/frontend/src/components/ResultCard.jsx"
click node_api_client "https://github.com/aadarshsahu04/retinai/blob/main/frontend/src/api.js"
click node_dashboard "https://github.com/aadarshsahu04/retinai/blob/main/frontend/src/pages/DashboardPage.jsx"
click node_app "https://github.com/aadarshsahu04/retinai/blob/main/frontend/src/App.jsx"
click node_routes "https://github.com/aadarshsahu04/retinai/blob/main/backend/routes/api.py"
click node_schemas "https://github.com/aadarshsahu04/retinai/blob/main/backend/schemas.py"
click node_ml "https://github.com/aadarshsahu04/retinai/blob/main/backend/services/ml_service.py"
click node_image_files "https://github.com/aadarshsahu04/retinai/blob/main/backend/routes/api.py"
click node_models "https://github.com/aadarshsahu04/retinai/blob/main/backend/models.py"
click node_database "https://github.com/aadarshsahu04/retinai/blob/main/backend/database.py"
click node_report_service "https://github.com/aadarshsahu04/retinai/blob/main/backend/services/report_service.py"
click node_report_files "https://github.com/aadarshsahu04/retinai/blob/main/backend/routes/api.py"
click node_backend "https://github.com/aadarshsahu04/retinai/blob/main/backend/main.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_upload,node_dropzone,node_result,node_api_client,node_dashboard,node_app toneBlue
class node_routes,node_schemas,node_backend toneAmber
class node_ml,node_image_files toneMint
class node_models,node_database toneRose
class node_report_service,node_report_files,node_clinician toneIndigo
```

## Components

### Clinical UI

- [Scan form](https://github.com/aadarshsahu04/retinai/blob/main/frontend/src/pages/UploadPage.jsx): `frontend/src/pages/UploadPage.jsx`
- [Image dropzone](https://github.com/aadarshsahu04/retinai/blob/main/frontend/src/components/ImageDropzone.jsx): `frontend/src/components/ImageDropzone.jsx`
- [Result card](https://github.com/aadarshsahu04/retinai/blob/main/frontend/src/components/ResultCard.jsx): `frontend/src/components/ResultCard.jsx`
- [API client](https://github.com/aadarshsahu04/retinai/blob/main/frontend/src/api.js): `frontend/src/api.js`
- [Patient dashboard](https://github.com/aadarshsahu04/retinai/blob/main/frontend/src/pages/DashboardPage.jsx): `frontend/src/pages/DashboardPage.jsx`
- [App router](https://github.com/aadarshsahu04/retinai/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`

### API workflow

- [API routes](https://github.com/aadarshsahu04/retinai/blob/main/backend/routes/api.py): `backend/routes/api.py`
- [Response schemas](https://github.com/aadarshsahu04/retinai/blob/main/backend/schemas.py): `backend/schemas.py`
- [FastAPI startup](https://github.com/aadarshsahu04/retinai/blob/main/backend/main.py): `backend/main.py`

### Image analysis

- [DR classifier](https://github.com/aadarshsahu04/retinai/blob/main/backend/services/ml_service.py): `backend/services/ml_service.py`
- [Uploaded images](https://github.com/aadarshsahu04/retinai/blob/main/backend/routes/api.py): `backend/routes/api.py`

### Patient records

- [ORM models](https://github.com/aadarshsahu04/retinai/blob/main/backend/models.py): `backend/models.py`
- [PostgreSQL](https://github.com/aadarshsahu04/retinai/blob/main/backend/database.py): `backend/database.py`

### Diagnostic reports

- [PDF generator](https://github.com/aadarshsahu04/retinai/blob/main/backend/services/report_service.py): `backend/services/report_service.py`
- [PDF reports](https://github.com/aadarshsahu04/retinai/blob/main/backend/routes/api.py): `backend/routes/api.py`

### Other components

- **Clinician**

## Connections

- Clinician → Scan form: enters scan (evidence: `README.md`)
- Scan form → Image dropzone: selects image (evidence: `frontend/src/pages/UploadPage.jsx`)
- Scan form → API client: submits scan (evidence: `frontend/src/pages/UploadPage.jsx`)
- API client → API routes: posts scan (evidence: `README.md`)
- API routes → Uploaded images: writes image (evidence: `backend/routes/api.py`)
- API routes → DR classifier: runs inference (evidence: `backend/routes/api.py`)
- DR classifier → API routes: returns prediction (evidence: `backend/routes/api.py`)
- API routes → ORM models: creates patient (evidence: `backend/routes/api.py`)
- API routes → PostgreSQL: queries and commits (evidence: `backend/routes/api.py`)
- API routes → Response schemas: serializes response (evidence: `backend/routes/api.py`)
- API client → Result card: shows prediction (evidence: `frontend/src/pages/UploadPage.jsx`)
- Result card → Patient dashboard: opens dashboard (evidence: `frontend/src/components/ResultCard.jsx`)
- Clinician → Patient dashboard: reviews records (evidence: `README.md`)
- Patient dashboard → API client: requests records
- API client → API routes: requests records
- Clinician → PDF reports: downloads report (evidence: `README.md`)
- API routes → PDF generator: generates PDF (evidence: `backend/routes/api.py`)
- PDF generator → PDF reports: writes PDF (evidence: `backend/services/report_service.py`)
- API routes → PDF reports: streams PDF (evidence: `backend/routes/api.py`)
- FastAPI startup → API routes: registers routes (evidence: `backend/main.py`)
- FastAPI startup → PostgreSQL: creates tables (evidence: `backend/main.py`)
- FastAPI startup → DR classifier: loads service (evidence: `backend/main.py`)
- App router → Scan form: routes to (evidence: `README.md`)
- App router → Patient dashboard: routes to (evidence: `README.md`)
