# chocle254/civcare architecture

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

- Interactive diagram: https://gitdiagram.com/chocle254/civcare
- Repository: https://github.com/chocle254/civcare

## Overview

CivTech Care is an AI-assisted healthcare platform with patient and doctor experiences. Patients register, describe symptoms to AI triage, choose a hospital, and enter an in-person or remote-care flow; clinicians use a live queue, review patient context, and submit a verdict. The backend also supports medication scanning, records, prescriptions and adherence reminders, payments, messaging, analytics, and AI feedback. The graph follows documented routes and indexed module references; several feature implementations were not sampled, so uncertain internal links are omitted or marked unverified.

Main entry points: [`backend/app/routers/triage.py`](https://github.com/chocle254/civcare/blob/main/backend/app/routers/triage.py) (Triage and arrival), [`backend/app/agents/orchestrator.py`](https://github.com/chocle254/civcare/blob/main/backend/app/agents/orchestrator.py) (AI triage orchestration), [`frontend/src/App.jsx`](https://github.com/chocle254/civcare/blob/main/frontend/src/App.jsx) (Web app routes), [`frontend/src/api/client.js`](https://github.com/chocle254/civcare/blob/main/frontend/src/api/client.js) (Frontend API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User experiences"]
  node_web_app["Web app routes<br/>[App.jsx]"]
  node_patient_chat["Patient symptom chat<br/>[Chat.jsx]"]
  node_doctor_dashboard["Doctor queue dashboard<br/>[Dashboard.jsx]"]
  node_api_client["Frontend API client<br/>[client.js]"]
  node_triage_api["Triage API client<br/>[triage.js]"]
end

subgraph group_clinical["Clinical workflows"]
  node_auth["Patient and doctor auth<br/>[auth.py]"]
  node_triage_router["Triage and arrival<br/>[triage.py]"]
  node_ai_orchestrator["AI triage orchestration<br/>[orchestrator.py]"]
  node_triage_agent["Clinical triage agent<br/>[triage_agent.py]"]
  node_medscan_agent["Medication safety scan<br/>[medscan_agent.py]"]
  node_hospital_directory["Hospital directory<br/>[hospitals.py]"]
  node_doctor_queue["Doctor and queue APIs<br/>[doctors.py]"]
  node_consultation["Remote consultation<br/>[consultation.py]"]
end

subgraph group_care["Ongoing care"]
  node_records["Patient records<br/>[records.py]"]
  node_prescriptions["Prescriptions and reminders<br/>[reminders.py]"]
  node_payments["Payments<br/>[payment.py]"]
  node_messaging["SMS and notifications<br/>[africastalking.py]"]
  node_analytics["Care analytics<br/>[analytics.py]"]
  node_medication_care["Medication outcomes and support<br/>[carer.py]"]
end

subgraph group_platform["Backend platform"]
  node_ai_client["Groq model client<br/>[ai_client.py]"]
  node_queue_socket["Live queue updates<br/>[queue.py]"]
end

subgraph group_state["Data and learning"]
  node_database[("SQL database access<br/>[database.py]")]
  node_clinical_models["Patient and clinical records"]
  node_verdict_model["Doctor verdicts<br/>[verdict.py]"]
  node_ai_feedback["AI feedback learning<br/>[rlhf.py]"]
end

node_patient(("Patient"))
node_doctor(("Doctor"))

node_patient -->|"uses"| node_web_app
node_doctor -->|"uses"| node_web_app
node_web_app -->|"routes to"| node_patient_chat
node_web_app -->|"routes to"| node_doctor_dashboard
node_patient_chat -->|"requests triage"| node_triage_api
node_doctor_dashboard -->|"requests data"| node_api_client
node_triage_api -->|"uses client"| node_api_client
node_api_client -.->|"calls backend"| node_auth
node_api_client -.->|"calls backend"| node_triage_router
node_patient -->|"registers"| node_auth
node_triage_router -->|"runs triage"| node_ai_orchestrator
node_ai_orchestrator -->|"delegates triage"| node_triage_agent
node_ai_orchestrator -->|"runs scan"| node_medscan_agent
node_triage_agent -->|"requests inference"| node_ai_client
node_ai_orchestrator -->|"requests inference"| node_ai_client
node_triage_router -->|"uses hospitals"| node_hospital_directory
node_patient -->|"selects hospital"| node_hospital_directory
node_doctor -->|"reviews queue"| node_doctor_queue
node_doctor_dashboard -->|"receives updates"| node_queue_socket
node_triage_router -->|"broadcasts queue"| node_queue_socket
node_doctor -->|"consults remotely"| node_consultation
node_patient -.->|"views records"| node_records
node_patient -->|"tracks treatment"| node_prescriptions
node_prescriptions -->|"reviews outcomes"| node_medication_care
node_patient -.->|"pays"| node_payments
node_prescriptions -->|"sends reminders"| node_messaging
node_doctor -->|"submits verdict"| node_verdict_model
node_verdict_model -->|"feeds ratings"| node_ai_feedback
node_patient -.->|"views analytics"| node_analytics
node_triage_router -->|"reads and writes"| node_clinical_models
node_auth -->|"reads and writes"| node_clinical_models
node_clinical_models -->|"persists records"| node_database
node_ai_feedback -->|"requests inference"| node_ai_client

click node_web_app "https://github.com/chocle254/civcare/blob/main/frontend/src/App.jsx"
click node_patient_chat "https://github.com/chocle254/civcare/blob/main/frontend/src/pages/patient/Chat.jsx"
click node_doctor_dashboard "https://github.com/chocle254/civcare/blob/main/frontend/src/pages/doctor/Dashboard.jsx"
click node_api_client "https://github.com/chocle254/civcare/blob/main/frontend/src/api/client.js"
click node_triage_api "https://github.com/chocle254/civcare/blob/main/frontend/src/api/triage.js"
click node_auth "https://github.com/chocle254/civcare/blob/main/backend/app/routers/auth.py"
click node_triage_router "https://github.com/chocle254/civcare/blob/main/backend/app/routers/triage.py"
click node_ai_orchestrator "https://github.com/chocle254/civcare/blob/main/backend/app/agents/orchestrator.py"
click node_triage_agent "https://github.com/chocle254/civcare/blob/main/backend/app/agents/triage_agent.py"
click node_medscan_agent "https://github.com/chocle254/civcare/blob/main/backend/app/agents/medscan_agent.py"
click node_hospital_directory "https://github.com/chocle254/civcare/blob/main/backend/app/routers/hospitals.py"
click node_doctor_queue "https://github.com/chocle254/civcare/blob/main/backend/app/routers/doctors.py"
click node_consultation "https://github.com/chocle254/civcare/blob/main/backend/app/routers/consultation.py"
click node_records "https://github.com/chocle254/civcare/blob/main/backend/app/routers/records.py"
click node_prescriptions "https://github.com/chocle254/civcare/blob/main/backend/app/routers/reminders.py"
click node_payments "https://github.com/chocle254/civcare/blob/main/backend/app/routers/payment.py"
click node_messaging "https://github.com/chocle254/civcare/blob/main/backend/app/services/africastalking.py"
click node_analytics "https://github.com/chocle254/civcare/blob/main/backend/app/routers/analytics.py"
click node_database "https://github.com/chocle254/civcare/blob/main/backend/app/database.py"
click node_clinical_models "https://github.com/chocle254/civcare/tree/main/backend/app/models"
click node_verdict_model "https://github.com/chocle254/civcare/blob/main/backend/app/models/verdict.py"
click node_ai_feedback "https://github.com/chocle254/civcare/blob/main/backend/app/services/rlhf.py"
click node_ai_client "https://github.com/chocle254/civcare/blob/main/backend/app/services/ai_client.py"
click node_queue_socket "https://github.com/chocle254/civcare/blob/main/backend/app/websocket/queue.py"
click node_medication_care "https://github.com/chocle254/civcare/blob/main/backend/app/services/carer.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_web_app,node_patient_chat,node_doctor_dashboard,node_api_client,node_triage_api toneBlue
class node_auth,node_triage_router,node_ai_orchestrator,node_triage_agent,node_medscan_agent,node_hospital_directory,node_doctor_queue,node_consultation toneAmber
class node_records,node_prescriptions,node_payments,node_messaging,node_analytics,node_medication_care toneMint
class node_ai_client,node_queue_socket toneRose
class node_database,node_clinical_models,node_verdict_model,node_ai_feedback,node_patient,node_doctor toneIndigo
```

## Components

### User experiences

- [Web app routes](https://github.com/chocle254/civcare/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Patient symptom chat](https://github.com/chocle254/civcare/blob/main/frontend/src/pages/patient/Chat.jsx): `frontend/src/pages/patient/Chat.jsx`
- [Doctor queue dashboard](https://github.com/chocle254/civcare/blob/main/frontend/src/pages/doctor/Dashboard.jsx): `frontend/src/pages/doctor/Dashboard.jsx`
- [Frontend API client](https://github.com/chocle254/civcare/blob/main/frontend/src/api/client.js): `frontend/src/api/client.js`
- [Triage API client](https://github.com/chocle254/civcare/blob/main/frontend/src/api/triage.js): `frontend/src/api/triage.js`

### Clinical workflows

- [Patient and doctor auth](https://github.com/chocle254/civcare/blob/main/backend/app/routers/auth.py): `backend/app/routers/auth.py`
- [Triage and arrival](https://github.com/chocle254/civcare/blob/main/backend/app/routers/triage.py): `backend/app/routers/triage.py`
- [AI triage orchestration](https://github.com/chocle254/civcare/blob/main/backend/app/agents/orchestrator.py): `backend/app/agents/orchestrator.py`
- [Clinical triage agent](https://github.com/chocle254/civcare/blob/main/backend/app/agents/triage_agent.py): `backend/app/agents/triage_agent.py`
- [Medication safety scan](https://github.com/chocle254/civcare/blob/main/backend/app/agents/medscan_agent.py): `backend/app/agents/medscan_agent.py`
- [Hospital directory](https://github.com/chocle254/civcare/blob/main/backend/app/routers/hospitals.py): `backend/app/routers/hospitals.py`
- [Doctor and queue APIs](https://github.com/chocle254/civcare/blob/main/backend/app/routers/doctors.py): `backend/app/routers/doctors.py`
- [Remote consultation](https://github.com/chocle254/civcare/blob/main/backend/app/routers/consultation.py): `backend/app/routers/consultation.py`

### Ongoing care

- [Patient records](https://github.com/chocle254/civcare/blob/main/backend/app/routers/records.py): `backend/app/routers/records.py`
- [Prescriptions and reminders](https://github.com/chocle254/civcare/blob/main/backend/app/routers/reminders.py): `backend/app/routers/reminders.py`
- [Payments](https://github.com/chocle254/civcare/blob/main/backend/app/routers/payment.py): `backend/app/routers/payment.py`
- [SMS and notifications](https://github.com/chocle254/civcare/blob/main/backend/app/services/africastalking.py): `backend/app/services/africastalking.py`
- [Care analytics](https://github.com/chocle254/civcare/blob/main/backend/app/routers/analytics.py): `backend/app/routers/analytics.py`
- [Medication outcomes and support](https://github.com/chocle254/civcare/blob/main/backend/app/services/carer.py): `backend/app/services/carer.py`

### Backend platform

- [Groq model client](https://github.com/chocle254/civcare/blob/main/backend/app/services/ai_client.py): `backend/app/services/ai_client.py`
- [Live queue updates](https://github.com/chocle254/civcare/blob/main/backend/app/websocket/queue.py): `backend/app/websocket/queue.py`

### Data and learning

- [SQL database access](https://github.com/chocle254/civcare/blob/main/backend/app/database.py): `backend/app/database.py`
- [Patient and clinical records](https://github.com/chocle254/civcare/tree/main/backend/app/models): `backend/app/models`
- [Doctor verdicts](https://github.com/chocle254/civcare/blob/main/backend/app/models/verdict.py): `backend/app/models/verdict.py`
- [AI feedback learning](https://github.com/chocle254/civcare/blob/main/backend/app/services/rlhf.py): `backend/app/services/rlhf.py`

### Other components

- **Patient**
- **Doctor**

## Connections

- Patient → Web app routes: uses
- Doctor → Web app routes: uses
- Web app routes → Patient symptom chat: routes to (evidence: `frontend/src/App.jsx`)
- Web app routes → Doctor queue dashboard: routes to (evidence: `frontend/src/App.jsx`)
- Patient symptom chat → Triage API client: requests triage (evidence: `frontend/src/pages/patient/Chat.jsx`)
- Doctor queue dashboard → Frontend API client: requests data (evidence: `frontend/src/pages/doctor/Dashboard.jsx`)
- Triage API client → Frontend API client: uses client
- Frontend API client → Patient and doctor auth: calls backend
- Frontend API client → Triage and arrival: calls backend
- Patient → Patient and doctor auth: registers
- Triage and arrival → AI triage orchestration: runs triage (evidence: `backend/app/routers/triage.py`)
- AI triage orchestration → Clinical triage agent: delegates triage (evidence: `backend/app/agents/orchestrator.py`)
- AI triage orchestration → Medication safety scan: runs scan (evidence: `backend/app/agents/orchestrator.py`)
- Clinical triage agent → Groq model client: requests inference (evidence: `backend/app/agents/triage_agent.py`)
- AI triage orchestration → Groq model client: requests inference (evidence: `backend/app/agents/orchestrator.py`)
- Triage and arrival → Hospital directory: uses hospitals (evidence: `backend/app/routers/triage.py`)
- Patient → Hospital directory: selects hospital
- Doctor → Doctor and queue APIs: reviews queue
- Doctor queue dashboard → Live queue updates: receives updates (evidence: `frontend/src/pages/doctor/Dashboard.jsx`)
- Triage and arrival → Live queue updates: broadcasts queue (evidence: `backend/main.py`)
- Doctor → Remote consultation: consults remotely
- Patient → Patient records: views records
- Patient → Prescriptions and reminders: tracks treatment (evidence: `backend/app/routers/reminders.py`)
- Prescriptions and reminders → Medication outcomes and support: reviews outcomes (evidence: `backend/app/routers/reminders.py`)
- Patient → Payments: pays
- Prescriptions and reminders → SMS and notifications: sends reminders (evidence: `backend/app/routers/reminders.py`)
- Doctor → Doctor verdicts: submits verdict (evidence: `backend/app/models/verdict.py`)
- Doctor verdicts → AI feedback learning: feeds ratings (evidence: `backend/app/models/verdict.py`)
- Patient → Care analytics: views analytics
- Triage and arrival → Patient and clinical records: reads and writes (evidence: `backend/app/routers/triage.py`)
- Patient and doctor auth → Patient and clinical records: reads and writes (evidence: `backend/app/routers/auth.py`)
- Patient and clinical records → SQL database access: persists records (evidence: `backend/app/models/session.py`)
- AI feedback learning → Groq model client: requests inference (evidence: `backend/app/services/rlhf.py`)
