# sai-chaitanya-ch/aarogya architecture

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

- Interactive diagram: https://gitdiagram.com/sai-chaitanya-ch/aarogya
- Repository: https://github.com/sai-chaitanya-ch/aarogya

## Overview

Aarogya is a mobile-first health copilot for patients and doctors. Patients set up a profile, scan and verify medical documents, then organize records, understand findings, track medicines and appointments, and share a clinical summary; doctors use a dedicated portal. The frontend coordinates these experiences and shared auth/health state, with optional Supabase persistence and a FastAPI document/chat backend. README capabilities such as ABHA linking, trends, and doctor workflows are represented, but some implementation details were not sampled, so their internal links are omitted.

Main entry points: [`src/App.tsx`](https://github.com/sai-chaitanya-ch/aarogya/blob/main/src/App.tsx) (App coordinator), [`backend/main.py`](https://github.com/sai-chaitanya-ch/aarogya/blob/main/backend/main.py) (FastAPI service), [`src/services/api.ts`](https://github.com/sai-chaitanya-ch/aarogya/blob/main/src/services/api.ts) (Backend API client), [`src/components/patient/ScanReviewStep.tsx`](https://github.com/sai-chaitanya-ch/aarogya/blob/main/src/components/patient/ScanReviewStep.tsx) (Scan review)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["App experience"]
  node_app["App coordinator<br/>[App.tsx]"]
  node_doctorportal["Doctor portal<br/>[DoctorPortal.tsx]"]
end

subgraph group_patient["Patient health tools"]
  node_onboard["Profile onboarding"]
  node_scan["Scan review<br/>[ScanReviewStep.tsx]"]
  node_camera["Live camera"]
  node_summary["Record summary"]
  node_library["Medical library<br/>[MedicalLibrary.tsx]"]
  node_trends["Health trends"]
  node_reminders["Medicine reminders"]
  node_appointments["Appointments"]
  node_doctors["Doctor directory<br/>[FindDoctor.tsx]"]
  node_abha["ABHA linking"]
  node_chat["Health chat<br/>[AskAarogyaChat.tsx]"]
end

subgraph group_services["AI and backend"]
  node_api["Backend API client<br/>[api.ts]"]
  node_ai["Client AI fallback<br/>[aiService.ts]"]
  node_backend["FastAPI service<br/>[main.py]"]
  node_ocr["OCR extraction<br/>[ocr_service.py]"]
  node_gemini["Gemini processing<br/>[gemini_service.py]"]
  node_storage["Private document storage<br/>[storage_service.py]"]
  node_export["Clinical summary export<br/>[exportService.ts]"]
end

subgraph group_state["Identity and health data"]
  node_auth["Authentication<br/>[AuthContext.tsx]"]
  node_healthdata["Health data state"]
  node_supabaseclient["Supabase client<br/>[supabase.ts]"]
end

node_person(("Patient or doctor"))
node_supabase[("Supabase data and storage")]

node_person -->|"uses"| node_app
node_app -->|"provides auth"| node_auth
node_app -->|"provides health state"| node_healthdata
node_app -->|"routes to"| node_onboard
node_app -->|"routes to"| node_scan
node_app -->|"routes to"| node_summary
node_app -->|"routes to"| node_library
node_app -->|"routes to"| node_trends
node_app -->|"routes to"| node_reminders
node_app -->|"routes to"| node_appointments
node_app -->|"routes to"| node_doctors
node_app -->|"opens"| node_abha
node_app -->|"routes to"| node_chat
node_app -->|"renders"| node_doctorportal
node_app -->|"calls"| node_export
node_scan -->|"opens"| node_camera
node_scan -->|"processes document"| node_api
node_chat -->|"requests response"| node_api
node_api -->|"falls back to"| node_ai
node_api -.->|"requests processing"| node_backend
node_backend -->|"calls"| node_ocr
node_backend -->|"calls"| node_gemini
node_backend -->|"calls"| node_storage
node_auth -->|"uses"| node_supabaseclient
node_healthdata -->|"uses"| node_supabaseclient
node_supabaseclient -.->|"connects to"| node_supabase
node_storage -->|"uploads and signs"| node_supabase

click node_app "https://github.com/sai-chaitanya-ch/aarogya/blob/main/src/App.tsx"
click node_onboard "https://github.com/sai-chaitanya-ch/aarogya/blob/main/src/components/patient/OnboardingSteps.tsx"
click node_scan "https://github.com/sai-chaitanya-ch/aarogya/blob/main/src/components/patient/ScanReviewStep.tsx"
click node_camera "https://github.com/sai-chaitanya-ch/aarogya/blob/main/src/components/patient/LiveCameraScanner.tsx"
click node_summary "https://github.com/sai-chaitanya-ch/aarogya/blob/main/src/components/patient/ReportSummaryStep.tsx"
click node_library "https://github.com/sai-chaitanya-ch/aarogya/blob/main/src/components/patient/MedicalLibrary.tsx"
click node_trends "https://github.com/sai-chaitanya-ch/aarogya/blob/main/src/components/patient/HealthTrendsView.tsx"
click node_reminders "https://github.com/sai-chaitanya-ch/aarogya/blob/main/src/components/patient/MedicinesReminders.tsx"
click node_appointments "https://github.com/sai-chaitanya-ch/aarogya/blob/main/src/components/patient/AppointmentsList.tsx"
click node_doctors "https://github.com/sai-chaitanya-ch/aarogya/blob/main/src/components/patient/FindDoctor.tsx"
click node_abha "https://github.com/sai-chaitanya-ch/aarogya/blob/main/src/components/patient/ABDMConnectionModal.tsx"
click node_chat "https://github.com/sai-chaitanya-ch/aarogya/blob/main/src/components/patient/AskAarogyaChat.tsx"
click node_doctorportal "https://github.com/sai-chaitanya-ch/aarogya/blob/main/src/components/doctor/DoctorPortal.tsx"
click node_auth "https://github.com/sai-chaitanya-ch/aarogya/blob/main/src/context/AuthContext.tsx"
click node_healthdata "https://github.com/sai-chaitanya-ch/aarogya/blob/main/src/context/HealthDataContext.tsx"
click node_supabaseclient "https://github.com/sai-chaitanya-ch/aarogya/blob/main/src/services/supabase.ts"
click node_api "https://github.com/sai-chaitanya-ch/aarogya/blob/main/src/services/api.ts"
click node_ai "https://github.com/sai-chaitanya-ch/aarogya/blob/main/src/services/aiService.ts"
click node_backend "https://github.com/sai-chaitanya-ch/aarogya/blob/main/backend/main.py"
click node_ocr "https://github.com/sai-chaitanya-ch/aarogya/blob/main/backend/ocr_service.py"
click node_gemini "https://github.com/sai-chaitanya-ch/aarogya/blob/main/backend/gemini_service.py"
click node_storage "https://github.com/sai-chaitanya-ch/aarogya/blob/main/backend/storage_service.py"
click node_export "https://github.com/sai-chaitanya-ch/aarogya/blob/main/src/services/exportService.ts"

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_doctorportal toneBlue
class node_onboard,node_scan,node_camera,node_summary,node_library,node_trends,node_reminders,node_appointments,node_doctors,node_abha,node_chat,node_supabase toneAmber
class node_api,node_ai,node_backend,node_ocr,node_gemini,node_storage,node_export toneMint
class node_auth,node_healthdata,node_supabaseclient toneRose
class node_person toneIndigo
```

## Components

### App experience

- [App coordinator](https://github.com/sai-chaitanya-ch/aarogya/blob/main/src/App.tsx): `src/App.tsx`
- [Doctor portal](https://github.com/sai-chaitanya-ch/aarogya/blob/main/src/components/doctor/DoctorPortal.tsx): `src/components/doctor/DoctorPortal.tsx`

### Patient health tools

- [Profile onboarding](https://github.com/sai-chaitanya-ch/aarogya/blob/main/src/components/patient/OnboardingSteps.tsx): `src/components/patient/OnboardingSteps.tsx`
- [Scan review](https://github.com/sai-chaitanya-ch/aarogya/blob/main/src/components/patient/ScanReviewStep.tsx): `src/components/patient/ScanReviewStep.tsx`
- [Live camera](https://github.com/sai-chaitanya-ch/aarogya/blob/main/src/components/patient/LiveCameraScanner.tsx): `src/components/patient/LiveCameraScanner.tsx`
- [Record summary](https://github.com/sai-chaitanya-ch/aarogya/blob/main/src/components/patient/ReportSummaryStep.tsx): `src/components/patient/ReportSummaryStep.tsx`
- [Medical library](https://github.com/sai-chaitanya-ch/aarogya/blob/main/src/components/patient/MedicalLibrary.tsx): `src/components/patient/MedicalLibrary.tsx`
- [Health trends](https://github.com/sai-chaitanya-ch/aarogya/blob/main/src/components/patient/HealthTrendsView.tsx): `src/components/patient/HealthTrendsView.tsx`
- [Medicine reminders](https://github.com/sai-chaitanya-ch/aarogya/blob/main/src/components/patient/MedicinesReminders.tsx): `src/components/patient/MedicinesReminders.tsx`
- [Appointments](https://github.com/sai-chaitanya-ch/aarogya/blob/main/src/components/patient/AppointmentsList.tsx): `src/components/patient/AppointmentsList.tsx`
- [Doctor directory](https://github.com/sai-chaitanya-ch/aarogya/blob/main/src/components/patient/FindDoctor.tsx): `src/components/patient/FindDoctor.tsx`
- [ABHA linking](https://github.com/sai-chaitanya-ch/aarogya/blob/main/src/components/patient/ABDMConnectionModal.tsx): `src/components/patient/ABDMConnectionModal.tsx`
- [Health chat](https://github.com/sai-chaitanya-ch/aarogya/blob/main/src/components/patient/AskAarogyaChat.tsx): `src/components/patient/AskAarogyaChat.tsx`

### AI and backend

- [Backend API client](https://github.com/sai-chaitanya-ch/aarogya/blob/main/src/services/api.ts): `src/services/api.ts`
- [Client AI fallback](https://github.com/sai-chaitanya-ch/aarogya/blob/main/src/services/aiService.ts): `src/services/aiService.ts`
- [FastAPI service](https://github.com/sai-chaitanya-ch/aarogya/blob/main/backend/main.py): `backend/main.py`
- [OCR extraction](https://github.com/sai-chaitanya-ch/aarogya/blob/main/backend/ocr_service.py): `backend/ocr_service.py`
- [Gemini processing](https://github.com/sai-chaitanya-ch/aarogya/blob/main/backend/gemini_service.py): `backend/gemini_service.py`
- [Private document storage](https://github.com/sai-chaitanya-ch/aarogya/blob/main/backend/storage_service.py): `backend/storage_service.py`
- [Clinical summary export](https://github.com/sai-chaitanya-ch/aarogya/blob/main/src/services/exportService.ts): `src/services/exportService.ts`

### Identity and health data

- [Authentication](https://github.com/sai-chaitanya-ch/aarogya/blob/main/src/context/AuthContext.tsx): `src/context/AuthContext.tsx`
- [Health data state](https://github.com/sai-chaitanya-ch/aarogya/blob/main/src/context/HealthDataContext.tsx): `src/context/HealthDataContext.tsx`
- [Supabase client](https://github.com/sai-chaitanya-ch/aarogya/blob/main/src/services/supabase.ts): `src/services/supabase.ts`

### Other components

- **Patient or doctor**
- **Supabase data and storage**

## Connections

- Patient or doctor → App coordinator: uses (evidence: `README.md`)
- App coordinator → Authentication: provides auth (evidence: `src/App.tsx`)
- App coordinator → Health data state: provides health state (evidence: `src/App.tsx`)
- App coordinator → Profile onboarding: routes to (evidence: `src/App.tsx`)
- App coordinator → Scan review: routes to (evidence: `src/App.tsx`)
- App coordinator → Record summary: routes to (evidence: `src/App.tsx`)
- App coordinator → Medical library: routes to (evidence: `src/App.tsx`)
- App coordinator → Health trends: routes to (evidence: `src/App.tsx`)
- App coordinator → Medicine reminders: routes to (evidence: `src/App.tsx`)
- App coordinator → Appointments: routes to (evidence: `src/App.tsx`)
- App coordinator → Doctor directory: routes to (evidence: `src/App.tsx`)
- App coordinator → ABHA linking: opens (evidence: `src/App.tsx`)
- App coordinator → Health chat: routes to (evidence: `src/App.tsx`)
- App coordinator → Doctor portal: renders (evidence: `src/App.tsx`)
- App coordinator → Clinical summary export: calls (evidence: `src/App.tsx`)
- Scan review → Live camera: opens (evidence: `src/components/patient/ScanReviewStep.tsx`)
- Scan review → Backend API client: processes document (evidence: `src/components/patient/ScanReviewStep.tsx`)
- Health chat → Backend API client: requests response (evidence: `src/components/patient/AskAarogyaChat.tsx`)
- Backend API client → Client AI fallback: falls back to (evidence: `src/services/api.ts`)
- Backend API client → FastAPI service: requests processing
- FastAPI service → OCR extraction: calls (evidence: `backend/main.py`)
- FastAPI service → Gemini processing: calls (evidence: `backend/main.py`)
- FastAPI service → Private document storage: calls (evidence: `backend/main.py`)
- Authentication → Supabase client: uses (evidence: `src/context/AuthContext.tsx`)
- Health data state → Supabase client: uses (evidence: `src/context/HealthDataContext.tsx`)
- Supabase client → Supabase data and storage: connects to
- Private document storage → Supabase data and storage: uploads and signs (evidence: `backend/storage_service.py`)
