# twilliamsa7/hearth-watch architecture

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

- Interactive diagram: https://gitdiagram.com/twilliamsa7/hearth-watch
- Repository: https://github.com/twilliamsa7/hearth-watch

## Overview

Hearth is a resident-safety monitoring and care-response simulation platform. Camera or simulated observations enter the backend ingestion API, where the monitoring service tracks source health, detects incidents, and manages alerts and events for nurse and room interfaces. The edge runner performs local camera inference and submits observations; simulation and evaluation provide scenario playback and scoring against ground truth. The README documents these capabilities, while several implementation links below are based on source-index references rather than inspected excerpts.

Main entry points: [`backend/hearth/api/app.py`](https://github.com/twilliamsa7/hearth-watch/blob/main/backend/hearth/api/app.py) (Ingestion API), [`backend/hearth/monitor/service.py`](https://github.com/twilliamsa7/hearth-watch/blob/main/backend/hearth/monitor/service.py) (Monitor service), [`edge/run_edge.py`](https://github.com/twilliamsa7/hearth-watch/blob/main/edge/run_edge.py) (Edge runner), [`shared/python/hearth_schema/models.py`](https://github.com/twilliamsa7/hearth-watch/blob/main/shared/python/hearth_schema/models.py) (Shared contract)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_edge["Edge sensing"]
  node_edge_runner["Edge runner<br/>[run_edge.py]"]
  node_pose_capture["Pose capture<br/>[pose.py]"]
  node_edge_features["Pose features<br/>[features.py]"]
  node_edge_client["Backend client<br/>[client.py]"]
  node_fall_vision["Fall vision<br/>[fall_model.py]"]
end

subgraph group_monitor["Monitoring service"]
  node_contract["Shared contract<br/>[models.py]"]
  node_api["Ingestion API<br/>[app.py]"]
  node_monitor_service["Monitor service<br/>[service.py]"]
  node_fall_detector["Fall detector<br/>[detector.py]"]
  node_gesture_rules["Gesture rules<br/>[gestures.py]"]
  node_memory_state[("Live state<br/>[service.py]")]
end

subgraph group_simulation["Simulation"]
  node_scenario["Scenario model<br/>[scenario.py]"]
  node_sim_world["Simulation world<br/>[world.py]"]
  node_live_engine["Live engine<br/>[engine.py]"]
  node_sim_controller["Scenario playback<br/>[controller.py]"]
end

subgraph group_evaluation["Evaluation"]
  node_eval_study["Evaluation study<br/>[study.py]"]
  node_eval_batch["Batch evaluation<br/>[batch.py]"]
  node_eval_scoring["Scoring<br/>[scoring.py]"]
end

subgraph group_interfaces["Care interfaces"]
  node_nurse_ui["Nurse desk<br/>[nurse.js]"]
  node_room_ui["Room panel<br/>[room.js]"]
  node_room_view["3D room view<br/>[LiveView3D.tsx]"]
end

node_caregiver(("Care team"))
node_camera(("USB camera"))

node_camera -->|"captures frames"| node_pose_capture
node_edge_runner -->|"reads poses"| node_pose_capture
node_edge_runner -->|"computes features"| node_edge_features
node_edge_runner -->|"sends observations"| node_edge_client
node_edge_features -.->|"formats observations"| node_contract
node_edge_client -->|"posts batches"| node_api
node_fall_vision -.->|"submits predictions"| node_api
node_api -->|"validates messages"| node_contract
node_api -->|"ingests observations"| node_monitor_service
node_monitor_service -->|"checks falls"| node_fall_detector
node_monitor_service -->|"checks gestures"| node_gesture_rules
node_monitor_service -->|"updates state"| node_memory_state
node_api -->|"serves nurse page"| node_nurse_ui
node_api -->|"serves room page"| node_room_ui
node_caregiver -->|"reviews alerts"| node_nurse_ui
node_room_ui -->|"requests help"| node_api
node_scenario -.->|"defines scenarios"| node_sim_world
node_live_engine -->|"advances world"| node_sim_world
node_sim_controller -->|"loads scenario"| node_scenario
node_sim_controller -->|"injects observations"| node_api
node_eval_study -->|"runs batches"| node_eval_batch
node_eval_study -->|"scores results"| node_eval_scoring
node_eval_scoring -->|"reads records"| node_contract
node_room_view -.->|"uses monitoring APIs"| node_api

click node_edge_runner "https://github.com/twilliamsa7/hearth-watch/blob/main/edge/run_edge.py"
click node_pose_capture "https://github.com/twilliamsa7/hearth-watch/blob/main/edge/hearth_edge/pose.py"
click node_edge_features "https://github.com/twilliamsa7/hearth-watch/blob/main/edge/hearth_edge/features.py"
click node_edge_client "https://github.com/twilliamsa7/hearth-watch/blob/main/edge/hearth_edge/client.py"
click node_fall_vision "https://github.com/twilliamsa7/hearth-watch/blob/main/backend/hearth/perception/fall_model.py"
click node_contract "https://github.com/twilliamsa7/hearth-watch/blob/main/shared/python/hearth_schema/models.py"
click node_api "https://github.com/twilliamsa7/hearth-watch/blob/main/backend/hearth/api/app.py"
click node_monitor_service "https://github.com/twilliamsa7/hearth-watch/blob/main/backend/hearth/monitor/service.py"
click node_fall_detector "https://github.com/twilliamsa7/hearth-watch/blob/main/backend/hearth/monitor/detector.py"
click node_gesture_rules "https://github.com/twilliamsa7/hearth-watch/blob/main/backend/hearth/monitor/gestures.py"
click node_memory_state "https://github.com/twilliamsa7/hearth-watch/blob/main/backend/hearth/monitor/service.py"
click node_scenario "https://github.com/twilliamsa7/hearth-watch/blob/main/backend/hearth/sim/scenario.py"
click node_sim_world "https://github.com/twilliamsa7/hearth-watch/blob/main/backend/hearth/sim/world.py"
click node_live_engine "https://github.com/twilliamsa7/hearth-watch/blob/main/backend/hearth/sim/live/engine.py"
click node_sim_controller "https://github.com/twilliamsa7/hearth-watch/blob/main/backend/hearth/sim/controller.py"
click node_eval_study "https://github.com/twilliamsa7/hearth-watch/blob/main/backend/hearth/eval/study.py"
click node_eval_batch "https://github.com/twilliamsa7/hearth-watch/blob/main/backend/hearth/eval/batch.py"
click node_eval_scoring "https://github.com/twilliamsa7/hearth-watch/blob/main/backend/hearth/eval/scoring.py"
click node_nurse_ui "https://github.com/twilliamsa7/hearth-watch/blob/main/backend/hearth/api/static/nurse.js"
click node_room_ui "https://github.com/twilliamsa7/hearth-watch/blob/main/backend/hearth/api/static/room.js"
click node_room_view "https://github.com/twilliamsa7/hearth-watch/blob/main/frontend/room-view/src/LiveView3D.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_edge_runner,node_pose_capture,node_edge_features,node_edge_client,node_fall_vision toneBlue
class node_contract,node_api,node_monitor_service,node_fall_detector,node_gesture_rules,node_memory_state toneAmber
class node_scenario,node_sim_world,node_live_engine,node_sim_controller toneMint
class node_eval_study,node_eval_batch,node_eval_scoring toneRose
class node_nurse_ui,node_room_ui,node_room_view,node_caregiver,node_camera toneIndigo
```

## Components

### Edge sensing

- [Edge runner](https://github.com/twilliamsa7/hearth-watch/blob/main/edge/run_edge.py): `edge/run_edge.py`
- [Pose capture](https://github.com/twilliamsa7/hearth-watch/blob/main/edge/hearth_edge/pose.py): `edge/hearth_edge/pose.py`
- [Pose features](https://github.com/twilliamsa7/hearth-watch/blob/main/edge/hearth_edge/features.py): `edge/hearth_edge/features.py`
- [Backend client](https://github.com/twilliamsa7/hearth-watch/blob/main/edge/hearth_edge/client.py): `edge/hearth_edge/client.py`
- [Fall vision](https://github.com/twilliamsa7/hearth-watch/blob/main/backend/hearth/perception/fall_model.py): `backend/hearth/perception/fall_model.py`

### Monitoring service

- [Shared contract](https://github.com/twilliamsa7/hearth-watch/blob/main/shared/python/hearth_schema/models.py): `shared/python/hearth_schema/models.py`
- [Ingestion API](https://github.com/twilliamsa7/hearth-watch/blob/main/backend/hearth/api/app.py): `backend/hearth/api/app.py`
- [Monitor service](https://github.com/twilliamsa7/hearth-watch/blob/main/backend/hearth/monitor/service.py): `backend/hearth/monitor/service.py`
- [Fall detector](https://github.com/twilliamsa7/hearth-watch/blob/main/backend/hearth/monitor/detector.py): `backend/hearth/monitor/detector.py`
- [Gesture rules](https://github.com/twilliamsa7/hearth-watch/blob/main/backend/hearth/monitor/gestures.py): `backend/hearth/monitor/gestures.py`
- [Live state](https://github.com/twilliamsa7/hearth-watch/blob/main/backend/hearth/monitor/service.py): `backend/hearth/monitor/service.py`

### Simulation

- [Scenario model](https://github.com/twilliamsa7/hearth-watch/blob/main/backend/hearth/sim/scenario.py): `backend/hearth/sim/scenario.py`
- [Simulation world](https://github.com/twilliamsa7/hearth-watch/blob/main/backend/hearth/sim/world.py): `backend/hearth/sim/world.py`
- [Live engine](https://github.com/twilliamsa7/hearth-watch/blob/main/backend/hearth/sim/live/engine.py): `backend/hearth/sim/live/engine.py`
- [Scenario playback](https://github.com/twilliamsa7/hearth-watch/blob/main/backend/hearth/sim/controller.py): `backend/hearth/sim/controller.py`

### Evaluation

- [Evaluation study](https://github.com/twilliamsa7/hearth-watch/blob/main/backend/hearth/eval/study.py): `backend/hearth/eval/study.py`
- [Batch evaluation](https://github.com/twilliamsa7/hearth-watch/blob/main/backend/hearth/eval/batch.py): `backend/hearth/eval/batch.py`
- [Scoring](https://github.com/twilliamsa7/hearth-watch/blob/main/backend/hearth/eval/scoring.py): `backend/hearth/eval/scoring.py`

### Care interfaces

- [Nurse desk](https://github.com/twilliamsa7/hearth-watch/blob/main/backend/hearth/api/static/nurse.js): `backend/hearth/api/static/nurse.js`
- [Room panel](https://github.com/twilliamsa7/hearth-watch/blob/main/backend/hearth/api/static/room.js): `backend/hearth/api/static/room.js`
- [3D room view](https://github.com/twilliamsa7/hearth-watch/blob/main/frontend/room-view/src/LiveView3D.tsx): `frontend/room-view/src/LiveView3D.tsx`

### Other components

- **Care team**
- **USB camera**

## Connections

- USB camera → Pose capture: captures frames (evidence: `edge/hearth_edge/pose.py`)
- Edge runner → Pose capture: reads poses (evidence: `edge/run_edge.py`)
- Edge runner → Pose features: computes features (evidence: `edge/run_edge.py`)
- Edge runner → Backend client: sends observations (evidence: `edge/run_edge.py`)
- Pose features → Shared contract: formats observations
- Backend client → Ingestion API: posts batches (evidence: `edge/hearth_edge/client.py`)
- Fall vision → Ingestion API: submits predictions
- Ingestion API → Shared contract: validates messages (evidence: `backend/hearth/api/app.py`)
- Ingestion API → Monitor service: ingests observations (evidence: `backend/hearth/api/app.py`)
- Monitor service → Fall detector: checks falls (evidence: `backend/hearth/monitor/service.py`)
- Monitor service → Gesture rules: checks gestures (evidence: `backend/hearth/monitor/service.py`)
- Monitor service → Live state: updates state (evidence: `backend/hearth/monitor/service.py`)
- Ingestion API → Nurse desk: serves nurse page
- Ingestion API → Room panel: serves room page
- Care team → Nurse desk: reviews alerts
- Room panel → Ingestion API: requests help
- Scenario model → Simulation world: defines scenarios (evidence: `backend/hearth/sim/world.py`)
- Live engine → Simulation world: advances world (evidence: `backend/hearth/sim/live/engine.py`)
- Scenario playback → Scenario model: loads scenario (evidence: `backend/hearth/sim/controller.py`)
- Scenario playback → Ingestion API: injects observations (evidence: `backend/hearth/sim/controller.py`)
- Evaluation study → Batch evaluation: runs batches (evidence: `backend/hearth/eval/study.py`)
- Evaluation study → Scoring: scores results (evidence: `backend/hearth/eval/study.py`)
- Scoring → Shared contract: reads records (evidence: `backend/hearth/eval/scoring.py`)
- 3D room view → Ingestion API: uses monitoring APIs
