# gaggs-daggs/cmc architecture

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

- Interactive diagram: https://gitdiagram.com/gaggs-daggs/cmc
- Repository: https://github.com/gaggs-daggs/cmc

## Overview

This repository is a multilingual health-assistance product: users provide symptoms by chat or voice, optionally supply vitals, and receive triage-oriented guidance. Its backend also supports prescription analysis and messaging channels, with web and mobile interfaces. The README documents voice, language, vitals, diagnosis, and offline capabilities; the source index and excerpts establish only some implementation links, so other relationships are left unconnected rather than inferred.

Main entry points: [`backend/app/services/ai_service_v2.py`](https://github.com/gaggs-daggs/cmc/blob/main/backend/app/services/ai_service_v2.py) (AI health assistant), [`backend/app/routes/prescription_routes.py`](https://github.com/gaggs-daggs/cmc/blob/main/backend/app/routes/prescription_routes.py) (Prescription routes), [`backend/app/main.py`](https://github.com/gaggs-daggs/cmc/blob/main/backend/app/main.py) (FastAPI application), [`frontend/web/src/App.jsx`](https://github.com/gaggs-daggs/cmc/blob/main/frontend/web/src/App.jsx) (Health web app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User experience"]
  node_webapp["Health web app<br/>[App.jsx]"]
  node_bodyselector["Body selector<br/>[BodySelector.jsx]"]
  node_iosapp["iOS app<br/>[ContentView.swift]"]
  node_prescriptionui["Prescription interface<br/>[App.jsx]"]
end

subgraph group_clinical["Health guidance"]
  node_symptomai["AI health assistant<br/>[ai_service_v2.py]"]
  node_diagnosis["Differential diagnosis"]
  node_medicaldata["Medical knowledge"]
  node_druginfo["Drug information"]
  node_speech["Speech services<br/>[stt_service.py]"]
  node_translation["Language processing<br/>[translator.py]"]
end

subgraph group_prescriptions["Prescription care"]
  node_prescriptionroutes["Prescription routes"]
  node_vision["Prescription vision"]
  node_analysis["Prescription analysis"]
  node_prescriptionstore[("Prescription store")]
  node_prescriptionqa["Prescription Q&amp;A<br/>[qa_routes.py]"]
end

subgraph group_platform["Sessions and channels"]
  node_api["FastAPI application<br/>[main.py]"]
  node_conversation["Conversation routes"]
  node_sessions["Session routes<br/>[session_routes.py]"]
  node_sessionstore[("Session persistence")]
  node_memorydb[("In-memory database<br/>[database.py]")]
  node_whatsapp["WhatsApp channel<br/>[whatsapp_routes.py]"]
end

subgraph group_integrations["Sensors and external services"]
  node_vitals["Vitals routes<br/>[vitals_routes.py]"]
  node_iot["Vitals simulator"]
  node_offline[("Offline storage<br/>[offlineStorage.js]")]
end

node_patient(("Patient"))

node_patient -->|"uses"| node_webapp
node_patient -.->|"uses"| node_iosapp
node_webapp -->|"renders"| node_bodyselector
node_webapp -->|"sends health requests"| node_api
node_api -->|"routes to"| node_conversation
node_api -->|"routes to"| node_sessions
node_conversation -->|"calls"| node_symptomai
node_conversation -->|"uses session routes"| node_sessions
node_sessions -->|"persists sessions"| node_sessionstore
node_api -->|"initializes"| node_memorydb
node_whatsapp -->|"processes messages"| node_symptomai
node_symptomai -->|"uses diagnosis"| node_diagnosis
node_symptomai -->|"reads knowledge"| node_medicaldata
node_symptomai -->|"queries drug data"| node_druginfo
node_symptomai -->|"uses translation"| node_translation
node_patient -->|"speaks symptoms"| node_speech
node_patient -->|"submits readings"| node_vitals
node_patient -->|"uses offline mode"| node_offline
node_patient -.->|"uses"| node_prescriptionui
node_prescriptionui -.->|"uploads prescription"| node_prescriptionroutes
node_prescriptionroutes -->|"analyzes images"| node_vision
node_prescriptionroutes -->|"requests analysis"| node_analysis
node_prescriptionroutes -->|"stores results"| node_prescriptionstore
node_prescriptionqa -->|"reads history"| node_prescriptionstore
node_prescriptionqa -->|"asks questions"| node_analysis

click node_webapp "https://github.com/gaggs-daggs/cmc/blob/main/frontend/web/src/App.jsx"
click node_bodyselector "https://github.com/gaggs-daggs/cmc/blob/main/frontend/web/src/components/BodySelector.jsx"
click node_iosapp "https://github.com/gaggs-daggs/cmc/blob/main/mobile/ios/Charaka/Charaka/ContentView.swift"
click node_api "https://github.com/gaggs-daggs/cmc/blob/main/backend/app/main.py"
click node_conversation "https://github.com/gaggs-daggs/cmc/blob/main/backend/app/routes/conversation_routes.py"
click node_sessions "https://github.com/gaggs-daggs/cmc/blob/main/backend/app/routes/session_routes.py"
click node_sessionstore "https://github.com/gaggs-daggs/cmc/blob/main/backend/app/services/database/postgres_session_service.py"
click node_memorydb "https://github.com/gaggs-daggs/cmc/blob/main/backend/app/utils/database.py"
click node_whatsapp "https://github.com/gaggs-daggs/cmc/blob/main/backend/app/routes/whatsapp_routes.py"
click node_symptomai "https://github.com/gaggs-daggs/cmc/blob/main/backend/app/services/ai_service_v2.py"
click node_diagnosis "https://github.com/gaggs-daggs/cmc/blob/main/backend/app/services/diagnosis_engine.py"
click node_medicaldata "https://github.com/gaggs-daggs/cmc/blob/main/backend/app/data/medical_database.py"
click node_druginfo "https://github.com/gaggs-daggs/cmc/blob/main/backend/app/services/medical_databases/drug_info_service.py"
click node_speech "https://github.com/gaggs-daggs/cmc/blob/main/backend/app/services/speech/stt_service.py"
click node_translation "https://github.com/gaggs-daggs/cmc/blob/main/backend/app/services/nlp/translator.py"
click node_vitals "https://github.com/gaggs-daggs/cmc/blob/main/backend/app/routes/vitals_routes.py"
click node_iot "https://github.com/gaggs-daggs/cmc/blob/main/iot/simulator/vitals_simulator.py"
click node_offline "https://github.com/gaggs-daggs/cmc/blob/main/frontend/web/src/utils/offlineStorage.js"
click node_prescriptionui "https://github.com/gaggs-daggs/cmc/blob/main/prescription-module/frontend/src/App.jsx"
click node_prescriptionroutes "https://github.com/gaggs-daggs/cmc/blob/main/backend/app/routes/prescription_routes.py"
click node_vision "https://github.com/gaggs-daggs/cmc/blob/main/backend/app/services/prescription_vision_service.py"
click node_analysis "https://github.com/gaggs-daggs/cmc/blob/main/prescription-module/backend/app/services/analysis_service.py"
click node_prescriptionstore "https://github.com/gaggs-daggs/cmc/blob/main/backend/app/services/prescription_store.py"
click node_prescriptionqa "https://github.com/gaggs-daggs/cmc/blob/main/prescription-module/backend/app/routes/qa_routes.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_webapp,node_bodyselector,node_iosapp,node_prescriptionui toneBlue
class node_symptomai,node_diagnosis,node_medicaldata,node_druginfo,node_speech,node_translation toneAmber
class node_prescriptionroutes,node_vision,node_analysis,node_prescriptionstore,node_prescriptionqa toneMint
class node_api,node_conversation,node_sessions,node_sessionstore,node_memorydb,node_whatsapp toneRose
class node_vitals,node_iot,node_offline,node_patient toneIndigo
```

## Components

### User experience

- [Health web app](https://github.com/gaggs-daggs/cmc/blob/main/frontend/web/src/App.jsx): `frontend/web/src/App.jsx`
- [Body selector](https://github.com/gaggs-daggs/cmc/blob/main/frontend/web/src/components/BodySelector.jsx): `frontend/web/src/components/BodySelector.jsx`
- [iOS app](https://github.com/gaggs-daggs/cmc/blob/main/mobile/ios/Charaka/Charaka/ContentView.swift): `mobile/ios/Charaka/Charaka/ContentView.swift`
- [Prescription interface](https://github.com/gaggs-daggs/cmc/blob/main/prescription-module/frontend/src/App.jsx): `prescription-module/frontend/src/App.jsx`

### Health guidance

- [AI health assistant](https://github.com/gaggs-daggs/cmc/blob/main/backend/app/services/ai_service_v2.py): `backend/app/services/ai_service_v2.py`
- [Differential diagnosis](https://github.com/gaggs-daggs/cmc/blob/main/backend/app/services/diagnosis_engine.py): `backend/app/services/diagnosis_engine.py`
- [Medical knowledge](https://github.com/gaggs-daggs/cmc/blob/main/backend/app/data/medical_database.py): `backend/app/data/medical_database.py`
- [Drug information](https://github.com/gaggs-daggs/cmc/blob/main/backend/app/services/medical_databases/drug_info_service.py): `backend/app/services/medical_databases/drug_info_service.py`
- [Speech services](https://github.com/gaggs-daggs/cmc/blob/main/backend/app/services/speech/stt_service.py): `backend/app/services/speech/stt_service.py`
- [Language processing](https://github.com/gaggs-daggs/cmc/blob/main/backend/app/services/nlp/translator.py): `backend/app/services/nlp/translator.py`

### Prescription care

- [Prescription routes](https://github.com/gaggs-daggs/cmc/blob/main/backend/app/routes/prescription_routes.py): `backend/app/routes/prescription_routes.py`
- [Prescription vision](https://github.com/gaggs-daggs/cmc/blob/main/backend/app/services/prescription_vision_service.py): `backend/app/services/prescription_vision_service.py`
- [Prescription analysis](https://github.com/gaggs-daggs/cmc/blob/main/prescription-module/backend/app/services/analysis_service.py): `prescription-module/backend/app/services/analysis_service.py`
- [Prescription store](https://github.com/gaggs-daggs/cmc/blob/main/backend/app/services/prescription_store.py): `backend/app/services/prescription_store.py`
- [Prescription Q&A](https://github.com/gaggs-daggs/cmc/blob/main/prescription-module/backend/app/routes/qa_routes.py): `prescription-module/backend/app/routes/qa_routes.py`

### Sessions and channels

- [FastAPI application](https://github.com/gaggs-daggs/cmc/blob/main/backend/app/main.py): `backend/app/main.py`
- [Conversation routes](https://github.com/gaggs-daggs/cmc/blob/main/backend/app/routes/conversation_routes.py): `backend/app/routes/conversation_routes.py`
- [Session routes](https://github.com/gaggs-daggs/cmc/blob/main/backend/app/routes/session_routes.py): `backend/app/routes/session_routes.py`
- [Session persistence](https://github.com/gaggs-daggs/cmc/blob/main/backend/app/services/database/postgres_session_service.py): `backend/app/services/database/postgres_session_service.py`
- [In-memory database](https://github.com/gaggs-daggs/cmc/blob/main/backend/app/utils/database.py): `backend/app/utils/database.py`
- [WhatsApp channel](https://github.com/gaggs-daggs/cmc/blob/main/backend/app/routes/whatsapp_routes.py): `backend/app/routes/whatsapp_routes.py`

### Sensors and external services

- [Vitals routes](https://github.com/gaggs-daggs/cmc/blob/main/backend/app/routes/vitals_routes.py): `backend/app/routes/vitals_routes.py`
- [Vitals simulator](https://github.com/gaggs-daggs/cmc/blob/main/iot/simulator/vitals_simulator.py): `iot/simulator/vitals_simulator.py`
- [Offline storage](https://github.com/gaggs-daggs/cmc/blob/main/frontend/web/src/utils/offlineStorage.js): `frontend/web/src/utils/offlineStorage.js`

### Other components

- **Patient**

## Connections

- Patient → Health web app: uses (evidence: `README.md`)
- Patient → iOS app: uses
- Health web app → Body selector: renders (evidence: `frontend/web/src/App.jsx`)
- Health web app → FastAPI application: sends health requests (evidence: `README.md`)
- FastAPI application → Conversation routes: routes to (evidence: `backend/app/main.py`)
- FastAPI application → Session routes: routes to (evidence: `backend/app/main.py`)
- Conversation routes → AI health assistant: calls (evidence: `backend/app/routes/conversation_routes.py`)
- Conversation routes → Session routes: uses session routes (evidence: `backend/app/routes/conversation_routes.py`)
- Session routes → Session persistence: persists sessions (evidence: `backend/app/routes/session_routes.py`)
- FastAPI application → In-memory database: initializes (evidence: `backend/app/main.py`)
- WhatsApp channel → AI health assistant: processes messages (evidence: `backend/app/routes/whatsapp_routes.py`)
- AI health assistant → Differential diagnosis: uses diagnosis (evidence: `backend/app/services/ai_service_v2.py`)
- AI health assistant → Medical knowledge: reads knowledge (evidence: `backend/app/services/ai_service_v2.py`)
- AI health assistant → Drug information: queries drug data (evidence: `backend/app/services/ai_service_v2.py`)
- AI health assistant → Language processing: uses translation (evidence: `backend/app/services/ai_service_v2.py`)
- Patient → Speech services: speaks symptoms (evidence: `README.md`)
- Patient → Vitals routes: submits readings (evidence: `README.md`)
- Patient → Offline storage: uses offline mode (evidence: `README.md`)
- Patient → Prescription interface: uses
- Prescription interface → Prescription routes: uploads prescription
- Prescription routes → Prescription vision: analyzes images (evidence: `backend/app/routes/prescription_routes.py`)
- Prescription routes → Prescription analysis: requests analysis (evidence: `backend/app/routes/prescription_routes.py`)
- Prescription routes → Prescription store: stores results (evidence: `backend/app/routes/prescription_routes.py`)
- Prescription Q&A → Prescription store: reads history (evidence: `prescription-module/backend/app/routes/qa_routes.py`)
- Prescription Q&A → Prescription analysis: asks questions (evidence: `prescription-module/backend/app/routes/qa_routes.py`)
