# mohammedanasuddinzaid/carespeak-with-database-checks architecture

> Architecture diagram of the GitHub repository mohammedanasuddinzaid/carespeak-with-database-checks, 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/mohammedanasuddinzaid/carespeak-with-database-checks
- Repository: https://github.com/mohammedanasuddinzaid/carespeak-with-database-checks

## Overview

CareSpeak turns patient hand/eye movements into spoken, logged requests that reach a clinician console, where staff can respond and manage escalation. The map also preserves ward monitoring, pairing, wearable vitals/SOS, history/reporting, and offline delivery. Edges are limited to README-described behavior and relationships visible in indexed excerpts; unsampled feature internals are represented by their exact route or page paths, with uncertain wiring omitted.

Main entry points: [`src/app/api/sync/route.ts`](https://github.com/mohammedanasuddinzaid/carespeak-with-database-checks/blob/main/src/app/api/sync/route.ts) (Event sync API), [`src/app/hand-mode/page.tsx`](https://github.com/mohammedanasuddinzaid/carespeak-with-database-checks/blob/main/src/app/hand-mode/page.tsx) (Patient console), [`src/app/nurse-view/page.tsx`](https://github.com/mohammedanasuddinzaid/carespeak-with-database-checks/blob/main/src/app/nurse-view/page.tsx) (Nurse console), [`src/app/api/ingest/route.ts`](https://github.com/mohammedanasuddinzaid/carespeak-with-database-checks/blob/main/src/app/api/ingest/route.ts) (Vitals ingest)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_patient["Patient communication"]
  node_hand["Hand gestures<br/>[useHandGesture.ts]"]
  node_eye["Eye gestures<br/>[useEyeGesture.ts]"]
  node_classifiers["Gesture classifiers<br/>[handClassifier.ts]"]
  node_eyeclassifier["Eye classifier<br/>[eyeClassifier.ts]"]
  node_speech["Spoken phrases<br/>[tts.ts]"]
  node_outbox["Offline outbox<br/>[outbox.ts]"]
  node_patientconsole["Patient console<br/>[page.tsx]"]
  node_cctv["Remote camera<br/>[useCctvFeed.ts]"]
end

subgraph group_clinical["Clinical response"]
  node_escalation["Risk and escalation<br/>[escalation.ts]"]
  node_nurse["Nurse console<br/>[page.tsx]"]
  node_ward["Ward overview<br/>[page.tsx]"]
  node_report["Shift report<br/>[page.tsx]"]
  node_pairing["Bed pairing<br/>[route.ts]"]
  node_history["Patient history<br/>[page.tsx]"]
end

subgraph group_server["API and services"]
  node_sync["Event sync API<br/>[route.ts]"]
  node_clinicaldata["Clinical records<br/>[clinical.ts]"]
  node_stream["Live event stream<br/>[route.ts]"]
  node_ingest["Vitals ingest<br/>[route.ts]"]
  node_vitals["Vitals validation<br/>[vitals.ts]"]
  node_publish["Event publisher<br/>[publish.ts]"]
  node_auth["Authentication<br/>[auth.ts]"]
end

subgraph group_state["Persistence and delivery"]
  node_realtime["Realtime bus<br/>[realtime.ts]"]
  node_store[("Session store<br/>[store.ts]")]
  node_database[("MySQL data<br/>[db.ts]")]
  node_audit[("Audit trail<br/>[audit.ts]")]
end

node_patient(("Patient"))
node_wearable(("ESP32 wearable"))

node_patient -->|"gestures"| node_hand
node_patient -->|"gestures"| node_eye
node_hand -->|"classifies"| node_classifiers
node_eye -->|"classifies"| node_eyeclassifier
node_hand -->|"speaks"| node_speech
node_eye -->|"speaks"| node_speech
node_patientconsole -.->|"uses"| node_hand
node_patientconsole -.->|"uses"| node_eye
node_patientconsole -.->|"queues offline"| node_outbox
node_patientconsole -->|"submits events"| node_sync
node_sync -->|"records gestures"| node_clinicaldata
node_sync -->|"publishes events"| node_publish
node_clinicaldata -->|"persists records"| node_database
node_nurse -->|"subscribes"| node_stream
node_stream -.->|"streams events"| node_realtime
node_publish -->|"publishes"| node_realtime
node_nurse -.->|"replies and acts"| node_sync
node_sync -.->|"evaluates alerts"| node_escalation
node_nurse -.->|"monitors patients"| node_ward
node_nurse -.->|"reviews report"| node_report
node_nurse -.->|"reviews history"| node_history
node_patientconsole -.->|"pairs by QR"| node_pairing
node_cctv -->|"classifies feed"| node_classifiers
node_wearable -->|"sends vitals/SOS"| node_ingest
node_ingest -->|"sanitizes readings"| node_vitals
node_ingest -->|"stores readings"| node_store
node_ingest -->|"publishes alerts"| node_publish
node_sync -->|"authorizes access"| node_auth
node_audit -->|"writes audit rows"| node_database
node_auth -->|"reads credentials"| node_database

click node_hand "https://github.com/mohammedanasuddinzaid/carespeak-with-database-checks/blob/main/src/hooks/useHandGesture.ts"
click node_eye "https://github.com/mohammedanasuddinzaid/carespeak-with-database-checks/blob/main/src/hooks/useEyeGesture.ts"
click node_classifiers "https://github.com/mohammedanasuddinzaid/carespeak-with-database-checks/blob/main/src/lib/handClassifier.ts"
click node_eyeclassifier "https://github.com/mohammedanasuddinzaid/carespeak-with-database-checks/blob/main/src/lib/eyeClassifier.ts"
click node_speech "https://github.com/mohammedanasuddinzaid/carespeak-with-database-checks/blob/main/src/lib/tts.ts"
click node_outbox "https://github.com/mohammedanasuddinzaid/carespeak-with-database-checks/blob/main/src/lib/outbox.ts"
click node_patientconsole "https://github.com/mohammedanasuddinzaid/carespeak-with-database-checks/blob/main/src/app/hand-mode/page.tsx"
click node_sync "https://github.com/mohammedanasuddinzaid/carespeak-with-database-checks/blob/main/src/app/api/sync/route.ts"
click node_clinicaldata "https://github.com/mohammedanasuddinzaid/carespeak-with-database-checks/blob/main/src/lib/server/clinical.ts"
click node_escalation "https://github.com/mohammedanasuddinzaid/carespeak-with-database-checks/blob/main/src/lib/escalation.ts"
click node_nurse "https://github.com/mohammedanasuddinzaid/carespeak-with-database-checks/blob/main/src/app/nurse-view/page.tsx"
click node_stream "https://github.com/mohammedanasuddinzaid/carespeak-with-database-checks/blob/main/src/app/api/stream/route.ts"
click node_ward "https://github.com/mohammedanasuddinzaid/carespeak-with-database-checks/blob/main/src/app/ward/page.tsx"
click node_report "https://github.com/mohammedanasuddinzaid/carespeak-with-database-checks/blob/main/src/app/report/page.tsx"
click node_pairing "https://github.com/mohammedanasuddinzaid/carespeak-with-database-checks/blob/main/src/app/api/pair/route.ts"
click node_cctv "https://github.com/mohammedanasuddinzaid/carespeak-with-database-checks/blob/main/src/hooks/useCctvFeed.ts"
click node_ingest "https://github.com/mohammedanasuddinzaid/carespeak-with-database-checks/blob/main/src/app/api/ingest/route.ts"
click node_vitals "https://github.com/mohammedanasuddinzaid/carespeak-with-database-checks/blob/main/src/lib/server/vitals.ts"
click node_realtime "https://github.com/mohammedanasuddinzaid/carespeak-with-database-checks/blob/main/src/lib/server/realtime.ts"
click node_publish "https://github.com/mohammedanasuddinzaid/carespeak-with-database-checks/blob/main/src/lib/server/publish.ts"
click node_store "https://github.com/mohammedanasuddinzaid/carespeak-with-database-checks/blob/main/src/lib/server/store.ts"
click node_database "https://github.com/mohammedanasuddinzaid/carespeak-with-database-checks/blob/main/src/lib/server/db.ts"
click node_audit "https://github.com/mohammedanasuddinzaid/carespeak-with-database-checks/blob/main/src/lib/server/audit.ts"
click node_auth "https://github.com/mohammedanasuddinzaid/carespeak-with-database-checks/blob/main/src/lib/server/auth.ts"
click node_history "https://github.com/mohammedanasuddinzaid/carespeak-with-database-checks/blob/main/src/app/logs/page.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_hand,node_eye,node_classifiers,node_eyeclassifier,node_speech,node_outbox,node_patientconsole,node_cctv toneBlue
class node_escalation,node_nurse,node_ward,node_report,node_pairing,node_history toneAmber
class node_sync,node_clinicaldata,node_stream,node_ingest,node_vitals,node_publish,node_auth toneMint
class node_realtime,node_store,node_database,node_audit toneRose
class node_patient,node_wearable toneIndigo
```

## Components

### Patient communication

- [Hand gestures](https://github.com/mohammedanasuddinzaid/carespeak-with-database-checks/blob/main/src/hooks/useHandGesture.ts): `src/hooks/useHandGesture.ts`
- [Eye gestures](https://github.com/mohammedanasuddinzaid/carespeak-with-database-checks/blob/main/src/hooks/useEyeGesture.ts): `src/hooks/useEyeGesture.ts`
- [Gesture classifiers](https://github.com/mohammedanasuddinzaid/carespeak-with-database-checks/blob/main/src/lib/handClassifier.ts): `src/lib/handClassifier.ts`
- [Eye classifier](https://github.com/mohammedanasuddinzaid/carespeak-with-database-checks/blob/main/src/lib/eyeClassifier.ts): `src/lib/eyeClassifier.ts`
- [Spoken phrases](https://github.com/mohammedanasuddinzaid/carespeak-with-database-checks/blob/main/src/lib/tts.ts): `src/lib/tts.ts`
- [Offline outbox](https://github.com/mohammedanasuddinzaid/carespeak-with-database-checks/blob/main/src/lib/outbox.ts): `src/lib/outbox.ts`
- [Patient console](https://github.com/mohammedanasuddinzaid/carespeak-with-database-checks/blob/main/src/app/hand-mode/page.tsx): `src/app/hand-mode/page.tsx`
- [Remote camera](https://github.com/mohammedanasuddinzaid/carespeak-with-database-checks/blob/main/src/hooks/useCctvFeed.ts): `src/hooks/useCctvFeed.ts`

### Clinical response

- [Risk and escalation](https://github.com/mohammedanasuddinzaid/carespeak-with-database-checks/blob/main/src/lib/escalation.ts): `src/lib/escalation.ts`
- [Nurse console](https://github.com/mohammedanasuddinzaid/carespeak-with-database-checks/blob/main/src/app/nurse-view/page.tsx): `src/app/nurse-view/page.tsx`
- [Ward overview](https://github.com/mohammedanasuddinzaid/carespeak-with-database-checks/blob/main/src/app/ward/page.tsx): `src/app/ward/page.tsx`
- [Shift report](https://github.com/mohammedanasuddinzaid/carespeak-with-database-checks/blob/main/src/app/report/page.tsx): `src/app/report/page.tsx`
- [Bed pairing](https://github.com/mohammedanasuddinzaid/carespeak-with-database-checks/blob/main/src/app/api/pair/route.ts): `src/app/api/pair/route.ts`
- [Patient history](https://github.com/mohammedanasuddinzaid/carespeak-with-database-checks/blob/main/src/app/logs/page.tsx): `src/app/logs/page.tsx`

### API and services

- [Event sync API](https://github.com/mohammedanasuddinzaid/carespeak-with-database-checks/blob/main/src/app/api/sync/route.ts): `src/app/api/sync/route.ts`
- [Clinical records](https://github.com/mohammedanasuddinzaid/carespeak-with-database-checks/blob/main/src/lib/server/clinical.ts): `src/lib/server/clinical.ts`
- [Live event stream](https://github.com/mohammedanasuddinzaid/carespeak-with-database-checks/blob/main/src/app/api/stream/route.ts): `src/app/api/stream/route.ts`
- [Vitals ingest](https://github.com/mohammedanasuddinzaid/carespeak-with-database-checks/blob/main/src/app/api/ingest/route.ts): `src/app/api/ingest/route.ts`
- [Vitals validation](https://github.com/mohammedanasuddinzaid/carespeak-with-database-checks/blob/main/src/lib/server/vitals.ts): `src/lib/server/vitals.ts`
- [Event publisher](https://github.com/mohammedanasuddinzaid/carespeak-with-database-checks/blob/main/src/lib/server/publish.ts): `src/lib/server/publish.ts`
- [Authentication](https://github.com/mohammedanasuddinzaid/carespeak-with-database-checks/blob/main/src/lib/server/auth.ts): `src/lib/server/auth.ts`

### Persistence and delivery

- [Realtime bus](https://github.com/mohammedanasuddinzaid/carespeak-with-database-checks/blob/main/src/lib/server/realtime.ts): `src/lib/server/realtime.ts`
- [Session store](https://github.com/mohammedanasuddinzaid/carespeak-with-database-checks/blob/main/src/lib/server/store.ts): `src/lib/server/store.ts`
- [MySQL data](https://github.com/mohammedanasuddinzaid/carespeak-with-database-checks/blob/main/src/lib/server/db.ts): `src/lib/server/db.ts`
- [Audit trail](https://github.com/mohammedanasuddinzaid/carespeak-with-database-checks/blob/main/src/lib/server/audit.ts): `src/lib/server/audit.ts`

### Other components

- **Patient**
- **ESP32 wearable**

## Connections

- Patient → Hand gestures: gestures
- Patient → Eye gestures: gestures
- Hand gestures → Gesture classifiers: classifies (evidence: `src/hooks/useHandGesture.ts`)
- Eye gestures → Eye classifier: classifies (evidence: `src/hooks/useEyeGesture.ts`)
- Hand gestures → Spoken phrases: speaks (evidence: `src/hooks/useHandGesture.ts`)
- Eye gestures → Spoken phrases: speaks (evidence: `src/hooks/useEyeGesture.ts`)
- Patient console → Hand gestures: uses
- Patient console → Eye gestures: uses
- Patient console → Offline outbox: queues offline
- Patient console → Event sync API: submits events
- Event sync API → Clinical records: records gestures (evidence: `src/app/api/sync/route.ts`)
- Event sync API → Event publisher: publishes events (evidence: `src/app/api/sync/route.ts`)
- Clinical records → MySQL data: persists records (evidence: `src/lib/server/clinical.ts`)
- Nurse console → Live event stream: subscribes
- Live event stream → Realtime bus: streams events (evidence: `src/app/api/stream/route.ts`)
- Event publisher → Realtime bus: publishes (evidence: `src/lib/server/publish.ts`)
- Nurse console → Event sync API: replies and acts
- Event sync API → Risk and escalation: evaluates alerts
- Nurse console → Ward overview: monitors patients
- Nurse console → Shift report: reviews report
- Nurse console → Patient history: reviews history
- Patient console → Bed pairing: pairs by QR
- Remote camera → Gesture classifiers: classifies feed (evidence: `src/hooks/useCctvFeed.ts`)
- ESP32 wearable → Vitals ingest: sends vitals/SOS
- Vitals ingest → Vitals validation: sanitizes readings (evidence: `src/app/api/ingest/route.ts`)
- Vitals ingest → Session store: stores readings (evidence: `src/app/api/ingest/route.ts`)
- Vitals ingest → Event publisher: publishes alerts (evidence: `src/app/api/ingest/route.ts`)
- Event sync API → Authentication: authorizes access (evidence: `src/app/api/sync/route.ts`)
- Audit trail → MySQL data: writes audit rows (evidence: `src/lib/server/audit.ts`)
- Authentication → MySQL data: reads credentials (evidence: `src/lib/server/auth.ts`)
