┌──────────────┐ HTTP/WS ┌─────────────────────────────────────┐
│ fbuild-cli │ ───────────────► │ fbuild-daemon │
│ (binary) │ │ ┌────────────┐ ┌───────────────┐ │
└──────────────┘ │ │ Build Proc │ │ Deploy Proc │ │
│ └─────┬──────┘ └──────┬────────┘ │
┌──────────────┐ PyO3 │ │ │ │
│ fbuild-python│ ── bindings ──► │ ┌─────▼──────┐ ┌──────▼────────┐ │
│ (cdylib) │ SerialMonitor │ │fbuild-build│ │ fbuild-deploy │ │
└──────────────┘ WS API │ └─────┬──────┘ └──────┬────────┘ │
│ │ │ │
│ ┌─────▼──────────────▼─────────┐ │
│ │ fbuild-serial │ │
│ │ SharedSerialManager │ │
│ │ Preemption + USB-CDC │ │
│ └──────────────────────────────┘ │
└─────────────────────────────────────┘
│ │
┌────────▼───┐ ┌───────▼────────┐
│ fbuild- │ │ fbuild- │
│ packages │ │ config │
└────────┬───┘ └───────┬────────┘
│ │
┌────────▼──────────────▼────────┐
│ fbuild-core / paths │
└────────────────────────────────┘
Thin clap-based CLI. Parses arguments, sends HTTP requests to daemon, streams output. Subcommands: build, deploy, monitor, purge.
Axum HTTP/WS server (port 8765 prod, 8865 dev). Processes build/deploy/monitor requests. Manages device leases, configuration locks, and serial sessions. Single daemon shared across all projects.
Platform-specific build logic behind BuildOrchestrator trait. Each platform (AVR, ESP32, ESP8266, RP2040, STM32, Teensy, WASM) has its own orchestrator handling: source scanning, compiler flag generation, parallel compilation, linking, size reporting.
Deployer trait with platform-specific upload tools: esptool (ESP32), avrdude (AVR), picotool (RP2040), st-flash (STM32), teensy_loader_cli (Teensy).
Central serial port management. All I/O goes through SharedSerialManager in the daemon. Background reader tasks per port. Broadcast channel to readers, exclusive writer via condition variable. Deploy preemption protocol for flash → monitor handoff. See serial.md.
Exposes SerialMonitor, Daemon, DaemonConnection, connect_daemon to Python via PyO3. FastLED imports these for JSON-RPC communication with devices. See pyo3-bindings.md.
Parses platformio.ini with environment inheritance (extends = env:parent), variable substitution (${env:parent.key}), and board overrides.
URL-based package management. Downloads toolchains and libraries to ~/.fbuild/{dev|prod}/cache/. Parallel download pipeline with Docker pull-style TUI.
Single source of truth for all .fbuild paths. Respects FBUILD_DEV_MODE=1 for dev/prod isolation.