# amanpandey284/sehat-saathi architecture

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

- Interactive diagram: https://gitdiagram.com/amanpandey284/sehat-saathi
- Repository: https://github.com/amanpandey284/sehat-saathi

## Overview

Sehat Saathi is a pre-consultation clinical intake prototype: patients provide consent and a complaint, complete adaptive history, optionally add prior documents, then review and submit a record for physician review. The product also supports urgent-safety flags, AYUSH history, multilingual and voice interaction, and a physician workflow for verification, conflicts, timeline, summaries, and FHIR-ready export. The graph centers the `src/` application and its API; duplicated `frontend/` modules are not expanded separately. Some subsystem links rely on README descriptions because their implementation was not sampled.

Main entry points: [`src/App.tsx`](https://github.com/amanpandey284/sehat-saathi/blob/main/src/App.tsx) (Application routes), [`src/features/patient/state/PatientSessionContext.tsx`](https://github.com/amanpandey284/sehat-saathi/blob/main/src/features/patient/state/PatientSessionContext.tsx) (Patient session), [`src/pages/PatientReview.tsx`](https://github.com/amanpandey284/sehat-saathi/blob/main/src/pages/PatientReview.tsx) (Patient review), [`backend/app/main.py`](https://github.com/amanpandey284/sehat-saathi/blob/main/backend/app/main.py) (FastAPI application)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_patient["Patient intake"]
  node_app["Application routes<br/>[App.tsx]"]
  node_session["Patient session"]
  node_consent["Consent and profile<br/>[ConsentScreen.tsx]"]
  node_complaint["Chief complaint"]
  node_adaptive["Adaptive history"]
  node_documents["Document upload"]
  node_ayush["AYUSH history<br/>[AyushMode.tsx]"]
  node_review_patient["Patient review<br/>[PatientReview.tsx]"]
  node_language["Language support"]
  node_voice["Voice input"]
end

subgraph group_clinical["Clinical processing"]
  node_question_engine["Question engine"]
  node_complaint_classifier["Complaint classifier"]
  node_normalizers["Answer normalization"]
  node_safety["Safety checks<br/>[safetyEngine.ts]"]
  node_routing["Clinical routing<br/>[routingService.ts]"]
end

subgraph group_review["Physician review"]
  node_record_utils["Record timeline<br/>[recordUtils.ts]"]
  node_doctor_dashboard["Physician dashboard"]
  node_conflicts["Conflict detection<br/>[conflictEngine.ts]"]
  node_summary["Evidence summary"]
  node_fhir["FHIR export<br/>[fhir.ts]"]
  node_patient_records["Patient records<br/>[patientRecords.ts]"]
end

subgraph group_platform["API and services"]
  node_api_client["API client<br/>[api.ts]"]
  node_auth_storage["Session tokens<br/>[authStorage.ts]"]
  node_api["FastAPI application<br/>[main.py]"]
  node_auth_api["Authentication API<br/>[auth.py]"]
  node_encounters_api["Encounter API<br/>[encounters.py]"]
  node_documents_api["Document OCR API<br/>[documents.py]"]
  node_ai_api["AI summary API<br/>[ai.py]"]
  node_auth_core["Auth services<br/>[auth.py]"]
  node_database[("Database<br/>[db.py]")]
  node_extractor["Medical extractor"]
end

node_patient(("Patient"))
node_external_ai["OpenAI provider"]

node_patient -->|"starts workflow"| node_app
node_app -->|"routes to"| node_consent
node_app -->|"routes to"| node_complaint
node_app -->|"routes to"| node_adaptive
node_app -->|"routes to"| node_documents
node_app -->|"routes to"| node_review_patient
node_app -->|"routes to"| node_ayush
node_app -->|"provides state"| node_session
node_app -->|"provides language"| node_language
node_complaint -.->|"records complaint"| node_session
node_adaptive -.->|"records history"| node_session
node_session -->|"classifies complaint"| node_complaint_classifier
node_adaptive -.->|"uses questions"| node_question_engine
node_session -->|"normalizes answers"| node_normalizers
node_session -->|"checks safety"| node_safety
node_complaint_classifier -->|"informs routing"| node_routing
node_patient -.->|"provides speech"| node_voice
node_patient -.->|"uploads records"| node_documents
node_review_patient -->|"reads intake"| node_session
node_review_patient -->|"saves record"| node_patient_records
node_review_patient -->|"posts encounter"| node_api
node_review_patient -->|"gets session token"| node_auth_storage
node_review_patient -->|"builds timeline"| node_record_utils
node_doctor_dashboard -.->|"detects contradictions"| node_conflicts
node_doctor_dashboard -.->|"shows summary"| node_summary
node_doctor_dashboard -.->|"exports record"| node_fhir
node_doctor_dashboard -.->|"reviews records"| node_patient_records
node_api -->|"registers router"| node_auth_api
node_api -->|"registers router"| node_encounters_api
node_api -->|"registers router"| node_documents_api
node_api -->|"registers router"| node_ai_api
node_auth_api -->|"uses auth"| node_auth_core
node_encounters_api -->|"uses auth"| node_auth_core
node_documents_api -->|"uses auth"| node_auth_core
node_ai_api -->|"uses auth"| node_auth_core
node_encounters_api -->|"uses database"| node_database
node_documents_api -->|"uses database"| node_database
node_ai_api -->|"uses database"| node_database
node_documents_api -->|"extracts medical data"| node_extractor
node_api_client -->|"uses tokens"| node_auth_storage
node_auth_storage -->|"requests guest session"| node_auth_api
node_ai_api -.->|"optionally summarizes"| node_external_ai

click node_app "https://github.com/amanpandey284/sehat-saathi/blob/main/src/App.tsx"
click node_session "https://github.com/amanpandey284/sehat-saathi/blob/main/src/features/patient/state/PatientSessionContext.tsx"
click node_consent "https://github.com/amanpandey284/sehat-saathi/blob/main/src/features/patient/ConsentScreen.tsx"
click node_complaint "https://github.com/amanpandey284/sehat-saathi/blob/main/src/features/patient/ChiefComplaintFlow.tsx"
click node_adaptive "https://github.com/amanpandey284/sehat-saathi/blob/main/src/features/patient/AdaptiveHistoryFlow.tsx"
click node_question_engine "https://github.com/amanpandey284/sehat-saathi/blob/main/src/features/patient/engine/questionEngineCore.ts"
click node_complaint_classifier "https://github.com/amanpandey284/sehat-saathi/blob/main/src/features/patient/services/complaintClassifier.ts"
click node_normalizers "https://github.com/amanpandey284/sehat-saathi/blob/main/src/features/patient/services/clinicalNormalizer.ts"
click node_safety "https://github.com/amanpandey284/sehat-saathi/blob/main/src/features/safety/safetyEngine.ts"
click node_routing "https://github.com/amanpandey284/sehat-saathi/blob/main/src/features/routing/routingService.ts"
click node_documents "https://github.com/amanpandey284/sehat-saathi/blob/main/src/pages/PatientDocuments.tsx"
click node_ayush "https://github.com/amanpandey284/sehat-saathi/blob/main/src/pages/AyushMode.tsx"
click node_review_patient "https://github.com/amanpandey284/sehat-saathi/blob/main/src/pages/PatientReview.tsx"
click node_record_utils "https://github.com/amanpandey284/sehat-saathi/blob/main/src/features/history/recordUtils.ts"
click node_doctor_dashboard "https://github.com/amanpandey284/sehat-saathi/blob/main/src/features/doctor/DoctorDashboard.tsx"
click node_conflicts "https://github.com/amanpandey284/sehat-saathi/blob/main/src/features/history/conflictEngine.ts"
click node_summary "https://github.com/amanpandey284/sehat-saathi/blob/main/src/features/history/summaryGenerator.ts"
click node_fhir "https://github.com/amanpandey284/sehat-saathi/blob/main/src/features/history/fhir.ts"
click node_patient_records "https://github.com/amanpandey284/sehat-saathi/blob/main/src/features/doctor/patientRecords.ts"
click node_api_client "https://github.com/amanpandey284/sehat-saathi/blob/main/src/services/api.ts"
click node_auth_storage "https://github.com/amanpandey284/sehat-saathi/blob/main/src/services/authStorage.ts"
click node_api "https://github.com/amanpandey284/sehat-saathi/blob/main/backend/app/main.py"
click node_auth_api "https://github.com/amanpandey284/sehat-saathi/blob/main/backend/app/api/auth.py"
click node_encounters_api "https://github.com/amanpandey284/sehat-saathi/blob/main/backend/app/api/encounters.py"
click node_documents_api "https://github.com/amanpandey284/sehat-saathi/blob/main/backend/app/api/documents.py"
click node_ai_api "https://github.com/amanpandey284/sehat-saathi/blob/main/backend/app/api/ai.py"
click node_auth_core "https://github.com/amanpandey284/sehat-saathi/blob/main/backend/app/core/auth.py"
click node_database "https://github.com/amanpandey284/sehat-saathi/blob/main/backend/app/core/db.py"
click node_extractor "https://github.com/amanpandey284/sehat-saathi/blob/main/backend/app/core/medical_extractor.py"
click node_language "https://github.com/amanpandey284/sehat-saathi/blob/main/src/i18n/LanguageContext.tsx"
click node_voice "https://github.com/amanpandey284/sehat-saathi/blob/main/src/components/VoiceInputButton.tsx"

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_session,node_consent,node_complaint,node_adaptive,node_documents,node_ayush,node_review_patient,node_language,node_voice toneBlue
class node_question_engine,node_complaint_classifier,node_normalizers,node_safety,node_routing toneAmber
class node_record_utils,node_doctor_dashboard,node_conflicts,node_summary,node_fhir,node_patient_records toneMint
class node_api_client,node_auth_storage,node_api,node_auth_api,node_encounters_api,node_documents_api,node_ai_api,node_auth_core,node_database,node_extractor toneRose
class node_patient,node_external_ai toneIndigo
```

## Components

### Patient intake

- [Application routes](https://github.com/amanpandey284/sehat-saathi/blob/main/src/App.tsx): `src/App.tsx`
- [Patient session](https://github.com/amanpandey284/sehat-saathi/blob/main/src/features/patient/state/PatientSessionContext.tsx): `src/features/patient/state/PatientSessionContext.tsx`
- [Consent and profile](https://github.com/amanpandey284/sehat-saathi/blob/main/src/features/patient/ConsentScreen.tsx): `src/features/patient/ConsentScreen.tsx`
- [Chief complaint](https://github.com/amanpandey284/sehat-saathi/blob/main/src/features/patient/ChiefComplaintFlow.tsx): `src/features/patient/ChiefComplaintFlow.tsx`
- [Adaptive history](https://github.com/amanpandey284/sehat-saathi/blob/main/src/features/patient/AdaptiveHistoryFlow.tsx): `src/features/patient/AdaptiveHistoryFlow.tsx`
- [Document upload](https://github.com/amanpandey284/sehat-saathi/blob/main/src/pages/PatientDocuments.tsx): `src/pages/PatientDocuments.tsx`
- [AYUSH history](https://github.com/amanpandey284/sehat-saathi/blob/main/src/pages/AyushMode.tsx): `src/pages/AyushMode.tsx`
- [Patient review](https://github.com/amanpandey284/sehat-saathi/blob/main/src/pages/PatientReview.tsx): `src/pages/PatientReview.tsx`
- [Language support](https://github.com/amanpandey284/sehat-saathi/blob/main/src/i18n/LanguageContext.tsx): `src/i18n/LanguageContext.tsx`
- [Voice input](https://github.com/amanpandey284/sehat-saathi/blob/main/src/components/VoiceInputButton.tsx): `src/components/VoiceInputButton.tsx`

### Clinical processing

- [Question engine](https://github.com/amanpandey284/sehat-saathi/blob/main/src/features/patient/engine/questionEngineCore.ts): `src/features/patient/engine/questionEngineCore.ts`
- [Complaint classifier](https://github.com/amanpandey284/sehat-saathi/blob/main/src/features/patient/services/complaintClassifier.ts): `src/features/patient/services/complaintClassifier.ts`
- [Answer normalization](https://github.com/amanpandey284/sehat-saathi/blob/main/src/features/patient/services/clinicalNormalizer.ts): `src/features/patient/services/clinicalNormalizer.ts`
- [Safety checks](https://github.com/amanpandey284/sehat-saathi/blob/main/src/features/safety/safetyEngine.ts): `src/features/safety/safetyEngine.ts`
- [Clinical routing](https://github.com/amanpandey284/sehat-saathi/blob/main/src/features/routing/routingService.ts): `src/features/routing/routingService.ts`

### Physician review

- [Record timeline](https://github.com/amanpandey284/sehat-saathi/blob/main/src/features/history/recordUtils.ts): `src/features/history/recordUtils.ts`
- [Physician dashboard](https://github.com/amanpandey284/sehat-saathi/blob/main/src/features/doctor/DoctorDashboard.tsx): `src/features/doctor/DoctorDashboard.tsx`
- [Conflict detection](https://github.com/amanpandey284/sehat-saathi/blob/main/src/features/history/conflictEngine.ts): `src/features/history/conflictEngine.ts`
- [Evidence summary](https://github.com/amanpandey284/sehat-saathi/blob/main/src/features/history/summaryGenerator.ts): `src/features/history/summaryGenerator.ts`
- [FHIR export](https://github.com/amanpandey284/sehat-saathi/blob/main/src/features/history/fhir.ts): `src/features/history/fhir.ts`
- [Patient records](https://github.com/amanpandey284/sehat-saathi/blob/main/src/features/doctor/patientRecords.ts): `src/features/doctor/patientRecords.ts`

### API and services

- [API client](https://github.com/amanpandey284/sehat-saathi/blob/main/src/services/api.ts): `src/services/api.ts`
- [Session tokens](https://github.com/amanpandey284/sehat-saathi/blob/main/src/services/authStorage.ts): `src/services/authStorage.ts`
- [FastAPI application](https://github.com/amanpandey284/sehat-saathi/blob/main/backend/app/main.py): `backend/app/main.py`
- [Authentication API](https://github.com/amanpandey284/sehat-saathi/blob/main/backend/app/api/auth.py): `backend/app/api/auth.py`
- [Encounter API](https://github.com/amanpandey284/sehat-saathi/blob/main/backend/app/api/encounters.py): `backend/app/api/encounters.py`
- [Document OCR API](https://github.com/amanpandey284/sehat-saathi/blob/main/backend/app/api/documents.py): `backend/app/api/documents.py`
- [AI summary API](https://github.com/amanpandey284/sehat-saathi/blob/main/backend/app/api/ai.py): `backend/app/api/ai.py`
- [Auth services](https://github.com/amanpandey284/sehat-saathi/blob/main/backend/app/core/auth.py): `backend/app/core/auth.py`
- [Database](https://github.com/amanpandey284/sehat-saathi/blob/main/backend/app/core/db.py): `backend/app/core/db.py`
- [Medical extractor](https://github.com/amanpandey284/sehat-saathi/blob/main/backend/app/core/medical_extractor.py): `backend/app/core/medical_extractor.py`

### Other components

- **Patient**
- **OpenAI provider**

## Connections

- Patient → Application routes: starts workflow (evidence: `src/App.tsx`)
- Application routes → Consent and profile: routes to (evidence: `src/App.tsx`)
- Application routes → Chief complaint: routes to (evidence: `src/App.tsx`)
- Application routes → Adaptive history: routes to (evidence: `src/App.tsx`)
- Application routes → Document upload: routes to (evidence: `src/App.tsx`)
- Application routes → Patient review: routes to (evidence: `src/App.tsx`)
- Application routes → AYUSH history: routes to (evidence: `src/App.tsx`)
- Application routes → Patient session: provides state (evidence: `src/App.tsx`)
- Application routes → Language support: provides language (evidence: `src/App.tsx`)
- Chief complaint → Patient session: records complaint
- Adaptive history → Patient session: records history
- Patient session → Complaint classifier: classifies complaint (evidence: `src/features/patient/state/PatientSessionContext.tsx`)
- Adaptive history → Question engine: uses questions
- Patient session → Answer normalization: normalizes answers (evidence: `src/features/patient/state/PatientSessionContext.tsx`)
- Patient session → Safety checks: checks safety (evidence: `src/features/safety/safetyEngine.ts`)
- Complaint classifier → Clinical routing: informs routing (evidence: `src/features/routing/routingService.ts`)
- Patient → Voice input: provides speech (evidence: `README.md`)
- Patient → Document upload: uploads records (evidence: `README.md`)
- Patient review → Patient session: reads intake (evidence: `src/pages/PatientReview.tsx`)
- Patient review → Patient records: saves record (evidence: `src/pages/PatientReview.tsx`)
- Patient review → FastAPI application: posts encounter (evidence: `src/pages/PatientReview.tsx`)
- Patient review → Session tokens: gets session token (evidence: `src/pages/PatientReview.tsx`)
- Patient review → Record timeline: builds timeline (evidence: `src/pages/PatientReview.tsx`)
- Physician dashboard → Conflict detection: detects contradictions (evidence: `README.md`)
- Physician dashboard → Evidence summary: shows summary (evidence: `README.md`)
- Physician dashboard → FHIR export: exports record (evidence: `README.md`)
- Physician dashboard → Patient records: reviews records (evidence: `README.md`)
- FastAPI application → Authentication API: registers router (evidence: `backend/app/main.py`)
- FastAPI application → Encounter API: registers router (evidence: `backend/app/main.py`)
- FastAPI application → Document OCR API: registers router (evidence: `backend/app/main.py`)
- FastAPI application → AI summary API: registers router (evidence: `backend/app/main.py`)
- Authentication API → Auth services: uses auth (evidence: `backend/app/api/auth.py`)
- Encounter API → Auth services: uses auth (evidence: `backend/app/api/encounters.py`)
- Document OCR API → Auth services: uses auth (evidence: `backend/app/api/documents.py`)
- AI summary API → Auth services: uses auth (evidence: `backend/app/api/ai.py`)
- Encounter API → Database: uses database (evidence: `backend/app/api/encounters.py`)
- Document OCR API → Database: uses database (evidence: `backend/app/api/documents.py`)
- AI summary API → Database: uses database (evidence: `backend/app/api/ai.py`)
- Document OCR API → Medical extractor: extracts medical data (evidence: `backend/app/api/documents.py`)
- API client → Session tokens: uses tokens (evidence: `src/services/api.ts`)
- Session tokens → Authentication API: requests guest session (evidence: `src/services/authStorage.ts`)
- AI summary API → OpenAI provider: optionally summarizes (evidence: `README.md`)
