# dinesh-2007/swasthai architecture

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

- Interactive diagram: https://gitdiagram.com/dinesh-2007/swasthai
- Repository: https://github.com/dinesh-2007/swasthai

## Overview

SwasthAI is a mobile-first health screening and care-coordination product for citizens and health workers, backed by an API and an administrative web console. The main citizen workflow gathers symptoms, vitals, or an image, runs on-device screening and clinical reasoning, then presents a result and guidance. Other visible capabilities include local health Q&A, patient management, reports, referrals, and data sync. Source evidence is partial; unverified connections are omitted or shown as dashed.

Main entry points: [`SwasthAI/app/src/main/java/com/swasthai/app/data/repository`](https://github.com/dinesh-2007/swasthai/tree/main/SwasthAI/app/src/main/java/com/swasthai/app/data/repository) (App repositories), [`SwasthAI/app/src/main/java/com/swasthai/app/ai/engine/AIEngineManager.kt`](https://github.com/dinesh-2007/swasthai/blob/main/SwasthAI/app/src/main/java/com/swasthai/app/ai/engine/AIEngineManager.kt) (Screening orchestrator), [`SwasthAI/app/src/main/java/com/swasthai/app/ai/engine/ClinicalReasoningEngine.kt`](https://github.com/dinesh-2007/swasthai/blob/main/SwasthAI/app/src/main/java/com/swasthai/app/ai/engine/ClinicalReasoningEngine.kt) (Clinical reasoning), [`SwasthAI/app/src/main/java/com/swasthai/app/data/remote/api/SwasthAIApiService.kt`](https://github.com/dinesh-2007/swasthai/blob/main/SwasthAI/app/src/main/java/com/swasthai/app/data/remote/api/SwasthAIApiService.kt) (Mobile API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_mobile["Mobile app"]
  node_navigation["App navigation"]
  node_screening_ui["Screening experience"]
  node_screening_result["Screening results"]
  node_chat["Health chat<br/>[AiChatEngine.kt]"]
  node_hw_patients["Worker patient care"]
  node_hw_followup["Follow-up and referral"]
  node_hw_reports["Worker reports<br/>[HWReportsScreen.kt]"]
  node_sync["Offline data sync<br/>[SyncWorker.kt]"]
end

subgraph group_clinical["Clinical intelligence"]
  node_ai_manager["Screening orchestrator<br/>[AIEngineManager.kt]"]
  node_image_model["Image classifier<br/>[ImageClassifier.kt]"]
  node_scan_registry["Scan model registry<br/>[ScanType.kt]"]
  node_reasoning["Clinical reasoning"]
  node_clinical_knowledge["Clinical knowledge"]
  node_disease_knowledge["Disease advice base"]
  node_rag_retriever["Local RAG retrieval"]
  node_rag_docs["RAG documents<br/>[RagDocument.kt]"]
end

subgraph group_data["Data services"]
  node_repositories["App repositories"]
  node_local_db[("Local health database")]
  node_preferences[("User preferences<br/>[UserPreferences.kt]")]
  node_api_client["Mobile API client"]
end

subgraph group_backend["Backend API"]
  node_backend_api["Backend endpoints<br/>[main.py]"]
  node_backend_db[("Backend database<br/>[database.py]")]
end

subgraph group_admin["Admin console"]
  node_admin_console["Admin dashboard<br/>[page.tsx]"]
  node_admin_routes["Admin API routes<br/>[route.ts]"]
end

node_citizen(("Citizen or worker"))
node_remote_service(("Remote service"))

node_citizen -.->|"opens app"| node_navigation
node_navigation -.->|"routes to"| node_screening_ui
node_screening_ui -.->|"requests screening"| node_ai_manager
node_ai_manager -->|"classifies image"| node_image_model
node_ai_manager -->|"reasons symptoms"| node_reasoning
node_ai_manager -.->|"returns diagnosis"| node_screening_result
node_image_model -->|"uses scan types"| node_scan_registry
node_reasoning -->|"uses clinical rules"| node_clinical_knowledge
node_reasoning -->|"uses disease data"| node_disease_knowledge
node_reasoning -->|"retrieves context"| node_rag_retriever
node_chat -->|"retrieves answers"| node_rag_retriever
node_rag_retriever -->|"reads documents"| node_rag_docs
node_hw_patients -.->|"uses patient data"| node_repositories
node_hw_followup -->|"routes follow-up"| node_navigation
node_hw_reports -.->|"loads reports"| node_repositories
node_sync -.->|"syncs records"| node_repositories
node_repositories -.->|"reads and writes"| node_local_db
node_repositories -.->|"uploads data"| node_api_client
node_api_client -.->|"sends requests"| node_remote_service
node_api_client -->|"gets session token"| node_preferences
node_backend_api -->|"uses database session"| node_backend_db
node_remote_service -.->|"serves API requests"| node_backend_api
node_admin_console -.->|"loads admin data"| node_admin_routes
node_admin_routes -.->|"requests records"| node_backend_api

click node_navigation "https://github.com/dinesh-2007/swasthai/blob/main/SwasthAI/app/src/main/java/com/swasthai/app/navigation/HealthWorkerNavGraph.kt"
click node_screening_ui "https://github.com/dinesh-2007/swasthai/blob/main/SwasthAI/app/src/main/java/com/swasthai/app/feature/citizen/screening/ScreeningViewModel.kt"
click node_screening_result "https://github.com/dinesh-2007/swasthai/blob/main/SwasthAI/app/src/main/java/com/swasthai/app/feature/citizen/diagnosis/ScreeningResultScreen.kt"
click node_chat "https://github.com/dinesh-2007/swasthai/blob/main/SwasthAI/app/src/main/java/com/swasthai/app/feature/citizen/aichat/AiChatEngine.kt"
click node_hw_patients "https://github.com/dinesh-2007/swasthai/blob/main/SwasthAI/app/src/main/java/com/swasthai/app/feature/healthworker/patients/PatientViewModel.kt"
click node_hw_followup "https://github.com/dinesh-2007/swasthai/blob/main/SwasthAI/app/src/main/java/com/swasthai/app/feature/healthworker/screening/ScheduleAndReferScreens.kt"
click node_hw_reports "https://github.com/dinesh-2007/swasthai/blob/main/SwasthAI/app/src/main/java/com/swasthai/app/feature/healthworker/reports/HWReportsScreen.kt"
click node_sync "https://github.com/dinesh-2007/swasthai/blob/main/SwasthAI/app/src/main/java/com/swasthai/app/sync/SyncWorker.kt"
click node_ai_manager "https://github.com/dinesh-2007/swasthai/blob/main/SwasthAI/app/src/main/java/com/swasthai/app/ai/engine/AIEngineManager.kt"
click node_image_model "https://github.com/dinesh-2007/swasthai/blob/main/SwasthAI/app/src/main/java/com/swasthai/app/ai/engine/ImageClassifier.kt"
click node_scan_registry "https://github.com/dinesh-2007/swasthai/blob/main/SwasthAI/app/src/main/java/com/swasthai/app/ai/engine/ScanType.kt"
click node_reasoning "https://github.com/dinesh-2007/swasthai/blob/main/SwasthAI/app/src/main/java/com/swasthai/app/ai/engine/ClinicalReasoningEngine.kt"
click node_clinical_knowledge "https://github.com/dinesh-2007/swasthai/blob/main/SwasthAI/app/src/main/java/com/swasthai/app/ai/engine/ClinicalKnowledge.kt"
click node_disease_knowledge "https://github.com/dinesh-2007/swasthai/blob/main/SwasthAI/app/src/main/java/com/swasthai/app/ai/engine/DiseaseKnowledgeBase.kt"
click node_rag_retriever "https://github.com/dinesh-2007/swasthai/blob/main/SwasthAI/app/src/main/java/com/swasthai/app/ai/engine/LocalRagRetriever.kt"
click node_rag_docs "https://github.com/dinesh-2007/swasthai/blob/main/SwasthAI/app/src/main/java/com/swasthai/app/ai/engine/RagDocument.kt"
click node_repositories "https://github.com/dinesh-2007/swasthai/tree/main/SwasthAI/app/src/main/java/com/swasthai/app/data/repository"
click node_local_db "https://github.com/dinesh-2007/swasthai/blob/main/SwasthAI/app/src/main/java/com/swasthai/app/data/local/database/SwasthAIDatabase.kt"
click node_preferences "https://github.com/dinesh-2007/swasthai/blob/main/SwasthAI/app/src/main/java/com/swasthai/app/data/local/datastore/UserPreferences.kt"
click node_api_client "https://github.com/dinesh-2007/swasthai/blob/main/SwasthAI/app/src/main/java/com/swasthai/app/data/remote/api/SwasthAIApiService.kt"
click node_backend_api "https://github.com/dinesh-2007/swasthai/blob/main/backend/main.py"
click node_backend_db "https://github.com/dinesh-2007/swasthai/blob/main/backend/database.py"
click node_admin_console "https://github.com/dinesh-2007/swasthai/blob/main/web/src/app/(admin)/overview/page.tsx"
click node_admin_routes "https://github.com/dinesh-2007/swasthai/blob/main/web/src/app/api/patients/route.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_navigation,node_screening_ui,node_screening_result,node_chat,node_hw_patients,node_hw_followup,node_hw_reports,node_sync toneBlue
class node_ai_manager,node_image_model,node_scan_registry,node_reasoning,node_clinical_knowledge,node_disease_knowledge,node_rag_retriever,node_rag_docs toneAmber
class node_repositories,node_local_db,node_preferences,node_api_client toneMint
class node_backend_api,node_backend_db,node_citizen toneRose
class node_admin_console,node_admin_routes,node_remote_service toneIndigo
```

## Components

### Mobile app

- [App navigation](https://github.com/dinesh-2007/swasthai/blob/main/SwasthAI/app/src/main/java/com/swasthai/app/navigation/HealthWorkerNavGraph.kt): `SwasthAI/app/src/main/java/com/swasthai/app/navigation/HealthWorkerNavGraph.kt`
- [Screening experience](https://github.com/dinesh-2007/swasthai/blob/main/SwasthAI/app/src/main/java/com/swasthai/app/feature/citizen/screening/ScreeningViewModel.kt): `SwasthAI/app/src/main/java/com/swasthai/app/feature/citizen/screening/ScreeningViewModel.kt`
- [Screening results](https://github.com/dinesh-2007/swasthai/blob/main/SwasthAI/app/src/main/java/com/swasthai/app/feature/citizen/diagnosis/ScreeningResultScreen.kt): `SwasthAI/app/src/main/java/com/swasthai/app/feature/citizen/diagnosis/ScreeningResultScreen.kt`
- [Health chat](https://github.com/dinesh-2007/swasthai/blob/main/SwasthAI/app/src/main/java/com/swasthai/app/feature/citizen/aichat/AiChatEngine.kt): `SwasthAI/app/src/main/java/com/swasthai/app/feature/citizen/aichat/AiChatEngine.kt`
- [Worker patient care](https://github.com/dinesh-2007/swasthai/blob/main/SwasthAI/app/src/main/java/com/swasthai/app/feature/healthworker/patients/PatientViewModel.kt): `SwasthAI/app/src/main/java/com/swasthai/app/feature/healthworker/patients/PatientViewModel.kt`
- [Follow-up and referral](https://github.com/dinesh-2007/swasthai/blob/main/SwasthAI/app/src/main/java/com/swasthai/app/feature/healthworker/screening/ScheduleAndReferScreens.kt): `SwasthAI/app/src/main/java/com/swasthai/app/feature/healthworker/screening/ScheduleAndReferScreens.kt`
- [Worker reports](https://github.com/dinesh-2007/swasthai/blob/main/SwasthAI/app/src/main/java/com/swasthai/app/feature/healthworker/reports/HWReportsScreen.kt): `SwasthAI/app/src/main/java/com/swasthai/app/feature/healthworker/reports/HWReportsScreen.kt`
- [Offline data sync](https://github.com/dinesh-2007/swasthai/blob/main/SwasthAI/app/src/main/java/com/swasthai/app/sync/SyncWorker.kt): `SwasthAI/app/src/main/java/com/swasthai/app/sync/SyncWorker.kt`

### Clinical intelligence

- [Screening orchestrator](https://github.com/dinesh-2007/swasthai/blob/main/SwasthAI/app/src/main/java/com/swasthai/app/ai/engine/AIEngineManager.kt): `SwasthAI/app/src/main/java/com/swasthai/app/ai/engine/AIEngineManager.kt`
- [Image classifier](https://github.com/dinesh-2007/swasthai/blob/main/SwasthAI/app/src/main/java/com/swasthai/app/ai/engine/ImageClassifier.kt): `SwasthAI/app/src/main/java/com/swasthai/app/ai/engine/ImageClassifier.kt`
- [Scan model registry](https://github.com/dinesh-2007/swasthai/blob/main/SwasthAI/app/src/main/java/com/swasthai/app/ai/engine/ScanType.kt): `SwasthAI/app/src/main/java/com/swasthai/app/ai/engine/ScanType.kt`
- [Clinical reasoning](https://github.com/dinesh-2007/swasthai/blob/main/SwasthAI/app/src/main/java/com/swasthai/app/ai/engine/ClinicalReasoningEngine.kt): `SwasthAI/app/src/main/java/com/swasthai/app/ai/engine/ClinicalReasoningEngine.kt`
- [Clinical knowledge](https://github.com/dinesh-2007/swasthai/blob/main/SwasthAI/app/src/main/java/com/swasthai/app/ai/engine/ClinicalKnowledge.kt): `SwasthAI/app/src/main/java/com/swasthai/app/ai/engine/ClinicalKnowledge.kt`
- [Disease advice base](https://github.com/dinesh-2007/swasthai/blob/main/SwasthAI/app/src/main/java/com/swasthai/app/ai/engine/DiseaseKnowledgeBase.kt): `SwasthAI/app/src/main/java/com/swasthai/app/ai/engine/DiseaseKnowledgeBase.kt`
- [Local RAG retrieval](https://github.com/dinesh-2007/swasthai/blob/main/SwasthAI/app/src/main/java/com/swasthai/app/ai/engine/LocalRagRetriever.kt): `SwasthAI/app/src/main/java/com/swasthai/app/ai/engine/LocalRagRetriever.kt`
- [RAG documents](https://github.com/dinesh-2007/swasthai/blob/main/SwasthAI/app/src/main/java/com/swasthai/app/ai/engine/RagDocument.kt): `SwasthAI/app/src/main/java/com/swasthai/app/ai/engine/RagDocument.kt`

### Data services

- [App repositories](https://github.com/dinesh-2007/swasthai/tree/main/SwasthAI/app/src/main/java/com/swasthai/app/data/repository): `SwasthAI/app/src/main/java/com/swasthai/app/data/repository`
- [Local health database](https://github.com/dinesh-2007/swasthai/blob/main/SwasthAI/app/src/main/java/com/swasthai/app/data/local/database/SwasthAIDatabase.kt): `SwasthAI/app/src/main/java/com/swasthai/app/data/local/database/SwasthAIDatabase.kt`
- [User preferences](https://github.com/dinesh-2007/swasthai/blob/main/SwasthAI/app/src/main/java/com/swasthai/app/data/local/datastore/UserPreferences.kt): `SwasthAI/app/src/main/java/com/swasthai/app/data/local/datastore/UserPreferences.kt`
- [Mobile API client](https://github.com/dinesh-2007/swasthai/blob/main/SwasthAI/app/src/main/java/com/swasthai/app/data/remote/api/SwasthAIApiService.kt): `SwasthAI/app/src/main/java/com/swasthai/app/data/remote/api/SwasthAIApiService.kt`

### Backend API

- [Backend endpoints](https://github.com/dinesh-2007/swasthai/blob/main/backend/main.py): `backend/main.py`
- [Backend database](https://github.com/dinesh-2007/swasthai/blob/main/backend/database.py): `backend/database.py`

### Admin console

- [Admin dashboard](https://github.com/dinesh-2007/swasthai/blob/main/web/src/app/(admin)/overview/page.tsx): `web/src/app/(admin)/overview/page.tsx`
- [Admin API routes](https://github.com/dinesh-2007/swasthai/blob/main/web/src/app/api/patients/route.ts): `web/src/app/api/patients/route.ts`

### Other components

- **Citizen or worker**
- **Remote service**

## Connections

- Citizen or worker → App navigation: opens app
- App navigation → Screening experience: routes to (evidence: `SwasthAI/app/src/main/java/com/swasthai/app/navigation/HealthWorkerNavGraph.kt`)
- Screening experience → Screening orchestrator: requests screening
- Screening orchestrator → Image classifier: classifies image (evidence: `SwasthAI/app/src/main/java/com/swasthai/app/ai/engine/AIEngineManager.kt`)
- Screening orchestrator → Clinical reasoning: reasons symptoms (evidence: `SwasthAI/app/src/main/java/com/swasthai/app/ai/engine/AIEngineManager.kt`)
- Screening orchestrator → Screening results: returns diagnosis
- Image classifier → Scan model registry: uses scan types (evidence: `SwasthAI/app/src/main/java/com/swasthai/app/ai/engine/ImageClassifier.kt`)
- Clinical reasoning → Clinical knowledge: uses clinical rules (evidence: `SwasthAI/app/src/main/java/com/swasthai/app/ai/engine/ClinicalReasoningEngine.kt`)
- Clinical reasoning → Disease advice base: uses disease data (evidence: `SwasthAI/app/src/main/java/com/swasthai/app/ai/engine/ClinicalReasoningEngine.kt`)
- Clinical reasoning → Local RAG retrieval: retrieves context (evidence: `SwasthAI/app/src/main/java/com/swasthai/app/ai/engine/ClinicalReasoningEngine.kt`)
- Health chat → Local RAG retrieval: retrieves answers (evidence: `SwasthAI/app/src/main/java/com/swasthai/app/feature/citizen/aichat/AiChatEngine.kt`)
- Local RAG retrieval → RAG documents: reads documents (evidence: `SwasthAI/app/src/main/java/com/swasthai/app/ai/engine/LocalRagRetriever.kt`)
- Worker patient care → App repositories: uses patient data
- Follow-up and referral → App navigation: routes follow-up (evidence: `SwasthAI/app/src/main/java/com/swasthai/app/navigation/HealthWorkerNavGraph.kt`)
- Worker reports → App repositories: loads reports
- Offline data sync → App repositories: syncs records
- App repositories → Local health database: reads and writes
- App repositories → Mobile API client: uploads data
- Mobile API client → Remote service: sends requests
- Mobile API client → User preferences: gets session token (evidence: `SwasthAI/app/src/main/java/com/swasthai/app/data/remote/api/SwasthAIApiService.kt`)
- Backend endpoints → Backend database: uses database session (evidence: `backend/main.py`)
- Remote service → Backend endpoints: serves API requests
- Admin dashboard → Admin API routes: loads admin data
- Admin API routes → Backend endpoints: requests records
