Repository navigation
RaftArchitecture
One-page overview of how a Raft application is structured at runtime: the boot sequence, the major subsystems, and how they reach each other. Use this page to orient yourself before drilling into individual subsystems.
┌──────────────────────────────────┐
│ Application (your main.cpp) │
│ ─ creates RaftCoreApp │
│ ─ registers SysMods │
│ ─ calls setup() / loop() │
└──────────────────────────────────┘
│
▼
┌──────────────────────────────────┐
│ RaftCoreApp │
│ ─ owns SysManager, FileSystem, │
│ ConfigBase, RestAPIEndpoints │
└──────────────────────────────────┘
│
▼
┌──────────────────────────────────┐
│ SysManager │
│ ─ orchestrates SysMod lifecycle│
│ ─ setup → addEndpoints → │
│ addCommsChannels → loop │
└──────────────────────────────────┘
│ │ │ │ │
┌─────────────────┘ │ │ │ └────────────────┐
▼ ▼ ▼ ▼ ▼
┌───────────────┐ ┌──────────────┐ ... ┌──────────────┐ ┌────────────────┐
│ Network / │ │ WebServer │ │ DeviceManager│ │ Your SysMods │
│ BLE / MQTT │ │ │ │ + I2C bus │ │ │
│ / Serial │ │ │ │ │ │ │
│ transports │ │ │ │ │ │ │
└───────┬───────┘ └──────┬───────┘ └──────┬───────┘ └───────┬────────┘
│ │ │ │
▼ ▼ ▼ ▼
┌───────────────────────────────────────────────────────────────────────────────────┐
│ CommsChannelManager (channels + protocol codecs) │
└───────────────────────────────────────────────────────────────────────────────────┘
│
▼
┌──────────────────────────────────┐
│ ProtocolExchange │
│ ─ decodes RICREST, dispatches │
│ URL/cmd to RestAPIEndpoints │
└──────────────────────────────────┘
│
▼
┌──────────────────────────────────┐
│ RestAPIEndpointManager │
│ ─ registry of REST endpoints │
│ ─ HTTP handlers also call here │
└──────────────────────────────────┘
RaftCoreApp::setup() drives this. Each step happens for every registered SysMod before moving to the next:
| Step | What happens |
|---|---|
| 1. Construct | Each SysMod's create() factory is invoked. The constructor stores the system config reference. |
2. setup()
|
Read JSON config, initialise hardware drivers, allocate buffers. |
3. addRestAPIEndpoints()
|
Register REST endpoints with the global RestAPIEndpointManager. |
4. addCommsChannels()
|
Register protocol codecs and channels with CommsCoreIF. |
5. postSetup()
|
Run anything that needs other SysMods to be fully wired (e.g. WebServer creates websocket channels here, since CommsCore is now ready). |
6. loop() repeatedly
|
Cooperative multitasking — each SysMod gets a slice on every iteration. |
Two consequences worth remembering:
- A SysMod's
setup()cannot rely on another SysMod's REST endpoints — they aren't registered yet. UsepostSetup()instead. - A SysMod's
setup()cannot register comms channels reliably — the codecs may not be added yet. UseaddCommsChannels().
Everything is driven by a single JSON document — the SysType — composed from:
- The compiled-in default SysType.
- Variant overrides (
systypes/<Variant>/SysType.json). - Non-volatile saved values (NVS).
- Runtime patches via the
sysconfigREST endpoint.
Each layer is layered on top of the previous via RaftJsonNVS / RaftJsonPrefixed. SysMods read their own subtree via configGet*().
See Configuration, SysTypes, Top-Level SysType.
A SysMod is a self-contained module with:
- A name and a JSON config slot inside the SysType.
- Lifecycle hooks (
setup,loop,addRestAPIEndpoints,addCommsChannels,postSetup). - Optional debug JSON (
getDebugJSON()) and busy-state (isBusy()).
Every Raft capability — networking, BLE, MQTT, file system, OTA, devices, your own code — is a SysMod. Built-in SysMods live in RaftSysMods.
See SysMods, SysManager, Writing Your First SysMod.
A layered model that lets a single REST endpoint serve any transport. Bottom to top:
- Transports (BLE, UART, sockets, websocket, MQTT) — each owned by its transport SysMod.
-
Channels (
CommsChannelManager) — register a transport, give it a name and a codec. -
Protocol codecs —
RICSerial(HDLC),RICFrame(length-prefixed),RICJSON(JSON-only). -
ProtocolExchange— decodes RICREST inner messages and dispatches. -
RestAPIEndpointManager— every endpoint registered by any SysMod, keyed on the first path segment.
See Communications Stack Overview.
DeviceManager is the SysMod that owns hardware buses (currently I2C; SPI and GPIO follow the same pattern). It scans, identifies, polls and publishes device data based on JSON device-type records. Other parts of the system can register as data sources or subscribe via the standard subscription endpoint.
See DeviceManager, I2C Bus, Device Type Record Format.
| Subsystem | Repo | Top-level folder |
|---|---|---|
RaftCoreApp, SysManager, base RaftSysMod, RaftJson, comms core, helpers |
RaftCore |
components/core/, components/comms/
|
| Built-in SysMods (BLE, Network, MQTT, FileManager, LogManager, OTA, command channels) | RaftSysMods | components/ |
| HTTP server, websocket and SSE handlers | RaftWebServer |
components/RaftWebServer/, components/WebServer/
|
| I2C bus and device infrastructure | RaftI2C | components/RaftI2C/ |
If you've just landed:
- Quick Start — run something.
- This page.
- SysMods — the abstraction every part of Raft is built on.
- Communications Stack Overview — how requests reach your code.
- Writing Your First SysMod — apply it.
Getting Started
- Quick Start
- Architecture at a Glance
- Writing Your First SysMod
- Adding a Comms Channel
- Adding an I2C Device Type
- PlatformIO / Arduino
Scaffolding & Building
- Raft CLI
- SysTypes
- Top-Level SysType
- Build Process
- WebUI Build Pipeline
- File System
- Partitions & Flash
- Local Dev Libraries
- Library Developer Guide
Architecture
Built-in SysMods
- NetworkManager
- WiFi Troubleshooting
- BLEManager
- WebServer
- MQTTManager
- SerialConsole
- CommandSerial
- CommandSocket
- CommandFile
- FileManager
- LogManager
- ESPOTAUpdate
- StatePublisher
- Remote Logging
- Data Source Registration
Comms & Protocols
- Stack Overview
- Comms Channels
- ProtocolExchange
- RICREST Protocol
- Real-Time Streams
- Adding REST Endpoints
- Built-in REST Endpoints
- File Download (OKTO)
- OTA Update Flow
Devices & Buses
- DeviceManager
- Device Manager REST API
- Device Factory & Classes
- Device Type Records
- Adding an I2C Device Type
- Device Data Publishing
- Data Logger
- I2C Bus
- I2C Device Scanning
- I2C ID & Polling
- MotorControl Overview
- MotorControl Config
- MotorControl Commands
ROS 2
Helpers
Reference