# shiauryatripathi/drishtiiiii architecture

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

- Interactive diagram: https://gitdiagram.com/shiauryatripathi/drishtiiiii
- Repository: https://github.com/shiauryatripathi/drishtiiiii

## Overview

DRishtii is a local-first tele-ophthalmology workstation for diabetic-retinopathy screening. Its main workflow registers or selects a patient, captures/uploads a fundus image, runs local preprocessing and inference, and presents grading with an explainable clinical dossier for referral and follow-up. The app also supports patient queues, longitudinal review and multi-device SSE updates. The README documents the optical pipeline and diagnostic capabilities; sampled source confirms the scanner, inference engine, MATLAB fallback, and XAI components. Other unsampled capabilities are represented only where documented, with uncertain implementation links omitted.

Main entry points: [`src/App.tsx`](https://github.com/shiauryatripathi/drishtiiiii/blob/main/src/App.tsx) (Workstation UI), [`src/server/matlabEngine.ts`](https://github.com/shiauryatripathi/drishtiiiii/blob/main/src/server/matlabEngine.ts) (DR inference), [`src/components/Scanner.tsx`](https://github.com/shiauryatripathi/drishtiiiii/blob/main/src/components/Scanner.tsx) (Scan capture), [`src/components/Patients.tsx`](https://github.com/shiauryatripathi/drishtiiiii/blob/main/src/components/Patients.tsx) (Patient records)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Clinical workflow"]
  node_app["Workstation UI<br/>[App.tsx]"]
  node_patients["Patient records<br/>[Patients.tsx]"]
  node_scanner["Scan capture<br/>[Scanner.tsx]"]
  node_image["Fundus image"]
end

subgraph group_diagnostics["Edge diagnostics"]
  node_preprocess["Image preprocessing<br/>[matlabEngine.ts]"]
  node_inference["DR inference<br/>[matlabEngine.ts]"]
  node_matlab["MATLAB pipeline<br/>[run_pipeline.m]"]
  node_onnx["ONNX engine<br/>[matlabEngine.ts]"]
  node_xai["Explainable analysis<br/>[xaiEngine.ts]"]
  node_scanresult["Graded scan"]
end

subgraph group_care["Clinical review"]
  node_dossier["Clinical dossier"]
  node_confidence["Confidence display"]
  node_advisor["Care recommendations<br/>[Advisor.tsx]"]
  node_timeline["Longitudinal review"]
  node_dashboard["Screening dashboard<br/>[Dashboard.tsx]"]
end

subgraph group_sync["Local coordination"]
  node_syncclient["SSE client<br/>[useRealtimeSync.ts]"]
  node_server["API and event server<br/>[server.ts]"]
  node_records[("Local records<br/>[retiscan_db.json]")]
end

node_staff(("PHC staff"))
node_devices(("Other workstations"))

node_staff -->|"uses"| node_app
node_app -->|"routes to"| node_patients
node_app -->|"routes to"| node_scanner
node_staff -->|"captures scan"| node_scanner
node_scanner -->|"uploads"| node_image
node_image -->|"submits"| node_preprocess
node_preprocess -->|"prepares image"| node_inference
node_inference -->|"runs locally"| node_onnx
node_inference -->|"falls back to"| node_matlab
node_inference -->|"produces grade"| node_scanresult
node_scanresult -.->|"informs analysis"| node_xai
node_xai -.->|"supplies report"| node_dossier
node_scanner -->|"renders result"| node_dossier
node_dossier -->|"renders score"| node_confidence
node_app -->|"routes to"| node_dashboard
node_app -->|"routes to"| node_advisor
node_patients -->|"opens history"| node_timeline
node_dashboard -->|"subscribes"| node_syncclient
node_patients -->|"subscribes"| node_syncclient
node_syncclient -->|"opens SSE"| node_server
node_devices -->|"coordinates by SSE"| node_server
node_server -.->|"reads and writes"| node_records
node_inference -.->|"generates clinical report"| node_xai

click node_app "https://github.com/shiauryatripathi/drishtiiiii/blob/main/src/App.tsx"
click node_patients "https://github.com/shiauryatripathi/drishtiiiii/blob/main/src/components/Patients.tsx"
click node_scanner "https://github.com/shiauryatripathi/drishtiiiii/blob/main/src/components/Scanner.tsx"
click node_preprocess "https://github.com/shiauryatripathi/drishtiiiii/blob/main/src/server/matlabEngine.ts"
click node_inference "https://github.com/shiauryatripathi/drishtiiiii/blob/main/src/server/matlabEngine.ts"
click node_matlab "https://github.com/shiauryatripathi/drishtiiiii/blob/main/matlab/run_pipeline.m"
click node_onnx "https://github.com/shiauryatripathi/drishtiiiii/blob/main/src/server/matlabEngine.ts"
click node_xai "https://github.com/shiauryatripathi/drishtiiiii/blob/main/src/server/xaiEngine.ts"
click node_dossier "https://github.com/shiauryatripathi/drishtiiiii/blob/main/src/components/ExplainableAIDossier.tsx"
click node_confidence "https://github.com/shiauryatripathi/drishtiiiii/blob/main/src/components/ConfidenceGauge.tsx"
click node_advisor "https://github.com/shiauryatripathi/drishtiiiii/blob/main/src/components/Advisor.tsx"
click node_timeline "https://github.com/shiauryatripathi/drishtiiiii/blob/main/src/components/LongitudinalTimeline.tsx"
click node_dashboard "https://github.com/shiauryatripathi/drishtiiiii/blob/main/src/components/Dashboard.tsx"
click node_syncclient "https://github.com/shiauryatripathi/drishtiiiii/blob/main/src/lib/useRealtimeSync.ts"
click node_server "https://github.com/shiauryatripathi/drishtiiiii/blob/main/server.ts"
click node_records "https://github.com/shiauryatripathi/drishtiiiii/blob/main/retiscan_db.json"

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_patients,node_scanner,node_image toneBlue
class node_preprocess,node_inference,node_matlab,node_onnx,node_xai,node_scanresult toneAmber
class node_dossier,node_confidence,node_advisor,node_timeline,node_dashboard toneMint
class node_syncclient,node_server,node_records toneRose
class node_staff,node_devices toneIndigo
```

## Components

### Clinical workflow

- [Workstation UI](https://github.com/shiauryatripathi/drishtiiiii/blob/main/src/App.tsx): `src/App.tsx`
- [Patient records](https://github.com/shiauryatripathi/drishtiiiii/blob/main/src/components/Patients.tsx): `src/components/Patients.tsx`
- [Scan capture](https://github.com/shiauryatripathi/drishtiiiii/blob/main/src/components/Scanner.tsx): `src/components/Scanner.tsx`
- **Fundus image**

### Edge diagnostics

- [Image preprocessing](https://github.com/shiauryatripathi/drishtiiiii/blob/main/src/server/matlabEngine.ts): `src/server/matlabEngine.ts`
- [DR inference](https://github.com/shiauryatripathi/drishtiiiii/blob/main/src/server/matlabEngine.ts): `src/server/matlabEngine.ts`
- [MATLAB pipeline](https://github.com/shiauryatripathi/drishtiiiii/blob/main/matlab/run_pipeline.m): `matlab/run_pipeline.m`
- [ONNX engine](https://github.com/shiauryatripathi/drishtiiiii/blob/main/src/server/matlabEngine.ts): `src/server/matlabEngine.ts`
- [Explainable analysis](https://github.com/shiauryatripathi/drishtiiiii/blob/main/src/server/xaiEngine.ts): `src/server/xaiEngine.ts`
- **Graded scan**

### Clinical review

- [Clinical dossier](https://github.com/shiauryatripathi/drishtiiiii/blob/main/src/components/ExplainableAIDossier.tsx): `src/components/ExplainableAIDossier.tsx`
- [Confidence display](https://github.com/shiauryatripathi/drishtiiiii/blob/main/src/components/ConfidenceGauge.tsx): `src/components/ConfidenceGauge.tsx`
- [Care recommendations](https://github.com/shiauryatripathi/drishtiiiii/blob/main/src/components/Advisor.tsx): `src/components/Advisor.tsx`
- [Longitudinal review](https://github.com/shiauryatripathi/drishtiiiii/blob/main/src/components/LongitudinalTimeline.tsx): `src/components/LongitudinalTimeline.tsx`
- [Screening dashboard](https://github.com/shiauryatripathi/drishtiiiii/blob/main/src/components/Dashboard.tsx): `src/components/Dashboard.tsx`

### Local coordination

- [SSE client](https://github.com/shiauryatripathi/drishtiiiii/blob/main/src/lib/useRealtimeSync.ts): `src/lib/useRealtimeSync.ts`
- [API and event server](https://github.com/shiauryatripathi/drishtiiiii/blob/main/server.ts): `server.ts`
- [Local records](https://github.com/shiauryatripathi/drishtiiiii/blob/main/retiscan_db.json): `retiscan_db.json`

### Other components

- **PHC staff**
- **Other workstations**

## Connections

- PHC staff → Workstation UI: uses (evidence: `README.md`)
- Workstation UI → Patient records: routes to (evidence: `src/App.tsx`)
- Workstation UI → Scan capture: routes to (evidence: `src/App.tsx`)
- PHC staff → Scan capture: captures scan (evidence: `README.md`)
- Scan capture → Fundus image: uploads (evidence: `src/components/Scanner.tsx`)
- Fundus image → Image preprocessing: submits (evidence: `README.md`)
- Image preprocessing → DR inference: prepares image (evidence: `README.md`)
- DR inference → ONNX engine: runs locally (evidence: `src/server/matlabEngine.ts`)
- DR inference → MATLAB pipeline: falls back to (evidence: `src/server/matlabEngine.ts`)
- DR inference → Graded scan: produces grade (evidence: `README.md`)
- Graded scan → Explainable analysis: informs analysis
- Explainable analysis → Clinical dossier: supplies report
- Scan capture → Clinical dossier: renders result (evidence: `src/components/Scanner.tsx`)
- Clinical dossier → Confidence display: renders score (evidence: `src/components/ExplainableAIDossier.tsx`)
- Workstation UI → Screening dashboard: routes to (evidence: `src/App.tsx`)
- Workstation UI → Care recommendations: routes to (evidence: `src/App.tsx`)
- Patient records → Longitudinal review: opens history (evidence: `src/components/Patients.tsx`)
- Screening dashboard → SSE client: subscribes (evidence: `src/components/Dashboard.tsx`)
- Patient records → SSE client: subscribes (evidence: `src/components/Patients.tsx`)
- SSE client → API and event server: opens SSE (evidence: `src/lib/useRealtimeSync.ts`)
- Other workstations → API and event server: coordinates by SSE (evidence: `README.md`)
- API and event server → Local records: reads and writes
- DR inference → Explainable analysis: generates clinical report
