# mnyashas/distohelp architecture

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

- Interactive diagram: https://gitdiagram.com/mnyashas/distohelp
- Repository: https://github.com/mnyashas/distohelp

## Overview

DIstoHelp is a post-discharge deterioration-monitoring product: clinicians review patients and readings, while device, manual, FHIR, and replay inputs are processed into personalized scores and explainable alerts. The backend API is the runtime entry point for ingestion and management; the frontend presents dashboard, patient, live-monitoring, and watch views. Documented scenario evaluation, BIDMC replay, escalation, and HAPI FHIR storage are retained. Several backend modules were not sampled, so their internal call links are shown only where the README or excerpts support them.

Main entry points: [`backend/app/api.py`](https://github.com/mnyashas/distohelp/blob/main/backend/app/api.py) (REST API), [`frontend/src/App.jsx`](https://github.com/mnyashas/distohelp/blob/main/frontend/src/App.jsx) (Web App Routes), [`backend/app/pipeline.py`](https://github.com/mnyashas/distohelp/blob/main/backend/app/pipeline.py) (Observation Pipeline), [`frontend/src/services/api.js`](https://github.com/mnyashas/distohelp/blob/main/frontend/src/services/api.js) (API Client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Clinician and Patient UI"]
  node_app["Web App Routes<br/>[App.jsx]"]
  node_dashboard["Dashboard<br/>[Dashboard.jsx]"]
  node_patient_profile["Patient Profile<br/>[PatientProfile.jsx]"]
  node_vitals_ui["Vitals and Sensors<br/>[VitalsPanel.jsx]"]
  node_sensor_panel["Sensor Panel<br/>[SensorPanel.jsx]"]
  node_live["Live Monitoring<br/>[Live.jsx]"]
  node_watch["Watch Companion<br/>[Watch.jsx]"]
  node_auth["Authentication State<br/>[AuthContext.jsx]"]
  node_api_client["API Client<br/>[api.js]"]
end

subgraph group_service["API and Ingestion"]
  node_backend["FastAPI Startup<br/>[main.py]"]
  node_compat["Frontend Compatibility API<br/>[compat.py]"]
  node_api["REST API<br/>[api.py]"]
  node_pipeline["Observation Pipeline<br/>[pipeline.py]"]
  node_ws["WebSocket Updates<br/>[ws.py]"]
end

subgraph group_clinical["Scoring and Alerts"]
  node_artifacts["Artifact Suppression<br/>[artifacts.py]"]
  node_scoring["Personalized Scoring<br/>[scoring.py]"]
  node_alerts["Explainable Alerts<br/>[alerts.py]"]
  node_escalation["Clinical Escalation<br/>[escalation.py]"]
end

subgraph group_state["Persistence and FHIR"]
  node_db[("SQLite Read Model<br/>[db.py]")]
  node_fhir["FHIR Client and Worker<br/>[fhir_client.py]"]
end

subgraph group_replay["Simulation and Replay"]
  node_simulator["Live Simulator<br/>[simulator.py]"]
  node_sim_engine["Scenario Engine<br/>[sim_engine.py]"]
  node_scenarios["Scenario Evaluation<br/>[scenarios.py]"]
  node_bidmc["BIDMC Replay<br/>[bidmc.py]"]
end

node_clinician(("Clinician"))
node_wearable(("Wearable or Sensor"))
node_hapi[("HAPI FHIR Server")]

node_clinician -->|"uses"| node_app
node_app -->|"routes to"| node_dashboard
node_app -->|"routes to"| node_patient_profile
node_app -->|"routes to"| node_vitals_ui
node_app -->|"routes to"| node_live
node_app -->|"routes to"| node_watch
node_app -->|"checks session"| node_auth
node_auth -->|"loads identity"| node_api_client
node_dashboard -->|"fetches data"| node_api_client
node_patient_profile -->|"renders"| node_vitals_ui
node_vitals_ui -->|"renders"| node_sensor_panel
node_sensor_panel -->|"submits readings"| node_api_client
node_vitals_ui -->|"saves readings"| node_api_client
node_api_client -->|"calls frontend API"| node_compat
node_api_client -->|"calls contract API"| node_api
node_backend -->|"registers router"| node_api
node_backend -->|"registers router"| node_compat
node_backend -->|"registers router"| node_ws
node_api -->|"parses observations"| node_pipeline
node_pipeline -->|"filters readings"| node_artifacts
node_pipeline -->|"computes score"| node_scoring
node_pipeline -->|"creates alerts"| node_alerts
node_pipeline -->|"stores readings"| node_db
node_pipeline -->|"queues observations"| node_fhir
node_fhir -->|"flushes bundles"| node_hapi
node_api -->|"lists alerts"| node_alerts
node_api -->|"handles escalation"| node_escalation
node_escalation -->|"creates FHIR resources"| node_fhir
node_api -->|"controls streams"| node_simulator
node_simulator -.->|"generates ticks"| node_sim_engine
node_api -->|"evaluates scenarios"| node_scenarios
node_scenarios -->|"consumes simulation"| node_sim_engine
node_api -->|"starts replay"| node_bidmc
node_bidmc -->|"replays readings"| node_pipeline
node_live -.->|"controls monitoring"| node_api_client
node_watch -->|"streams vitals"| node_ws
node_api -->|"broadcasts updates"| node_ws

click node_app "https://github.com/mnyashas/distohelp/blob/main/frontend/src/App.jsx"
click node_dashboard "https://github.com/mnyashas/distohelp/blob/main/frontend/src/dashboard/Dashboard.jsx"
click node_patient_profile "https://github.com/mnyashas/distohelp/blob/main/frontend/src/patients/PatientProfile.jsx"
click node_vitals_ui "https://github.com/mnyashas/distohelp/blob/main/frontend/src/vitals/VitalsPanel.jsx"
click node_sensor_panel "https://github.com/mnyashas/distohelp/blob/main/frontend/src/sensors/SensorPanel.jsx"
click node_live "https://github.com/mnyashas/distohelp/blob/main/frontend/src/pages/Live.jsx"
click node_watch "https://github.com/mnyashas/distohelp/blob/main/frontend/src/pages/Watch.jsx"
click node_auth "https://github.com/mnyashas/distohelp/blob/main/frontend/src/services/AuthContext.jsx"
click node_api_client "https://github.com/mnyashas/distohelp/blob/main/frontend/src/services/api.js"
click node_backend "https://github.com/mnyashas/distohelp/blob/main/backend/app/main.py"
click node_compat "https://github.com/mnyashas/distohelp/blob/main/backend/app/compat.py"
click node_api "https://github.com/mnyashas/distohelp/blob/main/backend/app/api.py"
click node_pipeline "https://github.com/mnyashas/distohelp/blob/main/backend/app/pipeline.py"
click node_artifacts "https://github.com/mnyashas/distohelp/blob/main/backend/app/artifacts.py"
click node_scoring "https://github.com/mnyashas/distohelp/blob/main/backend/app/scoring.py"
click node_alerts "https://github.com/mnyashas/distohelp/blob/main/backend/app/alerts.py"
click node_escalation "https://github.com/mnyashas/distohelp/blob/main/backend/app/escalation.py"
click node_db "https://github.com/mnyashas/distohelp/blob/main/backend/app/db.py"
click node_fhir "https://github.com/mnyashas/distohelp/blob/main/backend/app/fhir_client.py"
click node_ws "https://github.com/mnyashas/distohelp/blob/main/backend/app/ws.py"
click node_simulator "https://github.com/mnyashas/distohelp/blob/main/backend/app/simulator.py"
click node_sim_engine "https://github.com/mnyashas/distohelp/blob/main/backend/app/sim_engine.py"
click node_scenarios "https://github.com/mnyashas/distohelp/blob/main/backend/app/scenarios.py"
click node_bidmc "https://github.com/mnyashas/distohelp/blob/main/backend/app/bidmc.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_app,node_dashboard,node_patient_profile,node_vitals_ui,node_sensor_panel,node_live,node_watch,node_auth,node_api_client toneBlue
class node_backend,node_compat,node_api,node_pipeline,node_ws,node_hapi toneAmber
class node_artifacts,node_scoring,node_alerts,node_escalation toneMint
class node_db,node_fhir toneRose
class node_simulator,node_sim_engine,node_scenarios,node_bidmc,node_clinician,node_wearable toneIndigo
```

## Components

### Clinician and Patient UI

- [Web App Routes](https://github.com/mnyashas/distohelp/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Dashboard](https://github.com/mnyashas/distohelp/blob/main/frontend/src/dashboard/Dashboard.jsx): `frontend/src/dashboard/Dashboard.jsx`
- [Patient Profile](https://github.com/mnyashas/distohelp/blob/main/frontend/src/patients/PatientProfile.jsx): `frontend/src/patients/PatientProfile.jsx`
- [Vitals and Sensors](https://github.com/mnyashas/distohelp/blob/main/frontend/src/vitals/VitalsPanel.jsx): `frontend/src/vitals/VitalsPanel.jsx`
- [Sensor Panel](https://github.com/mnyashas/distohelp/blob/main/frontend/src/sensors/SensorPanel.jsx): `frontend/src/sensors/SensorPanel.jsx`
- [Live Monitoring](https://github.com/mnyashas/distohelp/blob/main/frontend/src/pages/Live.jsx): `frontend/src/pages/Live.jsx`
- [Watch Companion](https://github.com/mnyashas/distohelp/blob/main/frontend/src/pages/Watch.jsx): `frontend/src/pages/Watch.jsx`
- [Authentication State](https://github.com/mnyashas/distohelp/blob/main/frontend/src/services/AuthContext.jsx): `frontend/src/services/AuthContext.jsx`
- [API Client](https://github.com/mnyashas/distohelp/blob/main/frontend/src/services/api.js): `frontend/src/services/api.js`

### API and Ingestion

- [FastAPI Startup](https://github.com/mnyashas/distohelp/blob/main/backend/app/main.py): `backend/app/main.py`
- [Frontend Compatibility API](https://github.com/mnyashas/distohelp/blob/main/backend/app/compat.py): `backend/app/compat.py`
- [REST API](https://github.com/mnyashas/distohelp/blob/main/backend/app/api.py): `backend/app/api.py`
- [Observation Pipeline](https://github.com/mnyashas/distohelp/blob/main/backend/app/pipeline.py): `backend/app/pipeline.py`
- [WebSocket Updates](https://github.com/mnyashas/distohelp/blob/main/backend/app/ws.py): `backend/app/ws.py`

### Scoring and Alerts

- [Artifact Suppression](https://github.com/mnyashas/distohelp/blob/main/backend/app/artifacts.py): `backend/app/artifacts.py`
- [Personalized Scoring](https://github.com/mnyashas/distohelp/blob/main/backend/app/scoring.py): `backend/app/scoring.py`
- [Explainable Alerts](https://github.com/mnyashas/distohelp/blob/main/backend/app/alerts.py): `backend/app/alerts.py`
- [Clinical Escalation](https://github.com/mnyashas/distohelp/blob/main/backend/app/escalation.py): `backend/app/escalation.py`

### Persistence and FHIR

- [SQLite Read Model](https://github.com/mnyashas/distohelp/blob/main/backend/app/db.py): `backend/app/db.py`
- [FHIR Client and Worker](https://github.com/mnyashas/distohelp/blob/main/backend/app/fhir_client.py): `backend/app/fhir_client.py`

### Simulation and Replay

- [Live Simulator](https://github.com/mnyashas/distohelp/blob/main/backend/app/simulator.py): `backend/app/simulator.py`
- [Scenario Engine](https://github.com/mnyashas/distohelp/blob/main/backend/app/sim_engine.py): `backend/app/sim_engine.py`
- [Scenario Evaluation](https://github.com/mnyashas/distohelp/blob/main/backend/app/scenarios.py): `backend/app/scenarios.py`
- [BIDMC Replay](https://github.com/mnyashas/distohelp/blob/main/backend/app/bidmc.py): `backend/app/bidmc.py`

### Other components

- **Clinician**
- **Wearable or Sensor**
- **HAPI FHIR Server**

## Connections

- Clinician → Web App Routes: uses (evidence: `frontend/src/App.jsx`)
- Web App Routes → Dashboard: routes to (evidence: `frontend/src/App.jsx`)
- Web App Routes → Patient Profile: routes to (evidence: `frontend/src/App.jsx`)
- Web App Routes → Vitals and Sensors: routes to (evidence: `frontend/src/App.jsx`)
- Web App Routes → Live Monitoring: routes to (evidence: `frontend/src/App.jsx`)
- Web App Routes → Watch Companion: routes to (evidence: `frontend/src/App.jsx`)
- Web App Routes → Authentication State: checks session (evidence: `frontend/src/App.jsx`)
- Authentication State → API Client: loads identity (evidence: `frontend/src/services/AuthContext.jsx`)
- Dashboard → API Client: fetches data (evidence: `frontend/src/dashboard/Dashboard.jsx`)
- Patient Profile → Vitals and Sensors: renders (evidence: `frontend/src/patients/PatientProfile.jsx`)
- Vitals and Sensors → Sensor Panel: renders (evidence: `frontend/src/vitals/VitalsPanel.jsx`)
- Sensor Panel → API Client: submits readings (evidence: `frontend/src/sensors/SensorPanel.jsx`)
- Vitals and Sensors → API Client: saves readings (evidence: `frontend/src/vitals/VitalsPanel.jsx`)
- API Client → Frontend Compatibility API: calls frontend API (evidence: `README.md`)
- API Client → REST API: calls contract API (evidence: `README.md`)
- FastAPI Startup → REST API: registers router (evidence: `backend/app/main.py`)
- FastAPI Startup → Frontend Compatibility API: registers router (evidence: `backend/app/main.py`)
- FastAPI Startup → WebSocket Updates: registers router (evidence: `backend/app/main.py`)
- REST API → Observation Pipeline: parses observations (evidence: `backend/app/api.py`)
- Observation Pipeline → Artifact Suppression: filters readings (evidence: `backend/app/pipeline.py`)
- Observation Pipeline → Personalized Scoring: computes score (evidence: `backend/app/pipeline.py`)
- Observation Pipeline → Explainable Alerts: creates alerts (evidence: `backend/app/pipeline.py`)
- Observation Pipeline → SQLite Read Model: stores readings (evidence: `backend/app/pipeline.py`)
- Observation Pipeline → FHIR Client and Worker: queues observations (evidence: `backend/app/pipeline.py`)
- FHIR Client and Worker → HAPI FHIR Server: flushes bundles (evidence: `backend/app/fhir_client.py`)
- REST API → Explainable Alerts: lists alerts (evidence: `backend/app/api.py`)
- REST API → Clinical Escalation: handles escalation (evidence: `README.md`)
- Clinical Escalation → FHIR Client and Worker: creates FHIR resources (evidence: `backend/app/fhir_client.py`)
- REST API → Live Simulator: controls streams (evidence: `backend/app/api.py`)
- Live Simulator → Scenario Engine: generates ticks
- REST API → Scenario Evaluation: evaluates scenarios (evidence: `README.md`)
- Scenario Evaluation → Scenario Engine: consumes simulation (evidence: `backend/app/sim_engine.py`)
- REST API → BIDMC Replay: starts replay (evidence: `README.md`)
- BIDMC Replay → Observation Pipeline: replays readings (evidence: `README.md`)
- Live Monitoring → API Client: controls monitoring
- Watch Companion → WebSocket Updates: streams vitals (evidence: `README.md`)
- REST API → WebSocket Updates: broadcasts updates
