# krishnaharesh/glaucoma-vit architecture

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

- Interactive diagram: https://gitdiagram.com/krishnaharesh/glaucoma-vit
- Repository: https://github.com/krishnaharesh/glaucoma-vit

## Overview

Glaucoma-ViT is a research screening application combining retinal-image classification and a web interface. The principal workflow is a user uploading a fundus image in Analyze, the backend invoking model inference and returning a classification with visual explanation, and the application storing prediction history for signed-in users. The repository also supports model training, evaluation and comparison. Connections between components are included where excerpts, the source index or README document them; some frontend-to-backend links are documented at the API level rather than shown as direct source calls.

Main entry points: [`frontend/src/App.jsx`](https://github.com/krishnaharesh/glaucoma-vit/blob/main/frontend/src/App.jsx) (Routes and shell), [`src/model.py`](https://github.com/krishnaharesh/glaucoma-vit/blob/main/src/model.py) (Model definitions), [`src/dataset.py`](https://github.com/krishnaharesh/glaucoma-vit/blob/main/src/dataset.py) (Dataset loading), [`frontend/src/api/axios.js`](https://github.com/krishnaharesh/glaucoma-vit/blob/main/frontend/src/api/axios.js) (API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web application"]
  node_app["Routes and shell<br/>[App.jsx]"]
  node_analyze["Image analysis<br/>[AnalyzePage.jsx]"]
  node_auth_ui["Session context<br/>[AuthContext.jsx]"]
  node_api_client["API client<br/>[axios.js]"]
  node_dashboard["Dashboard<br/>[DashboardPage.jsx]"]
  node_history["Scan history<br/>[HistoryPage.jsx]"]
  node_landing["Landing page<br/>[LandingPage.jsx]"]
  node_about["Research overview<br/>[AboutPage.jsx]"]
  node_navbar["Navigation<br/>[Navbar.jsx]"]
end

subgraph group_service["API and persistence"]
  node_api["FastAPI routes<br/>[main.py]"]
  node_auth["JWT authentication<br/>[auth.py]"]
  node_records["User and predictions<br/>[models.py]"]
  node_db[("Database access<br/>[database.py]")]
end

subgraph group_inference["Image inference"]
  node_predictor["Single-image predictor<br/>[predict.py]"]
  node_preprocess["Image preprocessing<br/>[preprocessing.py]"]
  node_gradcam["Visual explanations<br/>[gradcam.py]"]
end

subgraph group_research["Model research"]
  node_model["Model definitions<br/>[model.py]"]
  node_multiscale["Multi-scale CNN<br/>[multiscale_cnn.py]"]
  node_fusion["Feature fusion<br/>[feature_fusion.py]"]
  node_vit["Vision Transformer<br/>[vit_model.py]"]
  node_dataset["Dataset loading<br/>[dataset.py]"]
  node_augmentation["Training augmentation<br/>[augmentation.py]"]
  node_config["Model configuration<br/>[config.py]"]
  node_training["Model training<br/>[train.py]"]
  node_evaluation["Evaluation and comparison<br/>[evaluate.py]"]
end

node_user(("User"))

node_user -->|"opens"| node_app
node_app -->|"routes to"| node_analyze
node_app -->|"provides session"| node_auth_ui
node_app -->|"routes to"| node_dashboard
node_app -->|"routes to"| node_history
node_app -->|"routes to"| node_landing
node_app -->|"routes to"| node_about
node_app -->|"renders"| node_navbar
node_auth_ui -->|"requests through"| node_api_client
node_analyze -->|"requests through"| node_api_client
node_dashboard -->|"requests through"| node_api_client
node_history -->|"requests through"| node_api_client
node_api_client -->|"calls API"| node_api
node_api -->|"authenticates"| node_auth
node_auth -->|"queries users"| node_records
node_api -->|"stores predictions"| node_records
node_records -->|"uses database base"| node_db
node_api -->|"runs inference"| node_predictor
node_predictor -->|"preprocesses image"| node_preprocess
node_predictor -->|"classifies image"| node_model
node_predictor -->|"uses explanation"| node_gradcam
node_model -->|"extracts features"| node_multiscale
node_model -->|"fuses features"| node_fusion
node_model -->|"classifies fused map"| node_vit
node_dataset -->|"preprocesses samples"| node_preprocess
node_dataset -->|"transforms samples"| node_augmentation
node_training -->|"loads batches"| node_dataset
node_training -->|"trains model"| node_model
node_evaluation -->|"loads test data"| node_dataset
node_evaluation -->|"evaluates models"| node_model
node_dataset -->|"uses settings"| node_config
node_preprocess -->|"uses settings"| node_config

click node_app "https://github.com/krishnaharesh/glaucoma-vit/blob/main/frontend/src/App.jsx"
click node_analyze "https://github.com/krishnaharesh/glaucoma-vit/blob/main/frontend/src/pages/AnalyzePage.jsx"
click node_auth_ui "https://github.com/krishnaharesh/glaucoma-vit/blob/main/frontend/src/context/AuthContext.jsx"
click node_api_client "https://github.com/krishnaharesh/glaucoma-vit/blob/main/frontend/src/api/axios.js"
click node_dashboard "https://github.com/krishnaharesh/glaucoma-vit/blob/main/frontend/src/pages/DashboardPage.jsx"
click node_history "https://github.com/krishnaharesh/glaucoma-vit/blob/main/frontend/src/pages/HistoryPage.jsx"
click node_landing "https://github.com/krishnaharesh/glaucoma-vit/blob/main/frontend/src/pages/LandingPage.jsx"
click node_about "https://github.com/krishnaharesh/glaucoma-vit/blob/main/frontend/src/pages/AboutPage.jsx"
click node_navbar "https://github.com/krishnaharesh/glaucoma-vit/blob/main/frontend/src/components/Navbar.jsx"
click node_api "https://github.com/krishnaharesh/glaucoma-vit/blob/main/backend/main.py"
click node_auth "https://github.com/krishnaharesh/glaucoma-vit/blob/main/backend/auth.py"
click node_records "https://github.com/krishnaharesh/glaucoma-vit/blob/main/backend/models.py"
click node_db "https://github.com/krishnaharesh/glaucoma-vit/blob/main/backend/database.py"
click node_predictor "https://github.com/krishnaharesh/glaucoma-vit/blob/main/src/predict.py"
click node_preprocess "https://github.com/krishnaharesh/glaucoma-vit/blob/main/src/preprocessing.py"
click node_gradcam "https://github.com/krishnaharesh/glaucoma-vit/blob/main/src/gradcam.py"
click node_model "https://github.com/krishnaharesh/glaucoma-vit/blob/main/src/model.py"
click node_multiscale "https://github.com/krishnaharesh/glaucoma-vit/blob/main/src/multiscale_cnn.py"
click node_fusion "https://github.com/krishnaharesh/glaucoma-vit/blob/main/src/feature_fusion.py"
click node_vit "https://github.com/krishnaharesh/glaucoma-vit/blob/main/src/vit_model.py"
click node_dataset "https://github.com/krishnaharesh/glaucoma-vit/blob/main/src/dataset.py"
click node_augmentation "https://github.com/krishnaharesh/glaucoma-vit/blob/main/src/augmentation.py"
click node_config "https://github.com/krishnaharesh/glaucoma-vit/blob/main/src/config.py"
click node_training "https://github.com/krishnaharesh/glaucoma-vit/blob/main/src/train.py"
click node_evaluation "https://github.com/krishnaharesh/glaucoma-vit/blob/main/src/evaluate.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_analyze,node_auth_ui,node_api_client,node_dashboard,node_history,node_landing,node_about,node_navbar,node_user toneBlue
class node_api,node_auth,node_records,node_db toneAmber
class node_predictor,node_preprocess,node_gradcam toneMint
class node_model,node_multiscale,node_fusion,node_vit,node_dataset,node_augmentation,node_config,node_training,node_evaluation toneRose
```

## Components

### Web application

- [Routes and shell](https://github.com/krishnaharesh/glaucoma-vit/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Image analysis](https://github.com/krishnaharesh/glaucoma-vit/blob/main/frontend/src/pages/AnalyzePage.jsx): `frontend/src/pages/AnalyzePage.jsx`
- [Session context](https://github.com/krishnaharesh/glaucoma-vit/blob/main/frontend/src/context/AuthContext.jsx): `frontend/src/context/AuthContext.jsx`
- [API client](https://github.com/krishnaharesh/glaucoma-vit/blob/main/frontend/src/api/axios.js): `frontend/src/api/axios.js`
- [Dashboard](https://github.com/krishnaharesh/glaucoma-vit/blob/main/frontend/src/pages/DashboardPage.jsx): `frontend/src/pages/DashboardPage.jsx`
- [Scan history](https://github.com/krishnaharesh/glaucoma-vit/blob/main/frontend/src/pages/HistoryPage.jsx): `frontend/src/pages/HistoryPage.jsx`
- [Landing page](https://github.com/krishnaharesh/glaucoma-vit/blob/main/frontend/src/pages/LandingPage.jsx): `frontend/src/pages/LandingPage.jsx`
- [Research overview](https://github.com/krishnaharesh/glaucoma-vit/blob/main/frontend/src/pages/AboutPage.jsx): `frontend/src/pages/AboutPage.jsx`
- [Navigation](https://github.com/krishnaharesh/glaucoma-vit/blob/main/frontend/src/components/Navbar.jsx): `frontend/src/components/Navbar.jsx`

### API and persistence

- [FastAPI routes](https://github.com/krishnaharesh/glaucoma-vit/blob/main/backend/main.py): `backend/main.py`
- [JWT authentication](https://github.com/krishnaharesh/glaucoma-vit/blob/main/backend/auth.py): `backend/auth.py`
- [User and predictions](https://github.com/krishnaharesh/glaucoma-vit/blob/main/backend/models.py): `backend/models.py`
- [Database access](https://github.com/krishnaharesh/glaucoma-vit/blob/main/backend/database.py): `backend/database.py`

### Image inference

- [Single-image predictor](https://github.com/krishnaharesh/glaucoma-vit/blob/main/src/predict.py): `src/predict.py`
- [Image preprocessing](https://github.com/krishnaharesh/glaucoma-vit/blob/main/src/preprocessing.py): `src/preprocessing.py`
- [Visual explanations](https://github.com/krishnaharesh/glaucoma-vit/blob/main/src/gradcam.py): `src/gradcam.py`

### Model research

- [Model definitions](https://github.com/krishnaharesh/glaucoma-vit/blob/main/src/model.py): `src/model.py`
- [Multi-scale CNN](https://github.com/krishnaharesh/glaucoma-vit/blob/main/src/multiscale_cnn.py): `src/multiscale_cnn.py`
- [Feature fusion](https://github.com/krishnaharesh/glaucoma-vit/blob/main/src/feature_fusion.py): `src/feature_fusion.py`
- [Vision Transformer](https://github.com/krishnaharesh/glaucoma-vit/blob/main/src/vit_model.py): `src/vit_model.py`
- [Dataset loading](https://github.com/krishnaharesh/glaucoma-vit/blob/main/src/dataset.py): `src/dataset.py`
- [Training augmentation](https://github.com/krishnaharesh/glaucoma-vit/blob/main/src/augmentation.py): `src/augmentation.py`
- [Model configuration](https://github.com/krishnaharesh/glaucoma-vit/blob/main/src/config.py): `src/config.py`
- [Model training](https://github.com/krishnaharesh/glaucoma-vit/blob/main/src/train.py): `src/train.py`
- [Evaluation and comparison](https://github.com/krishnaharesh/glaucoma-vit/blob/main/src/evaluate.py): `src/evaluate.py`

### Other components

- **User**

## Connections

- User → Routes and shell: opens (evidence: `README.md`)
- Routes and shell → Image analysis: routes to (evidence: `frontend/src/App.jsx`)
- Routes and shell → Session context: provides session (evidence: `frontend/src/App.jsx`)
- Routes and shell → Dashboard: routes to (evidence: `frontend/src/App.jsx`)
- Routes and shell → Scan history: routes to (evidence: `frontend/src/App.jsx`)
- Routes and shell → Landing page: routes to (evidence: `frontend/src/App.jsx`)
- Routes and shell → Research overview: routes to (evidence: `frontend/src/App.jsx`)
- Routes and shell → Navigation: renders (evidence: `frontend/src/App.jsx`)
- Session context → API client: requests through (evidence: `frontend/src/context/AuthContext.jsx`)
- Image analysis → API client: requests through (evidence: `frontend/src/pages/AnalyzePage.jsx`)
- Dashboard → API client: requests through (evidence: `frontend/src/pages/DashboardPage.jsx`)
- Scan history → API client: requests through (evidence: `frontend/src/pages/HistoryPage.jsx`)
- API client → FastAPI routes: calls API (evidence: `README.md`)
- FastAPI routes → JWT authentication: authenticates (evidence: `backend/main.py`)
- JWT authentication → User and predictions: queries users (evidence: `backend/auth.py`)
- FastAPI routes → User and predictions: stores predictions (evidence: `backend/main.py`)
- User and predictions → Database access: uses database base (evidence: `backend/models.py`)
- FastAPI routes → Single-image predictor: runs inference (evidence: `backend/main.py`)
- Single-image predictor → Image preprocessing: preprocesses image (evidence: `src/predict.py`)
- Single-image predictor → Model definitions: classifies image (evidence: `src/predict.py`)
- Single-image predictor → Visual explanations: uses explanation (evidence: `src/predict.py`)
- Model definitions → Multi-scale CNN: extracts features (evidence: `src/model.py`)
- Model definitions → Feature fusion: fuses features (evidence: `src/model.py`)
- Model definitions → Vision Transformer: classifies fused map (evidence: `src/model.py`)
- Dataset loading → Image preprocessing: preprocesses samples (evidence: `src/dataset.py`)
- Dataset loading → Training augmentation: transforms samples (evidence: `src/dataset.py`)
- Model training → Dataset loading: loads batches (evidence: `src/train.py`)
- Model training → Model definitions: trains model (evidence: `src/train.py`)
- Evaluation and comparison → Dataset loading: loads test data (evidence: `src/evaluate.py`)
- Evaluation and comparison → Model definitions: evaluates models (evidence: `src/evaluate.py`)
- Dataset loading → Model configuration: uses settings (evidence: `src/dataset.py`)
- Image preprocessing → Model configuration: uses settings (evidence: `src/preprocessing.py`)
