# charanpreetsingh123/mediscanai architecture

> Architecture diagram of the GitHub repository charanpreetsingh123/mediscanai, 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/charanpreetsingh123/mediscanai
- Repository: https://github.com/charanpreetsingh123/mediscanai

## Overview

MediScan AI is a role-based medical imaging platform: patients and doctors authenticate, submit disease-specific scans, review AI findings, and use dashboards or history to follow results. The README also documents Grad-CAM explanations and downloadable PDF reports. The graph connects the documented frontend and API flow; unsampled route and utility implementations limit confidence about internal prediction, persistence, heatmap, and report wiring, so those links are not inferred.

Main entry points: [`frontend/src/utils/api.js`](https://github.com/charanpreetsingh123/mediscanai/blob/main/frontend/src/utils/api.js) (API client), [`backend/main.py`](https://github.com/charanpreetsingh123/mediscanai/blob/main/backend/main.py) (FastAPI application), [`frontend/src/App.jsx`](https://github.com/charanpreetsingh123/mediscanai/blob/main/frontend/src/App.jsx) (Role-based app), [`backend/routes/predict.py`](https://github.com/charanpreetsingh123/mediscanai/blob/main/backend/routes/predict.py) (Prediction routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_app["Role-based app<br/>[App.jsx]"]
  node_login["Login and registration<br/>[Login.jsx]"]
  node_register["Registration form<br/>[Register.jsx]"]
  node_patientdash["Patient dashboard"]
  node_doctordash["Doctor dashboard"]
  node_patientupload["Patient scan upload<br/>[UploadScan.jsx]"]
  node_doctorupload["Doctor scan upload<br/>[UploadScan.jsx]"]
  node_scanresults["Scan results<br/>[ResultCard.jsx]"]
  node_history["Scan history<br/>[ScanHistory.jsx]"]
  node_analytics["Doctor analytics<br/>[Analytics.jsx]"]
  node_patients["Patient list<br/>[PatientList.jsx]"]
  node_reportview["Report viewer<br/>[ReportViewer.jsx]"]
  node_heatmapview["Heatmap viewer<br/>[HeatmapViewer.jsx]"]
  node_apiclient["API client<br/>[api.js]"]
end

subgraph group_api["API and access"]
  node_fastapi["FastAPI application<br/>[main.py]"]
  node_authroutes["Authentication routes<br/>[auth.py]"]
  node_authcore["JWT and password auth<br/>[auth.py]"]
  node_predroutes["Prediction routes<br/>[predict.py]"]
  node_doctorroutes["Doctor routes<br/>[doctor.py]"]
  node_patientroutes["Patient routes<br/>[patient.py]"]
end

subgraph group_diagnosis["AI diagnosis"]
  node_brain["Brain tumor inference"]
  node_retinopathy["Retinopathy inference"]
  node_skin["Skin cancer inference"]
  node_imageproc["Image processing<br/>[image_processor.py]"]
  node_gradcam["Grad-CAM generation<br/>[gradcam.py]"]
end

subgraph group_records["Records and reports"]
  node_reports["PDF report generation"]
  node_scanmodel["Scan records<br/>[scan.py]"]
  node_usermodel["User records<br/>[user.py]"]
  node_dbaccess["Database access<br/>[database.py]"]
end

node_patient(("Patient"))
node_doctor(("Doctor"))
node_postgres[("PostgreSQL")]

node_patient -->|"uses"| node_app
node_doctor -->|"uses"| node_app
node_app -->|"routes to"| node_login
node_app -->|"routes to"| node_register
node_app -->|"routes to"| node_patientdash
node_app -->|"routes to"| node_doctordash
node_patientdash -->|"offers upload"| node_patientupload
node_patientupload -->|"requests prediction"| node_apiclient
node_doctordash -->|"offers upload"| node_doctorupload
node_doctorupload -->|"requests prediction"| node_apiclient
node_login -->|"submits credentials"| node_apiclient
node_register -->|"submits account"| node_apiclient
node_apiclient -->|"sends API requests"| node_fastapi
node_fastapi -->|"dispatches auth"| node_authroutes
node_fastapi -->|"dispatches prediction"| node_predroutes
node_fastapi -->|"dispatches doctor"| node_doctorroutes
node_fastapi -->|"dispatches patient"| node_patientroutes
node_authroutes -->|"uses auth functions"| node_authcore
node_authroutes -->|"reads and writes users"| node_usermodel
node_predroutes -->|"runs brain model"| node_brain
node_predroutes -->|"runs eye model"| node_retinopathy
node_predroutes -->|"runs skin model"| node_skin
node_apiclient -->|"returns findings"| node_scanresults
node_apiclient -->|"loads history"| node_history
node_apiclient -->|"loads statistics"| node_analytics
node_apiclient -->|"loads patient list"| node_patients
node_apiclient -->|"loads reports"| node_reportview
node_apiclient -->|"loads heatmaps"| node_heatmapview
node_dbaccess -->|"reads and writes"| node_postgres
node_fastapi -->|"registers scan model"| node_scanmodel

click node_app "https://github.com/charanpreetsingh123/mediscanai/blob/main/frontend/src/App.jsx"
click node_login "https://github.com/charanpreetsingh123/mediscanai/blob/main/frontend/src/pages/Login.jsx"
click node_register "https://github.com/charanpreetsingh123/mediscanai/blob/main/frontend/src/pages/Register.jsx"
click node_patientdash "https://github.com/charanpreetsingh123/mediscanai/blob/main/frontend/src/pages/PatientDashboard.jsx"
click node_doctordash "https://github.com/charanpreetsingh123/mediscanai/blob/main/frontend/src/pages/DoctorDashboard.jsx"
click node_patientupload "https://github.com/charanpreetsingh123/mediscanai/blob/main/frontend/src/components/Patient/UploadScan.jsx"
click node_doctorupload "https://github.com/charanpreetsingh123/mediscanai/blob/main/frontend/src/components/Doctor/UploadScan.jsx"
click node_scanresults "https://github.com/charanpreetsingh123/mediscanai/blob/main/frontend/src/components/Patient/ResultCard.jsx"
click node_history "https://github.com/charanpreetsingh123/mediscanai/blob/main/frontend/src/components/Patient/ScanHistory.jsx"
click node_analytics "https://github.com/charanpreetsingh123/mediscanai/blob/main/frontend/src/components/Doctor/Analytics.jsx"
click node_patients "https://github.com/charanpreetsingh123/mediscanai/blob/main/frontend/src/components/Doctor/PatientList.jsx"
click node_reportview "https://github.com/charanpreetsingh123/mediscanai/blob/main/frontend/src/components/Doctor/ReportViewer.jsx"
click node_heatmapview "https://github.com/charanpreetsingh123/mediscanai/blob/main/frontend/src/components/Common/HeatmapViewer.jsx"
click node_apiclient "https://github.com/charanpreetsingh123/mediscanai/blob/main/frontend/src/utils/api.js"
click node_fastapi "https://github.com/charanpreetsingh123/mediscanai/blob/main/backend/main.py"
click node_authroutes "https://github.com/charanpreetsingh123/mediscanai/blob/main/backend/routes/auth.py"
click node_authcore "https://github.com/charanpreetsingh123/mediscanai/blob/main/backend/auth.py"
click node_predroutes "https://github.com/charanpreetsingh123/mediscanai/blob/main/backend/routes/predict.py"
click node_doctorroutes "https://github.com/charanpreetsingh123/mediscanai/blob/main/backend/routes/doctor.py"
click node_patientroutes "https://github.com/charanpreetsingh123/mediscanai/blob/main/backend/routes/patient.py"
click node_brain "https://github.com/charanpreetsingh123/mediscanai/tree/main/backend/models/brain_tumor"
click node_retinopathy "https://github.com/charanpreetsingh123/mediscanai/tree/main/backend/models/diabetic_retinopathy"
click node_skin "https://github.com/charanpreetsingh123/mediscanai/tree/main/backend/models/skin_cancer"
click node_imageproc "https://github.com/charanpreetsingh123/mediscanai/blob/main/backend/utils/image_processor.py"
click node_gradcam "https://github.com/charanpreetsingh123/mediscanai/blob/main/backend/utils/gradcam.py"
click node_reports "https://github.com/charanpreetsingh123/mediscanai/blob/main/backend/utils/report_generator.py"
click node_scanmodel "https://github.com/charanpreetsingh123/mediscanai/blob/main/backend/models/scan.py"
click node_usermodel "https://github.com/charanpreetsingh123/mediscanai/blob/main/backend/models/user.py"
click node_dbaccess "https://github.com/charanpreetsingh123/mediscanai/blob/main/backend/database.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_app,node_login,node_register,node_patientdash,node_doctordash,node_patientupload,node_doctorupload,node_scanresults,node_history,node_analytics,node_patients,node_reportview,node_heatmapview,node_apiclient toneBlue
class node_fastapi,node_authroutes,node_authcore,node_predroutes,node_doctorroutes,node_patientroutes,node_postgres toneAmber
class node_brain,node_retinopathy,node_skin,node_imageproc,node_gradcam toneMint
class node_reports,node_scanmodel,node_usermodel,node_dbaccess toneRose
class node_patient,node_doctor toneIndigo
```

## Components

### Web client

- [Role-based app](https://github.com/charanpreetsingh123/mediscanai/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Login and registration](https://github.com/charanpreetsingh123/mediscanai/blob/main/frontend/src/pages/Login.jsx): `frontend/src/pages/Login.jsx`
- [Registration form](https://github.com/charanpreetsingh123/mediscanai/blob/main/frontend/src/pages/Register.jsx): `frontend/src/pages/Register.jsx`
- [Patient dashboard](https://github.com/charanpreetsingh123/mediscanai/blob/main/frontend/src/pages/PatientDashboard.jsx): `frontend/src/pages/PatientDashboard.jsx`
- [Doctor dashboard](https://github.com/charanpreetsingh123/mediscanai/blob/main/frontend/src/pages/DoctorDashboard.jsx): `frontend/src/pages/DoctorDashboard.jsx`
- [Patient scan upload](https://github.com/charanpreetsingh123/mediscanai/blob/main/frontend/src/components/Patient/UploadScan.jsx): `frontend/src/components/Patient/UploadScan.jsx`
- [Doctor scan upload](https://github.com/charanpreetsingh123/mediscanai/blob/main/frontend/src/components/Doctor/UploadScan.jsx): `frontend/src/components/Doctor/UploadScan.jsx`
- [Scan results](https://github.com/charanpreetsingh123/mediscanai/blob/main/frontend/src/components/Patient/ResultCard.jsx): `frontend/src/components/Patient/ResultCard.jsx`
- [Scan history](https://github.com/charanpreetsingh123/mediscanai/blob/main/frontend/src/components/Patient/ScanHistory.jsx): `frontend/src/components/Patient/ScanHistory.jsx`
- [Doctor analytics](https://github.com/charanpreetsingh123/mediscanai/blob/main/frontend/src/components/Doctor/Analytics.jsx): `frontend/src/components/Doctor/Analytics.jsx`
- [Patient list](https://github.com/charanpreetsingh123/mediscanai/blob/main/frontend/src/components/Doctor/PatientList.jsx): `frontend/src/components/Doctor/PatientList.jsx`
- [Report viewer](https://github.com/charanpreetsingh123/mediscanai/blob/main/frontend/src/components/Doctor/ReportViewer.jsx): `frontend/src/components/Doctor/ReportViewer.jsx`
- [Heatmap viewer](https://github.com/charanpreetsingh123/mediscanai/blob/main/frontend/src/components/Common/HeatmapViewer.jsx): `frontend/src/components/Common/HeatmapViewer.jsx`
- [API client](https://github.com/charanpreetsingh123/mediscanai/blob/main/frontend/src/utils/api.js): `frontend/src/utils/api.js`

### API and access

- [FastAPI application](https://github.com/charanpreetsingh123/mediscanai/blob/main/backend/main.py): `backend/main.py`
- [Authentication routes](https://github.com/charanpreetsingh123/mediscanai/blob/main/backend/routes/auth.py): `backend/routes/auth.py`
- [JWT and password auth](https://github.com/charanpreetsingh123/mediscanai/blob/main/backend/auth.py): `backend/auth.py`
- [Prediction routes](https://github.com/charanpreetsingh123/mediscanai/blob/main/backend/routes/predict.py): `backend/routes/predict.py`
- [Doctor routes](https://github.com/charanpreetsingh123/mediscanai/blob/main/backend/routes/doctor.py): `backend/routes/doctor.py`
- [Patient routes](https://github.com/charanpreetsingh123/mediscanai/blob/main/backend/routes/patient.py): `backend/routes/patient.py`

### AI diagnosis

- [Brain tumor inference](https://github.com/charanpreetsingh123/mediscanai/tree/main/backend/models/brain_tumor): `backend/models/brain_tumor`
- [Retinopathy inference](https://github.com/charanpreetsingh123/mediscanai/tree/main/backend/models/diabetic_retinopathy): `backend/models/diabetic_retinopathy`
- [Skin cancer inference](https://github.com/charanpreetsingh123/mediscanai/tree/main/backend/models/skin_cancer): `backend/models/skin_cancer`
- [Image processing](https://github.com/charanpreetsingh123/mediscanai/blob/main/backend/utils/image_processor.py): `backend/utils/image_processor.py`
- [Grad-CAM generation](https://github.com/charanpreetsingh123/mediscanai/blob/main/backend/utils/gradcam.py): `backend/utils/gradcam.py`

### Records and reports

- [PDF report generation](https://github.com/charanpreetsingh123/mediscanai/blob/main/backend/utils/report_generator.py): `backend/utils/report_generator.py`
- [Scan records](https://github.com/charanpreetsingh123/mediscanai/blob/main/backend/models/scan.py): `backend/models/scan.py`
- [User records](https://github.com/charanpreetsingh123/mediscanai/blob/main/backend/models/user.py): `backend/models/user.py`
- [Database access](https://github.com/charanpreetsingh123/mediscanai/blob/main/backend/database.py): `backend/database.py`

### Other components

- **Patient**
- **Doctor**
- **PostgreSQL**

## Connections

- Patient → Role-based app: uses
- Doctor → Role-based app: uses
- Role-based app → Login and registration: routes to
- Role-based app → Registration form: routes to
- Role-based app → Patient dashboard: routes to
- Role-based app → Doctor dashboard: routes to
- Patient dashboard → Patient scan upload: offers upload
- Patient scan upload → API client: requests prediction
- Doctor dashboard → Doctor scan upload: offers upload
- Doctor scan upload → API client: requests prediction
- Login and registration → API client: submits credentials
- Registration form → API client: submits account
- API client → FastAPI application: sends API requests
- FastAPI application → Authentication routes: dispatches auth
- FastAPI application → Prediction routes: dispatches prediction
- FastAPI application → Doctor routes: dispatches doctor
- FastAPI application → Patient routes: dispatches patient
- Authentication routes → JWT and password auth: uses auth functions
- Authentication routes → User records: reads and writes users
- Prediction routes → Brain tumor inference: runs brain model
- Prediction routes → Retinopathy inference: runs eye model
- Prediction routes → Skin cancer inference: runs skin model
- API client → Scan results: returns findings
- API client → Scan history: loads history
- API client → Doctor analytics: loads statistics
- API client → Patient list: loads patient list
- API client → Report viewer: loads reports
- API client → Heatmap viewer: loads heatmaps
- Database access → PostgreSQL: reads and writes
- FastAPI application → Scan records: registers scan model
