# leahmoore8/motion-aware-physio architecture

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

- Interactive diagram: https://gitdiagram.com/leahmoore8/motion-aware-physio
- Repository: https://github.com/leahmoore8/motion-aware-physio

## Overview

This is an in-development embedded PPG/IMU sensing and analysis system. The intended workflow is serial sensor data acquisition, CSV recording, windowed heart-rate and motion analysis, then reliability flagging; synthetic datasets also support detector evaluation. The graph preserves the firmware, acquisition, DSP, and evaluation branches. Physical sensor integration is documented as pending, so those links are dashed. Unsampled capabilities are included only where the README or tree supports them; absent data files are represented as a conceptual CSV artifact.

Main entry points: [`analysis/signal_processing/windowed_hr.py`](https://github.com/leahmoore8/motion-aware-physio/blob/main/analysis/signal_processing/windowed_hr.py) (Windowed analysis), [`analysis/testing/evaluate_detector.py`](https://github.com/leahmoore8/motion-aware-physio/blob/main/analysis/testing/evaluate_detector.py) (Baseline evaluation), [`analysis/testing/compare_detectors.py`](https://github.com/leahmoore8/motion-aware-physio/blob/main/analysis/testing/compare_detectors.py) (Detector comparison), [`firmware/src/main.cpp`](https://github.com/leahmoore8/motion-aware-physio/blob/main/firmware/src/main.cpp) (ESP32 stream)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_embedded["Embedded sensing"]
  node_esp["ESP32 stream<br/>[main.cpp]"]
  node_i2c["I²C scanner<br/>[i2c_scanner.cpp]"]
end

subgraph group_acquisition["Data acquisition"]
  node_recorder["Serial recorder<br/>[record_serial.py]"]
  node_csv["CSV recordings"]
end

subgraph group_processing["Signal processing"]
  node_hr["FFT heart rate<br/>[estimate_hr.py]"]
  node_windows["Windowed analysis<br/>[windowed_hr.py]"]
  node_motion["Motion quality<br/>[motion_quality.py]"]
  node_spectral["Spectral quality"]
end

subgraph group_evaluation["Evaluation and views"]
  node_synthetic["Synthetic generator"]
  node_evaluate["Baseline evaluation"]
  node_compare["Detector comparison"]
  node_inspect["Spectral inspection"]
  node_plot["Signal visualization<br/>[plot_signals.py]"]
  node_motionplot["Motion comparison"]
end

node_operator(("Operator"))
node_ppg["MAX30102 PPG"]
node_imu["MPU6050 IMU"]

node_operator -->|"starts recording"| node_recorder
node_esp -->|"streams samples"| node_recorder
node_recorder -->|"writes CSV"| node_csv
node_synthetic -->|"generates datasets"| node_csv
node_evaluate -->|"reads cases"| node_csv
node_evaluate -->|"analyzes windows"| node_windows
node_evaluate -->|"assesses flags"| node_motion
node_windows -->|"estimates HR"| node_hr
node_motion -->|"analyzes windows"| node_windows
node_compare -->|"reads cases"| node_csv
node_compare -->|"compares flags"| node_spectral
node_compare -->|"uses test cases"| node_synthetic
node_spectral -->|"analyzes windows"| node_windows
node_inspect -->|"reads recording"| node_csv
node_inspect -->|"inspects features"| node_spectral
node_plot -->|"reads recording"| node_csv
node_i2c -.->|"scans devices"| node_ppg
node_i2c -.->|"scans devices"| node_imu
node_ppg -.->|"planned I²C input"| node_esp
node_imu -.->|"planned I²C input"| node_esp

click node_esp "https://github.com/leahmoore8/motion-aware-physio/blob/main/firmware/src/main.cpp"
click node_i2c "https://github.com/leahmoore8/motion-aware-physio/blob/main/firmware/examples/i2c_scanner.cpp"
click node_recorder "https://github.com/leahmoore8/motion-aware-physio/blob/main/analysis/acquisition/record_serial.py"
click node_synthetic "https://github.com/leahmoore8/motion-aware-physio/blob/main/analysis/testing/generate_synthetic.py"
click node_hr "https://github.com/leahmoore8/motion-aware-physio/blob/main/analysis/signal_processing/estimate_hr.py"
click node_windows "https://github.com/leahmoore8/motion-aware-physio/blob/main/analysis/signal_processing/windowed_hr.py"
click node_motion "https://github.com/leahmoore8/motion-aware-physio/blob/main/analysis/signal_processing/motion_quality.py"
click node_spectral "https://github.com/leahmoore8/motion-aware-physio/blob/main/analysis/signal_processing/spectral_quality.py"
click node_evaluate "https://github.com/leahmoore8/motion-aware-physio/blob/main/analysis/testing/evaluate_detector.py"
click node_compare "https://github.com/leahmoore8/motion-aware-physio/blob/main/analysis/testing/compare_detectors.py"
click node_inspect "https://github.com/leahmoore8/motion-aware-physio/blob/main/analysis/testing/inspect_spectral.py"
click node_plot "https://github.com/leahmoore8/motion-aware-physio/blob/main/analysis/visualization/plot_signals.py"
click node_motionplot "https://github.com/leahmoore8/motion-aware-physio/blob/main/analysis/visualization/plot_motion_comparison.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_esp,node_i2c toneBlue
class node_recorder,node_csv toneAmber
class node_hr,node_windows,node_motion,node_spectral toneMint
class node_synthetic,node_evaluate,node_compare,node_inspect,node_plot,node_motionplot toneRose
class node_operator,node_ppg,node_imu toneIndigo
```

## Components

### Embedded sensing

- [ESP32 stream](https://github.com/leahmoore8/motion-aware-physio/blob/main/firmware/src/main.cpp): `firmware/src/main.cpp`
- [I²C scanner](https://github.com/leahmoore8/motion-aware-physio/blob/main/firmware/examples/i2c_scanner.cpp): `firmware/examples/i2c_scanner.cpp`

### Data acquisition

- [Serial recorder](https://github.com/leahmoore8/motion-aware-physio/blob/main/analysis/acquisition/record_serial.py): `analysis/acquisition/record_serial.py`
- **CSV recordings**

### Signal processing

- [FFT heart rate](https://github.com/leahmoore8/motion-aware-physio/blob/main/analysis/signal_processing/estimate_hr.py): `analysis/signal_processing/estimate_hr.py`
- [Windowed analysis](https://github.com/leahmoore8/motion-aware-physio/blob/main/analysis/signal_processing/windowed_hr.py): `analysis/signal_processing/windowed_hr.py`
- [Motion quality](https://github.com/leahmoore8/motion-aware-physio/blob/main/analysis/signal_processing/motion_quality.py): `analysis/signal_processing/motion_quality.py`
- [Spectral quality](https://github.com/leahmoore8/motion-aware-physio/blob/main/analysis/signal_processing/spectral_quality.py): `analysis/signal_processing/spectral_quality.py`

### Evaluation and views

- [Synthetic generator](https://github.com/leahmoore8/motion-aware-physio/blob/main/analysis/testing/generate_synthetic.py): `analysis/testing/generate_synthetic.py`
- [Baseline evaluation](https://github.com/leahmoore8/motion-aware-physio/blob/main/analysis/testing/evaluate_detector.py): `analysis/testing/evaluate_detector.py`
- [Detector comparison](https://github.com/leahmoore8/motion-aware-physio/blob/main/analysis/testing/compare_detectors.py): `analysis/testing/compare_detectors.py`
- [Spectral inspection](https://github.com/leahmoore8/motion-aware-physio/blob/main/analysis/testing/inspect_spectral.py): `analysis/testing/inspect_spectral.py`
- [Signal visualization](https://github.com/leahmoore8/motion-aware-physio/blob/main/analysis/visualization/plot_signals.py): `analysis/visualization/plot_signals.py`
- [Motion comparison](https://github.com/leahmoore8/motion-aware-physio/blob/main/analysis/visualization/plot_motion_comparison.py): `analysis/visualization/plot_motion_comparison.py`

### Other components

- **Operator**
- **MAX30102 PPG**
- **MPU6050 IMU**

## Connections

- Operator → Serial recorder: starts recording (evidence: `analysis/acquisition/record_serial.py`)
- ESP32 stream → Serial recorder: streams samples (evidence: `README.md`)
- Serial recorder → CSV recordings: writes CSV (evidence: `analysis/acquisition/record_serial.py`)
- Synthetic generator → CSV recordings: generates datasets (evidence: `analysis/testing/generate_synthetic.py`)
- Baseline evaluation → CSV recordings: reads cases (evidence: `analysis/testing/evaluate_detector.py`)
- Baseline evaluation → Windowed analysis: analyzes windows (evidence: `analysis/testing/evaluate_detector.py`)
- Baseline evaluation → Motion quality: assesses flags (evidence: `analysis/testing/evaluate_detector.py`)
- Windowed analysis → FFT heart rate: estimates HR (evidence: `analysis/signal_processing/windowed_hr.py`)
- Motion quality → Windowed analysis: analyzes windows (evidence: `analysis/signal_processing/motion_quality.py`)
- Detector comparison → CSV recordings: reads cases (evidence: `analysis/testing/compare_detectors.py`)
- Detector comparison → Spectral quality: compares flags (evidence: `analysis/testing/compare_detectors.py`)
- Detector comparison → Synthetic generator: uses test cases (evidence: `analysis/testing/compare_detectors.py`)
- Spectral quality → Windowed analysis: analyzes windows (evidence: `analysis/signal_processing/spectral_quality.py`)
- Spectral inspection → CSV recordings: reads recording (evidence: `analysis/testing/inspect_spectral.py`)
- Spectral inspection → Spectral quality: inspects features (evidence: `analysis/testing/inspect_spectral.py`)
- Signal visualization → CSV recordings: reads recording (evidence: `analysis/visualization/plot_signals.py`)
- I²C scanner → MAX30102 PPG: scans devices
- I²C scanner → MPU6050 IMU: scans devices
- MAX30102 PPG → ESP32 stream: planned I²C input (evidence: `README.md`)
- MPU6050 IMU → ESP32 stream: planned I²C input (evidence: `README.md`)
