# solrinku/dynacardio-real-time-ecg-heart-risk-detection architecture

> Architecture diagram of the GitHub repository solrinku/dynacardio-real-time-ecg-heart-risk-detection, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/solrinku/dynacardio-real-time-ecg-heart-risk-detection
- Repository: https://github.com/solrinku/dynacardio-real-time-ecg-heart-risk-detection

## Overview

DynaCardio replays MIT-BIH ECG records as timed windows, extracts signal and HRV features, classifies each window into a risk tier, and streams results to a live monitoring dashboard. The queue separates raw-window and feature stages; the API owns inference, result history, HTTP endpoints, and WebSocket broadcasts. Model training is a separate dataset-to-artifact branch. Dashboard capabilities are documented in the README, but its implementation was not sampled, so its internal wiring is not expanded.

Main entry points: [`backend/api/server.py`](https://github.com/solrinku/dynacardio-real-time-ecg-heart-risk-detection/blob/main/backend/api/server.py) (Risk Inference), [`backend/queue_server.py`](https://github.com/solrinku/dynacardio-real-time-ecg-heart-risk-detection/blob/main/backend/queue_server.py) (HTTP Queues), [`backend/replay/replay_service.py`](https://github.com/solrinku/dynacardio-real-time-ecg-heart-risk-detection/blob/main/backend/replay/replay_service.py) (Record Replay), [`backend/preprocessing/preprocess_service.py`](https://github.com/solrinku/dynacardio-real-time-ecg-heart-risk-detection/blob/main/backend/preprocessing/preprocess_service.py) (Feature Extraction)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_replay["ECG Replay"]
  node_replay_service["Record Replay<br/>[replay_service.py]"]
  node_queue[("HTTP Queues<br/>[queue_server.py]")]
end

subgraph group_processing["Signal Processing"]
  node_preprocess["Feature Extraction"]
end

subgraph group_serving["Risk Serving"]
  node_inference["Risk Inference<br/>[server.py]"]
  node_api["HTTP API<br/>[server.py]"]
  node_history[("Result History<br/>[server.py]")]
  node_dashboard["Live Dashboard<br/>[index.html]"]
end

subgraph group_training["Model Training"]
  node_trainer["Training Pipeline<br/>[train_model.py]"]
  node_model["Trained Model"]
end

node_dataset[("MIT-BIH Records")]
node_viewer(("Dashboard User"))

node_dataset -->|"reads record"| node_replay_service
node_replay_service -->|"publishes raw windows"| node_queue
node_queue -->|"delivers raw windows"| node_preprocess
node_preprocess -->|"publishes features"| node_queue
node_queue -->|"delivers features"| node_inference
node_inference -->|"loads classifier"| node_model
node_inference -->|"appends results"| node_history
node_inference -->|"updates latest"| node_api
node_api -->|"streams results"| node_dashboard
node_dashboard -->|"displays monitoring"| node_viewer
node_dataset -->|"reads records"| node_trainer
node_trainer -->|"writes classifier"| node_model

click node_replay_service "https://github.com/solrinku/dynacardio-real-time-ecg-heart-risk-detection/blob/main/backend/replay/replay_service.py"
click node_queue "https://github.com/solrinku/dynacardio-real-time-ecg-heart-risk-detection/blob/main/backend/queue_server.py"
click node_preprocess "https://github.com/solrinku/dynacardio-real-time-ecg-heart-risk-detection/blob/main/backend/preprocessing/preprocess_service.py"
click node_inference "https://github.com/solrinku/dynacardio-real-time-ecg-heart-risk-detection/blob/main/backend/api/server.py"
click node_api "https://github.com/solrinku/dynacardio-real-time-ecg-heart-risk-detection/blob/main/backend/api/server.py"
click node_history "https://github.com/solrinku/dynacardio-real-time-ecg-heart-risk-detection/blob/main/backend/api/server.py"
click node_dashboard "https://github.com/solrinku/dynacardio-real-time-ecg-heart-risk-detection/blob/main/index.html"
click node_trainer "https://github.com/solrinku/dynacardio-real-time-ecg-heart-risk-detection/blob/main/backend/scripts/train_model.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_replay_service,node_queue,node_viewer toneBlue
class node_preprocess,node_dataset toneAmber
class node_inference,node_api,node_history,node_dashboard toneMint
class node_trainer,node_model toneRose
```

## Components

### ECG Replay

- [Record Replay](https://github.com/solrinku/dynacardio-real-time-ecg-heart-risk-detection/blob/main/backend/replay/replay_service.py): `backend/replay/replay_service.py`
- [HTTP Queues](https://github.com/solrinku/dynacardio-real-time-ecg-heart-risk-detection/blob/main/backend/queue_server.py): `backend/queue_server.py`

### Signal Processing

- [Feature Extraction](https://github.com/solrinku/dynacardio-real-time-ecg-heart-risk-detection/blob/main/backend/preprocessing/preprocess_service.py): `backend/preprocessing/preprocess_service.py`

### Risk Serving

- [Risk Inference](https://github.com/solrinku/dynacardio-real-time-ecg-heart-risk-detection/blob/main/backend/api/server.py): `backend/api/server.py`
- [HTTP API](https://github.com/solrinku/dynacardio-real-time-ecg-heart-risk-detection/blob/main/backend/api/server.py): `backend/api/server.py`
- [Result History](https://github.com/solrinku/dynacardio-real-time-ecg-heart-risk-detection/blob/main/backend/api/server.py): `backend/api/server.py`
- [Live Dashboard](https://github.com/solrinku/dynacardio-real-time-ecg-heart-risk-detection/blob/main/index.html): `index.html`

### Model Training

- [Training Pipeline](https://github.com/solrinku/dynacardio-real-time-ecg-heart-risk-detection/blob/main/backend/scripts/train_model.py): `backend/scripts/train_model.py`
- **Trained Model**

### Other components

- **MIT-BIH Records**
- **Dashboard User**

## Connections

- MIT-BIH Records → Record Replay: reads record
- Record Replay → HTTP Queues: publishes raw windows
- HTTP Queues → Feature Extraction: delivers raw windows
- Feature Extraction → HTTP Queues: publishes features
- HTTP Queues → Risk Inference: delivers features
- Risk Inference → Trained Model: loads classifier
- Risk Inference → Result History: appends results
- Risk Inference → HTTP API: updates latest
- HTTP API → Live Dashboard: streams results
- Live Dashboard → Dashboard User: displays monitoring
- MIT-BIH Records → Training Pipeline: reads records
- Training Pipeline → Trained Model: writes classifier
