Skip to main content

02 / projects / heartflow

HeartFlow OS

Deterministic Edge AI Telemetry & C99 Transpiler. HeartFlow OS compiles trained Scikit-Learn soft-voting ensembles into pure, static C99 headers designed to run on microcontrollers with less than 8KB of SRAM. It pairs the embedded runtime with a 60 FPS browser-based oscillograph communicating over the Web Serial API.

C99PythonTypeScriptNext.jsFastAPIScikit-LearnSHAPWeb Serial APIWebSocketsDocker
01Context

Problem & hardware constraints

HeartFlow OS compiles trained Scikit-Learn soft-voting ensembles into pure, static C99 headers designed to run on microcontrollers with less than 8KB of SRAM. It pairs the embedded runtime with a 60 FPS browser-based oscillograph communicating over the Web Serial API.

02Layers

System architecture & pipeline

The runtime is structured into decoupled execution layers to avoid latency jitter and unpredictable heap fragmentation:

01/Training & Export (Python)

Trains an ensemble classifier in Scikit-Learn, extracts split thresholds, weights, and tree structures, then computes SHAP summary values for explainability.

02/Transpiler Pipeline (C99 Generator)

Generates zero-allocation C99 code. All weights are baked into const arrays in flash memory. Stack usage is strictly bounded below 512 bytes with zero dynamic heap allocation (no malloc).

03/Edge Runtime (Microcontroller)

Processes analog telemetry pins at 250Hz. Fixed-point math and branch-predictable tree traversals execute in 18.4 microseconds per sample.

04/Telemetry & UI (Web Serial + WebSockets)

Streams raw signal packets into a browser dashboard rendered at 60 FPS via Canvas and WebGL shaders, with zero driver installation needed.

03Decisions

Engineering trade-offs & alternatives rejected

Why C99 instead of MicroPython or TinyML?

MicroPython has an unpredictable garbage collector that causes millisecond-long latency spikes during critical telemetry reads. TinyML is great for neural nets, but decision trees transpiled to raw C switch-cases run 10x faster and use virtually zero RAM.

Why Web Serial instead of a local desktop app?

Asking doctors or lab techs to install serial drivers and Python environments always breaks. Web Serial runs straight in Chromium browsers without installs or admin permissions.

04Field Notes

Field notes & edge cases

  • 01Stack overflow on embedded hardware does not throw a polite exception. It just quietly overwrites the interrupt vector table until the board resets itself.
  • 02Fixed-point integer arithmetic was chosen because floating-point hardware on sub-$2 chips either does not exist or burns too many clock cycles.

— / deploy

Explore source & live runtime

Source code, static headers, and benchmarks are open for review on GitHub.

Other systems

Keep exploring