# yashpanwar1408/poshanscan-minor-project architecture

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

- Interactive diagram: https://gitdiagram.com/yashpanwar1408/poshanscan-minor-project
- Repository: https://github.com/yashpanwar1408/poshanscan-minor-project

## Overview

PoshanScan is a smartphone-assisted MUAC screening platform: a frontline worker registers a person, captures an arm image beside a reference marker, and receives a category-specific screening estimate; supervisors then review screening activity and locations. The architecture has a React worker and supervisor frontend, a FastAPI backend for identity, records, image handling and analytics, and a separate FastAPI computer-vision service. The README documents the end-to-end flow and portal capabilities; some router and frontend internals were not sampled, so those relationships are cited to the README rather than presented as inspected implementation details.

Main entry points: [`backend/app/main.py`](https://github.com/yashpanwar1408/poshanscan-minor-project/blob/main/backend/app/main.py) (Backend API), [`backend/app/routers/scans.py`](https://github.com/yashpanwar1408/poshanscan-minor-project/blob/main/backend/app/routers/scans.py) (Scan handling), [`frontend/src/routes/app`](https://github.com/yashpanwar1408/poshanscan-minor-project/tree/main/frontend/src/routes/app) (Worker application), [`backend/app/routers/dashboard.py`](https://github.com/yashpanwar1408/poshanscan-minor-project/blob/main/backend/app/routers/dashboard.py) (Dashboard analytics)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_worker["Worker screening"]
  node_worker_app["Worker application"]
  node_capture["Guided capture"]
  node_worker_api["Worker API client<br/>[api.ts]"]
  node_scan_result["Scan result<br/>[result.$scanId.tsx]"]
end

subgraph group_backend["Backend services"]
  node_backend_api["Backend API<br/>[main.py]"]
  node_authentication["Authentication<br/>[auth.py]"]
  node_people["Person records<br/>[children.py]"]
  node_scan_handling["Scan handling<br/>[scans.py]"]
  node_offline_sync["Offline sync<br/>[sync.py]"]
  node_image_storage["Image storage<br/>[storage.py]"]
  node_dashboard_api["Dashboard analytics<br/>[dashboard.py]"]
end

subgraph group_vision["MUAC inference"]
  node_ml_api["CV inference API<br/>[main.py]"]
  node_reference_detection["Marker scale"]
  node_arm_localization["Arm localization<br/>[pose_localize.py]"]
  node_arm_segmentation["Arm segmentation<br/>[segment.py]"]
  node_muac_estimation["MUAC estimation<br/>[estimate.py]"]
  node_risk_classification["Risk classification<br/>[classify.py]"]
end

subgraph group_supervision["Supervisor portal"]
  node_supervisor_portal["Supervisor portal"]
  node_supervisor_data["Portal data access<br/>[hooks.ts]"]
end

node_frontline_worker(("Frontline worker"))
node_relational_db[("Relational database")]
node_supervisor(("Supervisor"))

node_frontline_worker -->|"uses"| node_worker_app
node_worker_app -->|"opens capture"| node_capture
node_worker_app -.->|"requests"| node_worker_api
node_worker_api -->|"HTTP requests"| node_backend_api
node_backend_api -->|"routes auth"| node_authentication
node_backend_api -->|"routes people"| node_people
node_backend_api -->|"routes scans"| node_scan_handling
node_backend_api -->|"routes sync"| node_offline_sync
node_authentication -->|"reads and writes"| node_relational_db
node_people -->|"stores records"| node_relational_db
node_scan_handling -->|"stores photo"| node_image_storage
node_scan_handling -->|"requests inference"| node_ml_api
node_scan_handling -->|"stores scan"| node_relational_db
node_offline_sync -->|"syncs records"| node_relational_db
node_ml_api -->|"runs pipeline"| node_reference_detection
node_reference_detection -->|"provides scale"| node_arm_localization
node_arm_localization -->|"localizes arm"| node_arm_segmentation
node_arm_segmentation -->|"provides mask"| node_muac_estimation
node_muac_estimation -->|"estimates category"| node_risk_classification
node_ml_api -->|"returns estimate"| node_scan_handling
node_worker_app -->|"shows outcome"| node_scan_result
node_supervisor -->|"reviews screening"| node_supervisor_portal
node_supervisor_portal -.->|"loads portal data"| node_supervisor_data
node_supervisor_data -->|"requests analytics"| node_dashboard_api
node_dashboard_api -->|"queries screening data"| node_relational_db
node_dashboard_api -.->|"serves report images"| node_image_storage

click node_worker_app "https://github.com/yashpanwar1408/poshanscan-minor-project/tree/main/frontend/src/routes/app"
click node_capture "https://github.com/yashpanwar1408/poshanscan-minor-project/blob/main/frontend/src/routes/app/capture.%24childId.tsx"
click node_worker_api "https://github.com/yashpanwar1408/poshanscan-minor-project/blob/main/frontend/src/lib/api.ts"
click node_backend_api "https://github.com/yashpanwar1408/poshanscan-minor-project/blob/main/backend/app/main.py"
click node_authentication "https://github.com/yashpanwar1408/poshanscan-minor-project/blob/main/backend/app/routers/auth.py"
click node_people "https://github.com/yashpanwar1408/poshanscan-minor-project/blob/main/backend/app/routers/children.py"
click node_scan_handling "https://github.com/yashpanwar1408/poshanscan-minor-project/blob/main/backend/app/routers/scans.py"
click node_offline_sync "https://github.com/yashpanwar1408/poshanscan-minor-project/blob/main/backend/app/routers/sync.py"
click node_image_storage "https://github.com/yashpanwar1408/poshanscan-minor-project/blob/main/backend/app/services/storage.py"
click node_ml_api "https://github.com/yashpanwar1408/poshanscan-minor-project/blob/main/ml-service/app/main.py"
click node_reference_detection "https://github.com/yashpanwar1408/poshanscan-minor-project/blob/main/ml-service/app/pipeline/reference_detect.py"
click node_arm_localization "https://github.com/yashpanwar1408/poshanscan-minor-project/blob/main/ml-service/app/pipeline/pose_localize.py"
click node_arm_segmentation "https://github.com/yashpanwar1408/poshanscan-minor-project/blob/main/ml-service/app/pipeline/segment.py"
click node_muac_estimation "https://github.com/yashpanwar1408/poshanscan-minor-project/blob/main/ml-service/app/pipeline/estimate.py"
click node_risk_classification "https://github.com/yashpanwar1408/poshanscan-minor-project/blob/main/ml-service/app/pipeline/classify.py"
click node_scan_result "https://github.com/yashpanwar1408/poshanscan-minor-project/blob/main/frontend/src/routes/app/result.%24scanId.tsx"
click node_supervisor_portal "https://github.com/yashpanwar1408/poshanscan-minor-project/tree/main/frontend/src/supervisor"
click node_supervisor_data "https://github.com/yashpanwar1408/poshanscan-minor-project/blob/main/frontend/src/supervisor/api/hooks.ts"
click node_dashboard_api "https://github.com/yashpanwar1408/poshanscan-minor-project/blob/main/backend/app/routers/dashboard.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_worker_app,node_capture,node_worker_api,node_scan_result toneBlue
class node_backend_api,node_authentication,node_people,node_scan_handling,node_offline_sync,node_image_storage,node_dashboard_api,node_relational_db toneAmber
class node_ml_api,node_reference_detection,node_arm_localization,node_arm_segmentation,node_muac_estimation,node_risk_classification toneMint
class node_supervisor_portal,node_supervisor_data,node_frontline_worker toneRose
class node_supervisor toneIndigo
```

## Components

### Worker screening

- [Worker application](https://github.com/yashpanwar1408/poshanscan-minor-project/tree/main/frontend/src/routes/app): `frontend/src/routes/app`
- [Guided capture](https://github.com/yashpanwar1408/poshanscan-minor-project/blob/main/frontend/src/routes/app/capture.%24childId.tsx): `frontend/src/routes/app/capture.$childId.tsx`
- [Worker API client](https://github.com/yashpanwar1408/poshanscan-minor-project/blob/main/frontend/src/lib/api.ts): `frontend/src/lib/api.ts`
- [Scan result](https://github.com/yashpanwar1408/poshanscan-minor-project/blob/main/frontend/src/routes/app/result.%24scanId.tsx): `frontend/src/routes/app/result.$scanId.tsx`

### Backend services

- [Backend API](https://github.com/yashpanwar1408/poshanscan-minor-project/blob/main/backend/app/main.py): `backend/app/main.py`
- [Authentication](https://github.com/yashpanwar1408/poshanscan-minor-project/blob/main/backend/app/routers/auth.py): `backend/app/routers/auth.py`
- [Person records](https://github.com/yashpanwar1408/poshanscan-minor-project/blob/main/backend/app/routers/children.py): `backend/app/routers/children.py`
- [Scan handling](https://github.com/yashpanwar1408/poshanscan-minor-project/blob/main/backend/app/routers/scans.py): `backend/app/routers/scans.py`
- [Offline sync](https://github.com/yashpanwar1408/poshanscan-minor-project/blob/main/backend/app/routers/sync.py): `backend/app/routers/sync.py`
- [Image storage](https://github.com/yashpanwar1408/poshanscan-minor-project/blob/main/backend/app/services/storage.py): `backend/app/services/storage.py`
- [Dashboard analytics](https://github.com/yashpanwar1408/poshanscan-minor-project/blob/main/backend/app/routers/dashboard.py): `backend/app/routers/dashboard.py`

### MUAC inference

- [CV inference API](https://github.com/yashpanwar1408/poshanscan-minor-project/blob/main/ml-service/app/main.py): `ml-service/app/main.py`
- [Marker scale](https://github.com/yashpanwar1408/poshanscan-minor-project/blob/main/ml-service/app/pipeline/reference_detect.py): `ml-service/app/pipeline/reference_detect.py`
- [Arm localization](https://github.com/yashpanwar1408/poshanscan-minor-project/blob/main/ml-service/app/pipeline/pose_localize.py): `ml-service/app/pipeline/pose_localize.py`
- [Arm segmentation](https://github.com/yashpanwar1408/poshanscan-minor-project/blob/main/ml-service/app/pipeline/segment.py): `ml-service/app/pipeline/segment.py`
- [MUAC estimation](https://github.com/yashpanwar1408/poshanscan-minor-project/blob/main/ml-service/app/pipeline/estimate.py): `ml-service/app/pipeline/estimate.py`
- [Risk classification](https://github.com/yashpanwar1408/poshanscan-minor-project/blob/main/ml-service/app/pipeline/classify.py): `ml-service/app/pipeline/classify.py`

### Supervisor portal

- [Supervisor portal](https://github.com/yashpanwar1408/poshanscan-minor-project/tree/main/frontend/src/supervisor): `frontend/src/supervisor`
- [Portal data access](https://github.com/yashpanwar1408/poshanscan-minor-project/blob/main/frontend/src/supervisor/api/hooks.ts): `frontend/src/supervisor/api/hooks.ts`

### Other components

- **Frontline worker**
- **Relational database**
- **Supervisor**

## Connections

- Frontline worker → Worker application: uses (evidence: `README.md`)
- Worker application → Guided capture: opens capture (evidence: `README.md`)
- Worker application → Worker API client: requests
- Worker API client → Backend API: HTTP requests (evidence: `README.md`)
- Backend API → Authentication: routes auth (evidence: `backend/app/main.py`)
- Backend API → Person records: routes people (evidence: `backend/app/main.py`)
- Backend API → Scan handling: routes scans (evidence: `backend/app/main.py`)
- Backend API → Offline sync: routes sync (evidence: `backend/app/main.py`)
- Authentication → Relational database: reads and writes (evidence: `backend/app/routers/auth.py`)
- Person records → Relational database: stores records (evidence: `README.md`)
- Scan handling → Image storage: stores photo (evidence: `README.md`)
- Scan handling → CV inference API: requests inference (evidence: `README.md`)
- Scan handling → Relational database: stores scan (evidence: `README.md`)
- Offline sync → Relational database: syncs records (evidence: `README.md`)
- CV inference API → Marker scale: runs pipeline (evidence: `ml-service/app/main.py`)
- Marker scale → Arm localization: provides scale (evidence: `README.md`)
- Arm localization → Arm segmentation: localizes arm (evidence: `README.md`)
- Arm segmentation → MUAC estimation: provides mask (evidence: `README.md`)
- MUAC estimation → Risk classification: estimates category (evidence: `README.md`)
- CV inference API → Scan handling: returns estimate (evidence: `README.md`)
- Worker application → Scan result: shows outcome (evidence: `README.md`)
- Supervisor → Supervisor portal: reviews screening (evidence: `README.md`)
- Supervisor portal → Portal data access: loads portal data (evidence: `frontend/src/supervisor/pages/WorkersPage.tsx`)
- Portal data access → Dashboard analytics: requests analytics (evidence: `README.md`)
- Dashboard analytics → Relational database: queries screening data (evidence: `README.md`)
- Dashboard analytics → Image storage: serves report images
