# muhffikkri/ecg-wave-preprocess architecture

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

- Interactive diagram: https://gitdiagram.com/muhffikkri/ecg-wave-preprocess
- Repository: https://github.com/muhffikkri/ecg-wave-preprocess

## Overview

This repository is a web-based three-lead ECG clinical workbench and hardware-DSP analyzer. A browser requests records and processing from the FastAPI application; data access loads ECGs, the DSP layer filters and resamples them, and the workbench returns visualizable signals and Holter metrics. Users can also save or download filtered frames and inspect ProSim distortion. The AI model registry and inference modules provide model selection and Keras/TFLite predictions. README capabilities are included where the tree supports them; some wiring is inferred only from documented routes and module roles because source excerpts are partial.

Main entry points: [`src/app/main.py`](https://github.com/muhffikkri/ecg-wave-preprocess/blob/main/src/app/main.py) (FastAPI routes), [`src/presentation/script.js`](https://github.com/muhffikkri/ecg-wave-preprocess/blob/main/src/presentation/script.js) (Dashboard), [`src/logic/logic_layer.py`](https://github.com/muhffikkri/ecg-wave-preprocess/blob/main/src/logic/logic_layer.py) (Live pipeline), [`src/app/model_registry.py`](https://github.com/muhffikkri/ecg-wave-preprocess/blob/main/src/app/model_registry.py) (Model registry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web Workbench"]
  node_browser["Dashboard<br/>[script.js]"]
  node_api["FastAPI routes<br/>[main.py]"]
  node_config["Runtime settings<br/>[config.py]"]
end

subgraph group_data["ECG Data"]
  node_records["Record discovery<br/>[data_layer.py]"]
  node_loader["Signal loading<br/>[data_layer.py]"]
  node_datasets[("ECG datasets")]
  node_manifest["Label lookup"]
end

subgraph group_dsp["Signal Processing"]
  node_preprocess["DSP preprocessing<br/>[preprocessing.py]"]
  node_pipeline["Live pipeline<br/>[logic_layer.py]"]
  node_holter["Holter metrics<br/>[logic_layer.py]"]
  node_frames["Frame export<br/>[logic_layer.py]"]
end

subgraph group_ai["AI Inference"]
  node_registry["Model registry<br/>[model_registry.py]"]
  node_model_manager["Model cache"]
  node_inference["Prediction engine"]
end

subgraph group_sim["Hardware Analysis"]
  node_simulator["ProSim analysis"]
end

node_clinician(("Workbench user"))
node_hardware(("ADS1293 captures"))

node_clinician -->|"uses"| node_browser
node_browser -->|"requests"| node_api
node_api -->|"lists records"| node_records
node_records -->|"scans"| node_datasets
node_api -->|"loads signals"| node_loader
node_loader -->|"reads records"| node_datasets
node_api -->|"processes signal"| node_pipeline
node_pipeline -->|"cleans signal"| node_preprocess
node_pipeline -->|"computes metrics"| node_holter
node_api -->|"saves frames"| node_frames
node_browser -->|"requests export"| node_api
node_registry -->|"uses settings"| node_config
node_model_manager -->|"loads model config"| node_registry
node_inference -->|"gets model settings"| node_registry
node_inference -->|"gets cached models"| node_model_manager
node_api -->|"analyzes captures"| node_simulator
node_simulator -.->|"reads captures"| node_hardware
node_api -.->|"looks up labels"| node_manifest
node_api -->|"reads defaults"| node_config

click node_browser "https://github.com/muhffikkri/ecg-wave-preprocess/blob/main/src/presentation/script.js"
click node_api "https://github.com/muhffikkri/ecg-wave-preprocess/blob/main/src/app/main.py"
click node_config "https://github.com/muhffikkri/ecg-wave-preprocess/blob/main/src/app/config.py"
click node_records "https://github.com/muhffikkri/ecg-wave-preprocess/blob/main/src/data/data_layer.py"
click node_loader "https://github.com/muhffikkri/ecg-wave-preprocess/blob/main/src/data/data_layer.py"
click node_datasets "https://github.com/muhffikkri/ecg-wave-preprocess/tree/main/dataset"
click node_preprocess "https://github.com/muhffikkri/ecg-wave-preprocess/blob/main/src/logic/preprocessing.py"
click node_pipeline "https://github.com/muhffikkri/ecg-wave-preprocess/blob/main/src/logic/logic_layer.py"
click node_holter "https://github.com/muhffikkri/ecg-wave-preprocess/blob/main/src/logic/logic_layer.py"
click node_frames "https://github.com/muhffikkri/ecg-wave-preprocess/blob/main/src/logic/logic_layer.py"
click node_manifest "https://github.com/muhffikkri/ecg-wave-preprocess/blob/main/src/logic/manifest_manager.py"
click node_registry "https://github.com/muhffikkri/ecg-wave-preprocess/blob/main/src/app/model_registry.py"
click node_model_manager "https://github.com/muhffikkri/ecg-wave-preprocess/blob/main/src/logic/ai_model_manager.py"
click node_inference "https://github.com/muhffikkri/ecg-wave-preprocess/blob/main/src/logic/inference_manager.py"
click node_simulator "https://github.com/muhffikkri/ecg-wave-preprocess/blob/main/src/logic/dsp_simulation_workbench.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_browser,node_api,node_config,node_clinician toneBlue
class node_records,node_loader,node_datasets,node_manifest toneAmber
class node_preprocess,node_pipeline,node_holter,node_frames toneMint
class node_registry,node_model_manager,node_inference toneRose
class node_simulator,node_hardware toneIndigo
```

## Components

### Web Workbench

- [Dashboard](https://github.com/muhffikkri/ecg-wave-preprocess/blob/main/src/presentation/script.js): `src/presentation/script.js`
- [FastAPI routes](https://github.com/muhffikkri/ecg-wave-preprocess/blob/main/src/app/main.py): `src/app/main.py`
- [Runtime settings](https://github.com/muhffikkri/ecg-wave-preprocess/blob/main/src/app/config.py): `src/app/config.py`

### ECG Data

- [Record discovery](https://github.com/muhffikkri/ecg-wave-preprocess/blob/main/src/data/data_layer.py): `src/data/data_layer.py`
- [Signal loading](https://github.com/muhffikkri/ecg-wave-preprocess/blob/main/src/data/data_layer.py): `src/data/data_layer.py`
- [ECG datasets](https://github.com/muhffikkri/ecg-wave-preprocess/tree/main/dataset): `dataset`
- [Label lookup](https://github.com/muhffikkri/ecg-wave-preprocess/blob/main/src/logic/manifest_manager.py): `src/logic/manifest_manager.py`

### Signal Processing

- [DSP preprocessing](https://github.com/muhffikkri/ecg-wave-preprocess/blob/main/src/logic/preprocessing.py): `src/logic/preprocessing.py`
- [Live pipeline](https://github.com/muhffikkri/ecg-wave-preprocess/blob/main/src/logic/logic_layer.py): `src/logic/logic_layer.py`
- [Holter metrics](https://github.com/muhffikkri/ecg-wave-preprocess/blob/main/src/logic/logic_layer.py): `src/logic/logic_layer.py`
- [Frame export](https://github.com/muhffikkri/ecg-wave-preprocess/blob/main/src/logic/logic_layer.py): `src/logic/logic_layer.py`

### AI Inference

- [Model registry](https://github.com/muhffikkri/ecg-wave-preprocess/blob/main/src/app/model_registry.py): `src/app/model_registry.py`
- [Model cache](https://github.com/muhffikkri/ecg-wave-preprocess/blob/main/src/logic/ai_model_manager.py): `src/logic/ai_model_manager.py`
- [Prediction engine](https://github.com/muhffikkri/ecg-wave-preprocess/blob/main/src/logic/inference_manager.py): `src/logic/inference_manager.py`

### Hardware Analysis

- [ProSim analysis](https://github.com/muhffikkri/ecg-wave-preprocess/blob/main/src/logic/dsp_simulation_workbench.py): `src/logic/dsp_simulation_workbench.py`

### Other components

- **Workbench user**
- **ADS1293 captures**

## Connections

- Workbench user → Dashboard: uses
- Dashboard → FastAPI routes: requests
- FastAPI routes → Record discovery: lists records
- Record discovery → ECG datasets: scans
- FastAPI routes → Signal loading: loads signals
- Signal loading → ECG datasets: reads records
- FastAPI routes → Live pipeline: processes signal
- Live pipeline → DSP preprocessing: cleans signal
- Live pipeline → Holter metrics: computes metrics
- FastAPI routes → Frame export: saves frames
- Dashboard → FastAPI routes: requests export
- Model registry → Runtime settings: uses settings
- Model cache → Model registry: loads model config
- Prediction engine → Model registry: gets model settings
- Prediction engine → Model cache: gets cached models
- FastAPI routes → ProSim analysis: analyzes captures
- ProSim analysis → ADS1293 captures: reads captures
- FastAPI routes → Label lookup: looks up labels
- FastAPI routes → Runtime settings: reads defaults
