# moonlightedd/ecg-heartbeat-classification architecture

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

- Interactive diagram: https://gitdiagram.com/moonlightedd/ecg-heartbeat-classification
- Repository: https://github.com/moonlightedd/ecg-heartbeat-classification

## Overview

This is an educational ECG heartbeat-classification application: users can inspect reported model results or upload ECG rows for validation, prediction, and result review. The frontend also provides dashboard, waveform/class-distribution views, and project information; the Python backend exposes health and batch-prediction endpoints. The sampled frontend shows the analysis page calling its API client and CSV utilities. Backend implementation details were not excerpted, so the model-artifact connection is shown as unverified.

Main entry points: [`src/App.tsx`](https://github.com/moonlightedd/ecg-heartbeat-classification/blob/main/src/App.tsx) (App navigation), [`src/pages/EcgAnalysis.tsx`](https://github.com/moonlightedd/ecg-heartbeat-classification/blob/main/src/pages/EcgAnalysis.tsx) (ECG analysis), [`src/pages/ModelPerformance.tsx`](https://github.com/moonlightedd/ecg-heartbeat-classification/blob/main/src/pages/ModelPerformance.tsx) (Model performance), [`src/lib/constants.ts`](https://github.com/moonlightedd/ecg-heartbeat-classification/blob/main/src/lib/constants.ts) (Classes and metrics)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Frontend app"]
  node_app["App navigation<br/>[App.tsx]"]
  node_layout["Page layout<br/>[Layout.tsx]"]
  node_sidebar["Sidebar navigation<br/>[Sidebar.tsx]"]
  node_dashboard["Dashboard<br/>[Dashboard.tsx]"]
  node_about["Project information<br/>[About.tsx]"]
end

subgraph group_analysis["ECG analysis"]
  node_analysis_page["ECG analysis<br/>[EcgAnalysis.tsx]"]
  node_csv["CSV validation<br/>[csv.ts]"]
  node_api_client["Prediction API client<br/>[api.ts]"]
  node_waveform["Waveform chart<br/>[WaveformChart.tsx]"]
  node_bar_chart["Class distribution chart<br/>[BarChart.tsx]"]
end

subgraph group_evaluation["Model evaluation"]
  node_model_page["Model performance"]
  node_comparison["Model comparison chart"]
  node_confusion["Confusion matrix"]
  node_constants["Classes and metrics<br/>[constants.ts]"]
  node_types["Shared domain types<br/>[types.ts]"]
end

subgraph group_backend["Prediction backend"]
  node_backend_api["Python prediction API<br/>[main.py]"]
  node_model_file["Serialized classifier"]
end

node_user(("User"))

node_user -.->|"uses"| node_app
node_app -->|"renders"| node_sidebar
node_app -->|"renders"| node_layout
node_app -->|"routes to"| node_dashboard
node_app -->|"routes to"| node_analysis_page
node_app -->|"routes to"| node_model_page
node_app -->|"routes to"| node_about
node_analysis_page -->|"parses and exports"| node_csv
node_analysis_page -->|"requests predictions"| node_api_client
node_analysis_page -->|"renders"| node_waveform
node_analysis_page -->|"renders"| node_bar_chart
node_api_client -.->|"calls"| node_backend_api
node_backend_api -.->|"loads classifier"| node_model_file
node_model_page -->|"renders"| node_comparison
node_model_page -->|"renders"| node_confusion
node_model_page -->|"reads metrics"| node_constants
node_confusion -->|"reads class labels"| node_constants
node_dashboard -->|"reads model data"| node_constants
node_analysis_page -.->|"uses class definitions"| node_constants
node_analysis_page -.->|"uses domain types"| node_types

click node_app "https://github.com/moonlightedd/ecg-heartbeat-classification/blob/main/src/App.tsx"
click node_layout "https://github.com/moonlightedd/ecg-heartbeat-classification/blob/main/src/components/layout/Layout.tsx"
click node_sidebar "https://github.com/moonlightedd/ecg-heartbeat-classification/blob/main/src/components/layout/Sidebar.tsx"
click node_dashboard "https://github.com/moonlightedd/ecg-heartbeat-classification/blob/main/src/pages/Dashboard.tsx"
click node_about "https://github.com/moonlightedd/ecg-heartbeat-classification/blob/main/src/pages/About.tsx"
click node_analysis_page "https://github.com/moonlightedd/ecg-heartbeat-classification/blob/main/src/pages/EcgAnalysis.tsx"
click node_csv "https://github.com/moonlightedd/ecg-heartbeat-classification/blob/main/src/lib/csv.ts"
click node_api_client "https://github.com/moonlightedd/ecg-heartbeat-classification/blob/main/src/lib/api.ts"
click node_waveform "https://github.com/moonlightedd/ecg-heartbeat-classification/blob/main/src/components/charts/WaveformChart.tsx"
click node_bar_chart "https://github.com/moonlightedd/ecg-heartbeat-classification/blob/main/src/components/charts/BarChart.tsx"
click node_model_page "https://github.com/moonlightedd/ecg-heartbeat-classification/blob/main/src/pages/ModelPerformance.tsx"
click node_comparison "https://github.com/moonlightedd/ecg-heartbeat-classification/blob/main/src/components/charts/ComparisonChart.tsx"
click node_confusion "https://github.com/moonlightedd/ecg-heartbeat-classification/blob/main/src/components/charts/ConfusionMatrix.tsx"
click node_constants "https://github.com/moonlightedd/ecg-heartbeat-classification/blob/main/src/lib/constants.ts"
click node_types "https://github.com/moonlightedd/ecg-heartbeat-classification/blob/main/src/lib/types.ts"
click node_backend_api "https://github.com/moonlightedd/ecg-heartbeat-classification/blob/main/backend/main.py"
click node_model_file "https://github.com/moonlightedd/ecg-heartbeat-classification/blob/main/backend/ecg_random_forest.pkl.gz"

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_layout,node_sidebar,node_dashboard,node_about,node_user toneBlue
class node_analysis_page,node_csv,node_api_client,node_waveform,node_bar_chart toneAmber
class node_model_page,node_comparison,node_confusion,node_constants,node_types toneMint
class node_backend_api,node_model_file toneRose
```

## Components

### Frontend app

- [App navigation](https://github.com/moonlightedd/ecg-heartbeat-classification/blob/main/src/App.tsx): `src/App.tsx`
- [Page layout](https://github.com/moonlightedd/ecg-heartbeat-classification/blob/main/src/components/layout/Layout.tsx): `src/components/layout/Layout.tsx`
- [Sidebar navigation](https://github.com/moonlightedd/ecg-heartbeat-classification/blob/main/src/components/layout/Sidebar.tsx): `src/components/layout/Sidebar.tsx`
- [Dashboard](https://github.com/moonlightedd/ecg-heartbeat-classification/blob/main/src/pages/Dashboard.tsx): `src/pages/Dashboard.tsx`
- [Project information](https://github.com/moonlightedd/ecg-heartbeat-classification/blob/main/src/pages/About.tsx): `src/pages/About.tsx`

### ECG analysis

- [ECG analysis](https://github.com/moonlightedd/ecg-heartbeat-classification/blob/main/src/pages/EcgAnalysis.tsx): `src/pages/EcgAnalysis.tsx`
- [CSV validation](https://github.com/moonlightedd/ecg-heartbeat-classification/blob/main/src/lib/csv.ts): `src/lib/csv.ts`
- [Prediction API client](https://github.com/moonlightedd/ecg-heartbeat-classification/blob/main/src/lib/api.ts): `src/lib/api.ts`
- [Waveform chart](https://github.com/moonlightedd/ecg-heartbeat-classification/blob/main/src/components/charts/WaveformChart.tsx): `src/components/charts/WaveformChart.tsx`
- [Class distribution chart](https://github.com/moonlightedd/ecg-heartbeat-classification/blob/main/src/components/charts/BarChart.tsx): `src/components/charts/BarChart.tsx`

### Model evaluation

- [Model performance](https://github.com/moonlightedd/ecg-heartbeat-classification/blob/main/src/pages/ModelPerformance.tsx): `src/pages/ModelPerformance.tsx`
- [Model comparison chart](https://github.com/moonlightedd/ecg-heartbeat-classification/blob/main/src/components/charts/ComparisonChart.tsx): `src/components/charts/ComparisonChart.tsx`
- [Confusion matrix](https://github.com/moonlightedd/ecg-heartbeat-classification/blob/main/src/components/charts/ConfusionMatrix.tsx): `src/components/charts/ConfusionMatrix.tsx`
- [Classes and metrics](https://github.com/moonlightedd/ecg-heartbeat-classification/blob/main/src/lib/constants.ts): `src/lib/constants.ts`
- [Shared domain types](https://github.com/moonlightedd/ecg-heartbeat-classification/blob/main/src/lib/types.ts): `src/lib/types.ts`

### Prediction backend

- [Python prediction API](https://github.com/moonlightedd/ecg-heartbeat-classification/blob/main/backend/main.py): `backend/main.py`
- [Serialized classifier](https://github.com/moonlightedd/ecg-heartbeat-classification/blob/main/backend/ecg_random_forest.pkl.gz): `backend/ecg_random_forest.pkl.gz`

### Other components

- **User**

## Connections

- User → App navigation: uses
- App navigation → Sidebar navigation: renders (evidence: `src/App.tsx`)
- App navigation → Page layout: renders (evidence: `src/App.tsx`)
- App navigation → Dashboard: routes to (evidence: `src/App.tsx`)
- App navigation → ECG analysis: routes to (evidence: `src/App.tsx`)
- App navigation → Model performance: routes to (evidence: `src/App.tsx`)
- App navigation → Project information: routes to (evidence: `src/App.tsx`)
- ECG analysis → CSV validation: parses and exports (evidence: `src/pages/EcgAnalysis.tsx`)
- ECG analysis → Prediction API client: requests predictions (evidence: `src/pages/EcgAnalysis.tsx`)
- ECG analysis → Waveform chart: renders (evidence: `src/pages/EcgAnalysis.tsx`)
- ECG analysis → Class distribution chart: renders (evidence: `src/pages/EcgAnalysis.tsx`)
- Prediction API client → Python prediction API: calls (evidence: `README.md`)
- Python prediction API → Serialized classifier: loads classifier
- Model performance → Model comparison chart: renders (evidence: `src/pages/ModelPerformance.tsx`)
- Model performance → Confusion matrix: renders (evidence: `src/pages/ModelPerformance.tsx`)
- Model performance → Classes and metrics: reads metrics (evidence: `src/pages/ModelPerformance.tsx`)
- Confusion matrix → Classes and metrics: reads class labels (evidence: `src/components/charts/ConfusionMatrix.tsx`)
- Dashboard → Classes and metrics: reads model data (evidence: `src/pages/Dashboard.tsx`)
- ECG analysis → Classes and metrics: uses class definitions (evidence: `src/pages/EcgAnalysis.tsx`)
- ECG analysis → Shared domain types: uses domain types (evidence: `src/pages/EcgAnalysis.tsx`)
