# yelli05/ecg-cardio-dashboard architecture

> Architecture diagram of the GitHub repository yelli05/ecg-cardio-dashboard, 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/yelli05/ecg-cardio-dashboard
- Repository: https://github.com/yelli05/ecg-cardio-dashboard

## Overview

This is an educational ECG heartbeat-classification web app. A user selects one of the bundled sample beats or uploads a one-row CSV in the Streamlit dashboard; the dashboard sends 187 values to the FastAPI service, which validates them, runs the loaded PyTorch CNN, and returns a class, confidence, and probabilities for display. The README also documents the model-training and baseline-comparison work. That development branch is shown at the available directory level; its notebook internals were not sampled.

Main entry points: [`backend/main.py`](https://github.com/yelli05/ecg-cardio-dashboard/blob/main/backend/main.py) (FastAPI API), [`frontend/app.py`](https://github.com/yelli05/ecg-cardio-dashboard/blob/main/frontend/app.py) (Streamlit dashboard), [`notebooks_or_scripts`](https://github.com/yelli05/ecg-cardio-dashboard/tree/main/notebooks_or_scripts) (Training and baselines), [`backend/ecg_model.pth`](https://github.com/yelli05/ecg-cardio-dashboard/blob/main/backend/ecg_model.pth) (CNN weights)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_dashboard["Heartbeat dashboard"]
  node_dashboard_app["Streamlit dashboard<br/>[app.py]"]
  node_sample_beats["Sample beats"]
end

subgraph group_inference["Inference service"]
  node_api["FastAPI API<br/>[main.py]"]
  node_cnn["ECG CNN<br/>[model.py]"]
  node_weights["CNN weights<br/>[ecg_model.pth]"]
end

subgraph group_modeling["Model development"]
  node_experiments["Training and baselines"]
  node_results["Model results"]
end

node_user(("User"))

node_user -->|"selects beat"| node_dashboard_app
node_dashboard_app -->|"reads samples"| node_sample_beats
node_dashboard_app -->|"sends values"| node_api
node_api -->|"runs inference"| node_cnn
node_api -->|"loads weights"| node_weights
node_api -->|"returns prediction"| node_dashboard_app
node_experiments -.->|"produces checkpoint"| node_weights
node_experiments -.->|"evaluates models"| node_results

click node_dashboard_app "https://github.com/yelli05/ecg-cardio-dashboard/blob/main/frontend/app.py"
click node_sample_beats "https://github.com/yelli05/ecg-cardio-dashboard/blob/main/frontend/sample_heartbeats.csv"
click node_api "https://github.com/yelli05/ecg-cardio-dashboard/blob/main/backend/main.py"
click node_cnn "https://github.com/yelli05/ecg-cardio-dashboard/blob/main/backend/model.py"
click node_weights "https://github.com/yelli05/ecg-cardio-dashboard/blob/main/backend/ecg_model.pth"
click node_experiments "https://github.com/yelli05/ecg-cardio-dashboard/tree/main/notebooks_or_scripts"
click node_results "https://github.com/yelli05/ecg-cardio-dashboard/tree/main/results"

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_dashboard_app,node_sample_beats,node_user toneBlue
class node_api,node_cnn,node_weights toneAmber
class node_experiments,node_results toneMint
```

## Components

### Heartbeat dashboard

- [Streamlit dashboard](https://github.com/yelli05/ecg-cardio-dashboard/blob/main/frontend/app.py): `frontend/app.py`
- [Sample beats](https://github.com/yelli05/ecg-cardio-dashboard/blob/main/frontend/sample_heartbeats.csv): `frontend/sample_heartbeats.csv`

### Inference service

- [FastAPI API](https://github.com/yelli05/ecg-cardio-dashboard/blob/main/backend/main.py): `backend/main.py`
- [ECG CNN](https://github.com/yelli05/ecg-cardio-dashboard/blob/main/backend/model.py): `backend/model.py`
- [CNN weights](https://github.com/yelli05/ecg-cardio-dashboard/blob/main/backend/ecg_model.pth): `backend/ecg_model.pth`

### Model development

- [Training and baselines](https://github.com/yelli05/ecg-cardio-dashboard/tree/main/notebooks_or_scripts): `notebooks_or_scripts`
- [Model results](https://github.com/yelli05/ecg-cardio-dashboard/tree/main/results): `results`

### Other components

- **User**

## Connections

- User → Streamlit dashboard: selects beat (evidence: `README.md`)
- Streamlit dashboard → Sample beats: reads samples (evidence: `frontend/app.py`)
- Streamlit dashboard → FastAPI API: sends values (evidence: `frontend/app.py`)
- FastAPI API → ECG CNN: runs inference (evidence: `backend/main.py`)
- FastAPI API → CNN weights: loads weights (evidence: `backend/main.py`)
- FastAPI API → Streamlit dashboard: returns prediction (evidence: `README.md`)
- Training and baselines → CNN weights: produces checkpoint (evidence: `README.md`)
- Training and baselines → Model results: evaluates models (evidence: `README.md`)
