# asthanakislay-ui/sih-dr-screening architecture

> Architecture diagram of the GitHub repository asthanakislay-ui/sih-dr-screening, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/asthanakislay-ui/sih-dr-screening
- Repository: https://github.com/asthanakislay-ui/sih-dr-screening

## Overview

This is a diabetic-retinopathy screening application: staff submit a fundus image, receive a five-class model assessment with a Grad-CAM visualization, and can save and review screening records. The graph combines documented product capabilities with sampled implementation; the frontend service source shows direct AI-service calls, while the backend also exposes a separate ML proxy. Some page-to-service wiring and unsampled features are represented only at the documented subsystem level.

Main entry points: [`frontend/src/services/screeningService.js`](https://github.com/asthanakislay-ui/sih-dr-screening/blob/main/frontend/src/services/screeningService.js) (Screening API client), [`frontend/src/App.jsx`](https://github.com/asthanakislay-ui/sih-dr-screening/blob/main/frontend/src/App.jsx) (React application), [`ai/app.py`](https://github.com/asthanakislay-ui/sih-dr-screening/blob/main/ai/app.py) (FastAPI inference endpoint), [`backend/src/controllers/screening.controller.js`](https://github.com/asthanakislay-ui/sih-dr-screening/blob/main/backend/src/controllers/screening.controller.js) (Screening controller)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Screening interface"]
  node_frontend["React application<br/>[App.jsx]"]
  node_screening_ui["New screening"]
  node_analysis_ui["Analysis result"]
  node_history_ui["History and dashboard<br/>[HistoryPage.jsx]"]
  node_planning_ui["Resource planning"]
  node_client_service["Screening API client"]
end

subgraph group_api["Backend API"]
  node_backend_app["Express API<br/>[app.js]"]
  node_predict_route["Prediction route<br/>[predict.routes.js]"]
  node_predict_controller["ML proxy"]
end

subgraph group_inference["AI inference"]
  node_ai_api["FastAPI inference endpoint<br/>[app.py]"]
  node_validator["Fundus validation<br/>[image_validator.py]"]
  node_model["DR classifier<br/>[model.py]"]
  node_gradcam["Grad-CAM visualization<br/>[gradcam.py]"]
end

subgraph group_records["Screening records"]
  node_screen_route["Screening routes"]
  node_screen_controller["Screening controller"]
  node_notifications["Notification controller"]
  node_screen_model["Screening model<br/>[Screening.js]"]
  node_notification_model["Notification model<br/>[Notification.js]"]
end

subgraph group_identity["Identity and access"]
  node_auth_routes["Authentication routes<br/>[auth.routes.js]"]
  node_auth_controller["Authentication controller<br/>[auth.controller.js]"]
  node_user_model["User model<br/>[User.js]"]
end

node_staff(("Screening staff"))
node_mongo[("MongoDB")]
node_ml_service["AI service"]

node_staff -->|"uses"| node_frontend
node_frontend -->|"routes to"| node_screening_ui
node_frontend -->|"routes to"| node_analysis_ui
node_frontend -->|"routes to"| node_history_ui
node_frontend -->|"routes to"| node_planning_ui
node_screening_ui -->|"requests prediction"| node_client_service
node_client_service -->|"posts image"| node_ml_service
node_ml_service -->|"dispatches to"| node_ai_api
node_ai_api -->|"validates image"| node_validator
node_ai_api -->|"preprocesses and predicts"| node_model
node_ai_api -->|"generates heatmap"| node_gradcam
node_ai_api -->|"returns result"| node_client_service
node_screening_ui -->|"saves screening"| node_client_service
node_client_service -->|"sends records"| node_backend_app
node_backend_app -->|"mounts routes"| node_screen_route
node_screen_route -->|"dispatches requests"| node_screen_controller
node_screen_controller -->|"creates and queries"| node_screen_model
node_screen_controller -->|"finds recipients"| node_user_model
node_screen_controller -->|"inserts notifications"| node_notification_model
node_screen_controller -->|"persists records"| node_mongo
node_analysis_ui -->|"loads result"| node_client_service
node_history_ui -->|"loads screenings"| node_client_service
node_client_service -->|"requests records"| node_backend_app
node_backend_app -->|"mounts routes"| node_predict_route
node_predict_route -->|"dispatches prediction"| node_predict_controller
node_predict_controller -.->|"proxies image"| node_ml_service
node_backend_app -->|"mounts routes"| node_auth_routes
node_auth_routes -->|"dispatches requests"| node_auth_controller
node_auth_controller -->|"creates and reads"| node_user_model
node_user_model -->|"persists users"| node_mongo
node_notifications -->|"reads and updates"| node_notification_model
node_notification_model -->|"persists notifications"| node_mongo

click node_frontend "https://github.com/asthanakislay-ui/sih-dr-screening/blob/main/frontend/src/App.jsx"
click node_screening_ui "https://github.com/asthanakislay-ui/sih-dr-screening/blob/main/frontend/src/pages/NewScreeningPage.jsx"
click node_analysis_ui "https://github.com/asthanakislay-ui/sih-dr-screening/blob/main/frontend/src/pages/AnalysisResultPage.jsx"
click node_history_ui "https://github.com/asthanakislay-ui/sih-dr-screening/blob/main/frontend/src/pages/HistoryPage.jsx"
click node_planning_ui "https://github.com/asthanakislay-ui/sih-dr-screening/blob/main/frontend/src/pages/ResourcePlanningPage.jsx"
click node_client_service "https://github.com/asthanakislay-ui/sih-dr-screening/blob/main/frontend/src/services/screeningService.js"
click node_backend_app "https://github.com/asthanakislay-ui/sih-dr-screening/blob/main/backend/src/app.js"
click node_predict_route "https://github.com/asthanakislay-ui/sih-dr-screening/blob/main/backend/src/routes/predict.routes.js"
click node_predict_controller "https://github.com/asthanakislay-ui/sih-dr-screening/blob/main/backend/src/controllers/predict.controller.js"
click node_screen_route "https://github.com/asthanakislay-ui/sih-dr-screening/blob/main/backend/src/routes/screening.routes.js"
click node_screen_controller "https://github.com/asthanakislay-ui/sih-dr-screening/blob/main/backend/src/controllers/screening.controller.js"
click node_ai_api "https://github.com/asthanakislay-ui/sih-dr-screening/blob/main/ai/app.py"
click node_validator "https://github.com/asthanakislay-ui/sih-dr-screening/blob/main/ai/image_validator.py"
click node_model "https://github.com/asthanakislay-ui/sih-dr-screening/blob/main/ai/model.py"
click node_gradcam "https://github.com/asthanakislay-ui/sih-dr-screening/blob/main/ai/gradcam.py"
click node_auth_routes "https://github.com/asthanakislay-ui/sih-dr-screening/blob/main/backend/src/routes/auth.routes.js"
click node_auth_controller "https://github.com/asthanakislay-ui/sih-dr-screening/blob/main/backend/src/controllers/auth.controller.js"
click node_notifications "https://github.com/asthanakislay-ui/sih-dr-screening/blob/main/backend/src/controllers/notification.controller.js"
click node_user_model "https://github.com/asthanakislay-ui/sih-dr-screening/blob/main/backend/src/models/User.js"
click node_screen_model "https://github.com/asthanakislay-ui/sih-dr-screening/blob/main/backend/src/models/Screening.js"
click node_notification_model "https://github.com/asthanakislay-ui/sih-dr-screening/blob/main/backend/src/models/Notification.js"

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_frontend,node_screening_ui,node_analysis_ui,node_history_ui,node_planning_ui,node_client_service,node_staff toneBlue
class node_backend_app,node_predict_route,node_predict_controller,node_mongo toneAmber
class node_ai_api,node_validator,node_model,node_gradcam toneMint
class node_screen_route,node_screen_controller,node_notifications,node_screen_model,node_notification_model toneRose
class node_auth_routes,node_auth_controller,node_user_model,node_ml_service toneIndigo
```

## Components

### Screening interface

- [React application](https://github.com/asthanakislay-ui/sih-dr-screening/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [New screening](https://github.com/asthanakislay-ui/sih-dr-screening/blob/main/frontend/src/pages/NewScreeningPage.jsx): `frontend/src/pages/NewScreeningPage.jsx`
- [Analysis result](https://github.com/asthanakislay-ui/sih-dr-screening/blob/main/frontend/src/pages/AnalysisResultPage.jsx): `frontend/src/pages/AnalysisResultPage.jsx`
- [History and dashboard](https://github.com/asthanakislay-ui/sih-dr-screening/blob/main/frontend/src/pages/HistoryPage.jsx): `frontend/src/pages/HistoryPage.jsx`
- [Resource planning](https://github.com/asthanakislay-ui/sih-dr-screening/blob/main/frontend/src/pages/ResourcePlanningPage.jsx): `frontend/src/pages/ResourcePlanningPage.jsx`
- [Screening API client](https://github.com/asthanakislay-ui/sih-dr-screening/blob/main/frontend/src/services/screeningService.js): `frontend/src/services/screeningService.js`

### Backend API

- [Express API](https://github.com/asthanakislay-ui/sih-dr-screening/blob/main/backend/src/app.js): `backend/src/app.js`
- [Prediction route](https://github.com/asthanakislay-ui/sih-dr-screening/blob/main/backend/src/routes/predict.routes.js): `backend/src/routes/predict.routes.js`
- [ML proxy](https://github.com/asthanakislay-ui/sih-dr-screening/blob/main/backend/src/controllers/predict.controller.js): `backend/src/controllers/predict.controller.js`

### AI inference

- [FastAPI inference endpoint](https://github.com/asthanakislay-ui/sih-dr-screening/blob/main/ai/app.py): `ai/app.py`
- [Fundus validation](https://github.com/asthanakislay-ui/sih-dr-screening/blob/main/ai/image_validator.py): `ai/image_validator.py`
- [DR classifier](https://github.com/asthanakislay-ui/sih-dr-screening/blob/main/ai/model.py): `ai/model.py`
- [Grad-CAM visualization](https://github.com/asthanakislay-ui/sih-dr-screening/blob/main/ai/gradcam.py): `ai/gradcam.py`

### Screening records

- [Screening routes](https://github.com/asthanakislay-ui/sih-dr-screening/blob/main/backend/src/routes/screening.routes.js): `backend/src/routes/screening.routes.js`
- [Screening controller](https://github.com/asthanakislay-ui/sih-dr-screening/blob/main/backend/src/controllers/screening.controller.js): `backend/src/controllers/screening.controller.js`
- [Notification controller](https://github.com/asthanakislay-ui/sih-dr-screening/blob/main/backend/src/controllers/notification.controller.js): `backend/src/controllers/notification.controller.js`
- [Screening model](https://github.com/asthanakislay-ui/sih-dr-screening/blob/main/backend/src/models/Screening.js): `backend/src/models/Screening.js`
- [Notification model](https://github.com/asthanakislay-ui/sih-dr-screening/blob/main/backend/src/models/Notification.js): `backend/src/models/Notification.js`

### Identity and access

- [Authentication routes](https://github.com/asthanakislay-ui/sih-dr-screening/blob/main/backend/src/routes/auth.routes.js): `backend/src/routes/auth.routes.js`
- [Authentication controller](https://github.com/asthanakislay-ui/sih-dr-screening/blob/main/backend/src/controllers/auth.controller.js): `backend/src/controllers/auth.controller.js`
- [User model](https://github.com/asthanakislay-ui/sih-dr-screening/blob/main/backend/src/models/User.js): `backend/src/models/User.js`

### Other components

- **Screening staff**
- **MongoDB**
- **AI service**

## Connections

- Screening staff → React application: uses
- React application → New screening: routes to
- React application → Analysis result: routes to
- React application → History and dashboard: routes to
- React application → Resource planning: routes to
- New screening → Screening API client: requests prediction
- Screening API client → AI service: posts image
- AI service → FastAPI inference endpoint: dispatches to
- FastAPI inference endpoint → Fundus validation: validates image
- FastAPI inference endpoint → DR classifier: preprocesses and predicts
- FastAPI inference endpoint → Grad-CAM visualization: generates heatmap
- FastAPI inference endpoint → Screening API client: returns result
- New screening → Screening API client: saves screening
- Screening API client → Express API: sends records
- Express API → Screening routes: mounts routes
- Screening routes → Screening controller: dispatches requests
- Screening controller → Screening model: creates and queries
- Screening controller → User model: finds recipients
- Screening controller → Notification model: inserts notifications
- Screening controller → MongoDB: persists records
- Analysis result → Screening API client: loads result
- History and dashboard → Screening API client: loads screenings
- Screening API client → Express API: requests records
- Express API → Prediction route: mounts routes
- Prediction route → ML proxy: dispatches prediction
- ML proxy → AI service: proxies image
- Express API → Authentication routes: mounts routes
- Authentication routes → Authentication controller: dispatches requests
- Authentication controller → User model: creates and reads
- User model → MongoDB: persists users
- Notification controller → Notification model: reads and updates
- Notification model → MongoDB: persists notifications
