# cou-ai-hackathon26/team_3zeros architecture

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

- Interactive diagram: https://gitdiagram.com/cou-ai-hackathon26/team_3zeros
- Repository: https://github.com/cou-ai-hackathon26/team_3zeros

## Overview

Medi Waypoint is a Bangla/English triage and closed-loop referral service for patients, CHWs, clinicians, and receiving facilities. The main path runs from voice or text symptom intake through deterministic emergency checks and AI-supported triage, then into a clinician report, consent, referral, receiving-facility progress, and returned outcome. Offline encrypted actions support referral work through connectivity loss. The graph preserves documented knowledge-base, access, scheduling, and interoperability capabilities. Evidence is limited to the README, source index references, and shown excerpts; unverified links are omitted.

Main entry points: [`backend/apps/referrals/services.py`](https://github.com/cou-ai-hackathon26/team_3zeros/blob/master/backend/apps/referrals/services.py) (Referral lifecycle), [`frontend/src/api/client.ts`](https://github.com/cou-ai-hackathon26/team_3zeros/blob/master/frontend/src/api/client.ts) (API client), [`backend/apps/triage/services.py`](https://github.com/cou-ai-hackathon26/team_3zeros/blob/master/backend/apps/triage/services.py) (Triage sessions), [`backend/apps/knowledge`](https://github.com/cou-ai-hackathon26/team_3zeros/tree/master/backend/apps/knowledge) (Knowledge search and ingestion)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access and experience"]
  node_web["Role-based web app"]
  node_voice["Voice and text client<br/>[controller.ts]"]
  node_api["API client<br/>[client.ts]"]
  node_offline["Encrypted offline queue"]
  node_accounts["Accounts and access"]
end

subgraph group_triage["Triage and knowledge"]
  node_triage_service["Triage sessions<br/>[services.py]"]
  node_redflags["Red-flag rules<br/>[engine.py]"]
  node_ai["AI triage and dialogue<br/>[dialogue.py]"]
  node_knowledge[("Knowledge search and ingestion")]
  node_report["Clinical report analysis<br/>[report_analysis.py]"]
end

subgraph group_care["Care coordination"]
  node_consent["Patient consent<br/>[services.py]"]
  node_referrals["Referral lifecycle<br/>[services.py]"]
  node_facility_intake["Emergency intake<br/>[services.py]"]
  node_scheduling["Appointments"]
  node_records[("Patient records<br/>[models.py]")]
end

subgraph group_platform["Workflow and integrations"]
  node_workflow["State and outbox engine<br/>[engine.py]"]
  node_audit[("Audit trail<br/>[services.py]")]
  node_notifications["Notifications<br/>[services.py]"]
  node_fhir["FHIR synchronization<br/>[sync.py]"]
end

node_users(("Patients and care teams"))
node_voice_provider["Vapi voice service"]
node_llm["Cerebras and Gemini"]
node_database[("Postgres and pgvector")]

node_users -->|"use"| node_web
node_web -->|"request data"| node_api
node_api -->|"submit turns"| node_triage_service
node_voice -->|"send session turns"| node_api
node_voice -.->|"place calls"| node_voice_provider
node_triage_service -->|"check emergencies"| node_redflags
node_triage_service -->|"request next reply"| node_ai
node_ai -.->|"generate dialogue"| node_llm
node_triage_service -->|"generate report"| node_report
node_report -->|"retrieve context"| node_knowledge
node_knowledge -->|"embed content"| node_llm
node_users -->|"queue offline actions"| node_offline
node_offline -.->|"sync actions"| node_api
node_api -.->|"authenticate requests"| node_accounts
node_users -->|"grant or refuse"| node_consent
node_consent -->|"advance referral"| node_referrals
node_referrals -->|"execute transitions"| node_workflow
node_referrals -->|"reconcile intake"| node_facility_intake
node_referrals -->|"sync referrals"| node_fhir
node_referrals -->|"use triage report"| node_report
node_workflow -->|"record transition"| node_audit
node_workflow -.->|"write history and outbox"| node_database
node_knowledge -->|"store searchable chunks"| node_database
node_referrals -->|"coordinate appointments"| node_scheduling
node_referrals -->|"associate encounters"| node_records
node_notifications -->|"read notification data"| node_database
node_users -.->|"receive updates"| node_notifications

click node_web "https://github.com/cou-ai-hackathon26/team_3zeros/tree/master/frontend/src/app"
click node_voice "https://github.com/cou-ai-hackathon26/team_3zeros/blob/master/frontend/src/voice/controller.ts"
click node_api "https://github.com/cou-ai-hackathon26/team_3zeros/blob/master/frontend/src/api/client.ts"
click node_offline "https://github.com/cou-ai-hackathon26/team_3zeros/tree/master/frontend/src/offline"
click node_accounts "https://github.com/cou-ai-hackathon26/team_3zeros/tree/master/backend/apps/accounts"
click node_triage_service "https://github.com/cou-ai-hackathon26/team_3zeros/blob/master/backend/apps/triage/services.py"
click node_redflags "https://github.com/cou-ai-hackathon26/team_3zeros/blob/master/backend/apps/triage/rules/engine.py"
click node_ai "https://github.com/cou-ai-hackathon26/team_3zeros/blob/master/backend/apps/triage/dialogue.py"
click node_knowledge "https://github.com/cou-ai-hackathon26/team_3zeros/tree/master/backend/apps/knowledge"
click node_report "https://github.com/cou-ai-hackathon26/team_3zeros/blob/master/backend/apps/ai/report_analysis.py"
click node_consent "https://github.com/cou-ai-hackathon26/team_3zeros/blob/master/backend/apps/consent/services.py"
click node_referrals "https://github.com/cou-ai-hackathon26/team_3zeros/blob/master/backend/apps/referrals/services.py"
click node_facility_intake "https://github.com/cou-ai-hackathon26/team_3zeros/blob/master/backend/apps/emergency_dept/services.py"
click node_scheduling "https://github.com/cou-ai-hackathon26/team_3zeros/tree/master/backend/apps/scheduling"
click node_records "https://github.com/cou-ai-hackathon26/team_3zeros/blob/master/backend/apps/records/models.py"
click node_workflow "https://github.com/cou-ai-hackathon26/team_3zeros/blob/master/backend/apps/workflow/engine.py"
click node_audit "https://github.com/cou-ai-hackathon26/team_3zeros/blob/master/backend/apps/audit/services.py"
click node_notifications "https://github.com/cou-ai-hackathon26/team_3zeros/blob/master/backend/apps/notifications/services.py"
click node_fhir "https://github.com/cou-ai-hackathon26/team_3zeros/blob/master/backend/apps/fhir/sync.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,node_voice,node_api,node_offline,node_accounts toneBlue
class node_triage_service,node_redflags,node_ai,node_knowledge,node_report,node_database toneAmber
class node_consent,node_referrals,node_facility_intake,node_scheduling,node_records,node_voice_provider toneMint
class node_workflow,node_audit,node_notifications,node_fhir toneRose
class node_users,node_llm toneIndigo
```

## Components

### Access and experience

- [Role-based web app](https://github.com/cou-ai-hackathon26/team_3zeros/tree/master/frontend/src/app): `frontend/src/app`
- [Voice and text client](https://github.com/cou-ai-hackathon26/team_3zeros/blob/master/frontend/src/voice/controller.ts): `frontend/src/voice/controller.ts`
- [API client](https://github.com/cou-ai-hackathon26/team_3zeros/blob/master/frontend/src/api/client.ts): `frontend/src/api/client.ts`
- [Encrypted offline queue](https://github.com/cou-ai-hackathon26/team_3zeros/tree/master/frontend/src/offline): `frontend/src/offline`
- [Accounts and access](https://github.com/cou-ai-hackathon26/team_3zeros/tree/master/backend/apps/accounts): `backend/apps/accounts`

### Triage and knowledge

- [Triage sessions](https://github.com/cou-ai-hackathon26/team_3zeros/blob/master/backend/apps/triage/services.py): `backend/apps/triage/services.py`
- [Red-flag rules](https://github.com/cou-ai-hackathon26/team_3zeros/blob/master/backend/apps/triage/rules/engine.py): `backend/apps/triage/rules/engine.py`
- [AI triage and dialogue](https://github.com/cou-ai-hackathon26/team_3zeros/blob/master/backend/apps/triage/dialogue.py): `backend/apps/triage/dialogue.py`
- [Knowledge search and ingestion](https://github.com/cou-ai-hackathon26/team_3zeros/tree/master/backend/apps/knowledge): `backend/apps/knowledge`
- [Clinical report analysis](https://github.com/cou-ai-hackathon26/team_3zeros/blob/master/backend/apps/ai/report_analysis.py): `backend/apps/ai/report_analysis.py`

### Care coordination

- [Patient consent](https://github.com/cou-ai-hackathon26/team_3zeros/blob/master/backend/apps/consent/services.py): `backend/apps/consent/services.py`
- [Referral lifecycle](https://github.com/cou-ai-hackathon26/team_3zeros/blob/master/backend/apps/referrals/services.py): `backend/apps/referrals/services.py`
- [Emergency intake](https://github.com/cou-ai-hackathon26/team_3zeros/blob/master/backend/apps/emergency_dept/services.py): `backend/apps/emergency_dept/services.py`
- [Appointments](https://github.com/cou-ai-hackathon26/team_3zeros/tree/master/backend/apps/scheduling): `backend/apps/scheduling`
- [Patient records](https://github.com/cou-ai-hackathon26/team_3zeros/blob/master/backend/apps/records/models.py): `backend/apps/records/models.py`

### Workflow and integrations

- [State and outbox engine](https://github.com/cou-ai-hackathon26/team_3zeros/blob/master/backend/apps/workflow/engine.py): `backend/apps/workflow/engine.py`
- [Audit trail](https://github.com/cou-ai-hackathon26/team_3zeros/blob/master/backend/apps/audit/services.py): `backend/apps/audit/services.py`
- [Notifications](https://github.com/cou-ai-hackathon26/team_3zeros/blob/master/backend/apps/notifications/services.py): `backend/apps/notifications/services.py`
- [FHIR synchronization](https://github.com/cou-ai-hackathon26/team_3zeros/blob/master/backend/apps/fhir/sync.py): `backend/apps/fhir/sync.py`

### Other components

- **Patients and care teams**
- **Vapi voice service**
- **Cerebras and Gemini**
- **Postgres and pgvector**

## Connections

- Patients and care teams → Role-based web app: use (evidence: `README.md`)
- Role-based web app → API client: request data (evidence: `README.md`)
- API client → Triage sessions: submit turns (evidence: `README.md`)
- Voice and text client → API client: send session turns (evidence: `frontend/src/voice/controller.ts`)
- Voice and text client → Vapi voice service: place calls (evidence: `README.md`)
- Triage sessions → Red-flag rules: check emergencies (evidence: `backend/apps/triage/services.py`)
- Triage sessions → AI triage and dialogue: request next reply (evidence: `backend/apps/triage/services.py`)
- AI triage and dialogue → Cerebras and Gemini: generate dialogue (evidence: `README.md`)
- Triage sessions → Clinical report analysis: generate report (evidence: `backend/apps/triage/services.py`)
- Clinical report analysis → Knowledge search and ingestion: retrieve context (evidence: `backend/apps/ai/report_analysis.py`)
- Knowledge search and ingestion → Cerebras and Gemini: embed content (evidence: `backend/apps/knowledge/ingest.py`)
- Patients and care teams → Encrypted offline queue: queue offline actions (evidence: `README.md`)
- Encrypted offline queue → API client: sync actions (evidence: `README.md`)
- API client → Accounts and access: authenticate requests (evidence: `README.md`)
- Patients and care teams → Patient consent: grant or refuse (evidence: `README.md`)
- Patient consent → Referral lifecycle: advance referral (evidence: `backend/apps/consent/services.py`)
- Referral lifecycle → State and outbox engine: execute transitions (evidence: `backend/apps/referrals/services.py`)
- Referral lifecycle → Emergency intake: reconcile intake (evidence: `backend/apps/referrals/services.py`)
- Referral lifecycle → FHIR synchronization: sync referrals (evidence: `backend/apps/referrals/services.py`)
- Referral lifecycle → Clinical report analysis: use triage report (evidence: `backend/apps/referrals/services.py`)
- State and outbox engine → Audit trail: record transition (evidence: `backend/apps/workflow/engine.py`)
- State and outbox engine → Postgres and pgvector: write history and outbox (evidence: `README.md`)
- Knowledge search and ingestion → Postgres and pgvector: store searchable chunks (evidence: `backend/apps/knowledge/ingest.py`)
- Referral lifecycle → Appointments: coordinate appointments (evidence: `backend/apps/referrals/services.py`)
- Referral lifecycle → Patient records: associate encounters (evidence: `backend/apps/referrals/services.py`)
- Notifications → Postgres and pgvector: read notification data (evidence: `backend/apps/notifications/services.py`)
- Patients and care teams → Notifications: receive updates (evidence: `README.md`)
