# mohamed-soubhi/bootlab-esp architecture

> Architecture diagram of the GitHub repository mohamed-soubhi/bootlab-esp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mohamed-soubhi/bootlab-esp
- Repository: https://github.com/mohamed-soubhi/bootlab-esp

## Overview

bootlab-esp is a dual-OS ESP32-S3 firmware and resilient-OTA testbed, with a host CLI and hardware-in-the-loop operations tooling. The primary workflow is to identify a board, build or select a signed image, deliver it over BLE, HTTPS, or MCUmgr, then verify the running slot and confirmation state. Firmware shares LABID framing across IDF and Zephyr; each OS has its own OTA and rollback mechanisms. HIL soak tools exercise recovery behavior, while the dashboard exposes operational commands. Some firmware and transport implementations are unsampled, so those links rely on documented capabilities rather than inspected call sites.

Main entry points: [`host/labflash/__main__.py`](https://github.com/mohamed-soubhi/bootlab-esp/blob/master/host/labflash/__main__.py) (labflash CLI), [`host/labflash/update_cli.py`](https://github.com/mohamed-soubhi/bootlab-esp/blob/master/host/labflash/update_cli.py) (Update Adapters), [`tests_hil/live_backend.py`](https://github.com/mohamed-soubhi/bootlab-esp/blob/master/tests_hil/live_backend.py) (Live HIL Backend), [`common/labid/src/labid_dispatch.c`](https://github.com/mohamed-soubhi/bootlab-esp/blob/master/common/labid/src/labid_dispatch.c) (Request Dispatcher)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_protocol["Shared LABID Protocol"]
  node_engine["Frame Engine<br/>[labid.c]"]
  node_dispatch["Request Dispatcher<br/>[labid_dispatch.c]"]
end

subgraph group_idf["ESP-IDF Firmware"]
  node_idf_app["IDF App<br/>[app_main.c]"]
  node_idf_port["IDF LABID Port<br/>[labid_port.c]"]
  node_idf_ble["IDF BLE OTA<br/>[app_ble_ota.c]"]
  node_idf_http["IDF HTTPS OTA<br/>[app_http_server.c]"]
  node_idf_wifi["IDF WiFi<br/>[app_wifi.c]"]
end

subgraph group_zephyr["Zephyr Firmware"]
  node_zephyr_app["Zephyr App<br/>[main.c]"]
  node_zephyr_port["Zephyr LABID Port"]
  node_zephyr_ble["Zephyr BLE SMP<br/>[app_ble_smp.c]"]
  node_zephyr_wifi["Zephyr WiFi SMP<br/>[app_wifi.c]"]
end

subgraph group_host["Host Management"]
  node_cli["labflash CLI<br/>[__main__.py]"]
  node_board_resolve["Board Resolution<br/>[core.py]"]
  node_identify["Board Identity<br/>[identify.py]"]
  node_build["Build and Signing<br/>[build.py]"]
  node_pool["Image Pool<br/>[poolmanifest.py]"]
  node_update_cli["Update Adapters<br/>[update_cli.py]"]
  node_update["Update Verification<br/>[update.py]"]
end

subgraph group_operations["HIL and Operations"]
  node_hil_backend["Live HIL Backend<br/>[live_backend.py]"]
  node_soak["Randomized OTA Soak<br/>[soak_random.py]"]
  node_dashboard["Operations Dashboard<br/>[server.py]"]
  node_registry["Tool Registry<br/>[tools_registry.py]"]
  node_runner["Process Runner<br/>[runner.py]"]
end

node_user(("Lab Engineer"))
node_device["ESP32-S3 Board"]

node_dispatch -->|"parses frames"| node_engine
node_idf_app -->|"starts port"| node_idf_port
node_idf_port -->|"dispatches bytes"| node_dispatch
node_zephyr_app -->|"initializes port"| node_zephyr_port
node_zephyr_port -->|"dispatches bytes"| node_dispatch
node_user -->|"runs commands"| node_cli
node_cli -->|"resolves board"| node_board_resolve
node_cli -->|"queries identity"| node_identify
node_cli -->|"builds images"| node_build
node_cli -->|"manages pool"| node_pool
node_cli -->|"starts update"| node_update_cli
node_update_cli -->|"orchestrates"| node_update
node_update_cli -->|"sends OTA"| node_device
node_update -->|"verifies result"| node_device
node_device -.->|"receives BLE OTA"| node_idf_ble
node_device -.->|"receives HTTPS OTA"| node_idf_http
node_device -.->|"receives BLE SMP"| node_zephyr_ble
node_device -.->|"receives UDP SMP"| node_zephyr_wifi
node_device -.->|"uses WiFi"| node_idf_wifi
node_soak -->|"uses backend"| node_hil_backend
node_hil_backend -->|"calls update APIs"| node_update
node_hil_backend -->|"tests target"| node_device
node_user -->|"operates lab"| node_dashboard
node_dashboard -->|"starts jobs"| node_runner
node_runner -->|"builds commands"| node_registry

click node_engine "https://github.com/mohamed-soubhi/bootlab-esp/blob/master/common/labid/src/labid.c"
click node_dispatch "https://github.com/mohamed-soubhi/bootlab-esp/blob/master/common/labid/src/labid_dispatch.c"
click node_idf_app "https://github.com/mohamed-soubhi/bootlab-esp/blob/master/esp_idf/main/app_main.c"
click node_idf_port "https://github.com/mohamed-soubhi/bootlab-esp/blob/master/esp_idf/components/labid_port/labid_port.c"
click node_idf_ble "https://github.com/mohamed-soubhi/bootlab-esp/blob/master/esp_idf/main/app_ble_ota.c"
click node_idf_http "https://github.com/mohamed-soubhi/bootlab-esp/blob/master/esp_idf/main/app_http_server.c"
click node_idf_wifi "https://github.com/mohamed-soubhi/bootlab-esp/blob/master/esp_idf/main/app_wifi.c"
click node_zephyr_app "https://github.com/mohamed-soubhi/bootlab-esp/blob/master/esp_zephyr/app/src/main.c"
click node_zephyr_port "https://github.com/mohamed-soubhi/bootlab-esp/blob/master/esp_zephyr/app/src/labid_port_zephyr.c"
click node_zephyr_ble "https://github.com/mohamed-soubhi/bootlab-esp/blob/master/esp_zephyr/app/src/app_ble_smp.c"
click node_zephyr_wifi "https://github.com/mohamed-soubhi/bootlab-esp/blob/master/esp_zephyr/app/src/app_wifi.c"
click node_cli "https://github.com/mohamed-soubhi/bootlab-esp/blob/master/host/labflash/__main__.py"
click node_board_resolve "https://github.com/mohamed-soubhi/bootlab-esp/blob/master/host/labflash/core.py"
click node_identify "https://github.com/mohamed-soubhi/bootlab-esp/blob/master/host/labflash/identify.py"
click node_build "https://github.com/mohamed-soubhi/bootlab-esp/blob/master/host/labflash/build.py"
click node_pool "https://github.com/mohamed-soubhi/bootlab-esp/blob/master/host/labflash/poolmanifest.py"
click node_update_cli "https://github.com/mohamed-soubhi/bootlab-esp/blob/master/host/labflash/update_cli.py"
click node_update "https://github.com/mohamed-soubhi/bootlab-esp/blob/master/host/labflash/update.py"
click node_hil_backend "https://github.com/mohamed-soubhi/bootlab-esp/blob/master/tests_hil/live_backend.py"
click node_soak "https://github.com/mohamed-soubhi/bootlab-esp/blob/master/tests_hil/soak_random.py"
click node_dashboard "https://github.com/mohamed-soubhi/bootlab-esp/blob/master/tools/dashboard/server.py"
click node_registry "https://github.com/mohamed-soubhi/bootlab-esp/blob/master/tools/dashboard/tools_registry.py"
click node_runner "https://github.com/mohamed-soubhi/bootlab-esp/blob/master/tools/dashboard/runner.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_engine,node_dispatch toneBlue
class node_idf_app,node_idf_port,node_idf_ble,node_idf_http,node_idf_wifi toneAmber
class node_zephyr_app,node_zephyr_port,node_zephyr_ble,node_zephyr_wifi toneMint
class node_cli,node_board_resolve,node_identify,node_build,node_pool,node_update_cli,node_update toneRose
class node_hil_backend,node_soak,node_dashboard,node_registry,node_runner,node_user,node_device toneIndigo
```

## Components

### Shared LABID Protocol

- [Frame Engine](https://github.com/mohamed-soubhi/bootlab-esp/blob/master/common/labid/src/labid.c): `common/labid/src/labid.c`
- [Request Dispatcher](https://github.com/mohamed-soubhi/bootlab-esp/blob/master/common/labid/src/labid_dispatch.c): `common/labid/src/labid_dispatch.c`

### ESP-IDF Firmware

- [IDF App](https://github.com/mohamed-soubhi/bootlab-esp/blob/master/esp_idf/main/app_main.c): `esp_idf/main/app_main.c`
- [IDF LABID Port](https://github.com/mohamed-soubhi/bootlab-esp/blob/master/esp_idf/components/labid_port/labid_port.c): `esp_idf/components/labid_port/labid_port.c`
- [IDF BLE OTA](https://github.com/mohamed-soubhi/bootlab-esp/blob/master/esp_idf/main/app_ble_ota.c): `esp_idf/main/app_ble_ota.c`
- [IDF HTTPS OTA](https://github.com/mohamed-soubhi/bootlab-esp/blob/master/esp_idf/main/app_http_server.c): `esp_idf/main/app_http_server.c`
- [IDF WiFi](https://github.com/mohamed-soubhi/bootlab-esp/blob/master/esp_idf/main/app_wifi.c): `esp_idf/main/app_wifi.c`

### Zephyr Firmware

- [Zephyr App](https://github.com/mohamed-soubhi/bootlab-esp/blob/master/esp_zephyr/app/src/main.c): `esp_zephyr/app/src/main.c`
- [Zephyr LABID Port](https://github.com/mohamed-soubhi/bootlab-esp/blob/master/esp_zephyr/app/src/labid_port_zephyr.c): `esp_zephyr/app/src/labid_port_zephyr.c`
- [Zephyr BLE SMP](https://github.com/mohamed-soubhi/bootlab-esp/blob/master/esp_zephyr/app/src/app_ble_smp.c): `esp_zephyr/app/src/app_ble_smp.c`
- [Zephyr WiFi SMP](https://github.com/mohamed-soubhi/bootlab-esp/blob/master/esp_zephyr/app/src/app_wifi.c): `esp_zephyr/app/src/app_wifi.c`

### Host Management

- [labflash CLI](https://github.com/mohamed-soubhi/bootlab-esp/blob/master/host/labflash/__main__.py): `host/labflash/__main__.py`
- [Board Resolution](https://github.com/mohamed-soubhi/bootlab-esp/blob/master/host/labflash/core.py): `host/labflash/core.py`
- [Board Identity](https://github.com/mohamed-soubhi/bootlab-esp/blob/master/host/labflash/identify.py): `host/labflash/identify.py`
- [Build and Signing](https://github.com/mohamed-soubhi/bootlab-esp/blob/master/host/labflash/build.py): `host/labflash/build.py`
- [Image Pool](https://github.com/mohamed-soubhi/bootlab-esp/blob/master/host/labflash/poolmanifest.py): `host/labflash/poolmanifest.py`
- [Update Adapters](https://github.com/mohamed-soubhi/bootlab-esp/blob/master/host/labflash/update_cli.py): `host/labflash/update_cli.py`
- [Update Verification](https://github.com/mohamed-soubhi/bootlab-esp/blob/master/host/labflash/update.py): `host/labflash/update.py`

### HIL and Operations

- [Live HIL Backend](https://github.com/mohamed-soubhi/bootlab-esp/blob/master/tests_hil/live_backend.py): `tests_hil/live_backend.py`
- [Randomized OTA Soak](https://github.com/mohamed-soubhi/bootlab-esp/blob/master/tests_hil/soak_random.py): `tests_hil/soak_random.py`
- [Operations Dashboard](https://github.com/mohamed-soubhi/bootlab-esp/blob/master/tools/dashboard/server.py): `tools/dashboard/server.py`
- [Tool Registry](https://github.com/mohamed-soubhi/bootlab-esp/blob/master/tools/dashboard/tools_registry.py): `tools/dashboard/tools_registry.py`
- [Process Runner](https://github.com/mohamed-soubhi/bootlab-esp/blob/master/tools/dashboard/runner.py): `tools/dashboard/runner.py`

### Other components

- **Lab Engineer**
- **ESP32-S3 Board**

## Connections

- Request Dispatcher → Frame Engine: parses frames (evidence: `common/labid/src/labid_dispatch.c`)
- IDF App → IDF LABID Port: starts port (evidence: `esp_idf/main/app_main.c`)
- IDF LABID Port → Request Dispatcher: dispatches bytes (evidence: `esp_idf/components/labid_port/labid_port.c`)
- Zephyr App → Zephyr LABID Port: initializes port (evidence: `esp_zephyr/app/src/main.c`)
- Zephyr LABID Port → Request Dispatcher: dispatches bytes (evidence: `esp_zephyr/app/src/labid_port_zephyr.c`)
- Lab Engineer → labflash CLI: runs commands (evidence: `host/labflash/__main__.py`)
- labflash CLI → Board Resolution: resolves board (evidence: `host/labflash/__main__.py`)
- labflash CLI → Board Identity: queries identity (evidence: `host/labflash/__main__.py`)
- labflash CLI → Build and Signing: builds images (evidence: `host/labflash/__main__.py`)
- labflash CLI → Image Pool: manages pool (evidence: `host/labflash/__main__.py`)
- labflash CLI → Update Adapters: starts update (evidence: `host/labflash/__main__.py`)
- Update Adapters → Update Verification: orchestrates (evidence: `host/labflash/update_cli.py`)
- Update Adapters → ESP32-S3 Board: sends OTA (evidence: `README.md`)
- Update Verification → ESP32-S3 Board: verifies result (evidence: `README.md`)
- ESP32-S3 Board → IDF BLE OTA: receives BLE OTA (evidence: `README.md`)
- ESP32-S3 Board → IDF HTTPS OTA: receives HTTPS OTA (evidence: `README.md`)
- ESP32-S3 Board → Zephyr BLE SMP: receives BLE SMP (evidence: `README.md`)
- ESP32-S3 Board → Zephyr WiFi SMP: receives UDP SMP (evidence: `README.md`)
- ESP32-S3 Board → IDF WiFi: uses WiFi (evidence: `README.md`)
- Randomized OTA Soak → Live HIL Backend: uses backend (evidence: `tests_hil/soak_random.py`)
- Live HIL Backend → Update Verification: calls update APIs (evidence: `tests_hil/live_backend.py`)
- Live HIL Backend → ESP32-S3 Board: tests target (evidence: `README.md`)
- Lab Engineer → Operations Dashboard: operates lab (evidence: `tools/dashboard/server.py`)
- Operations Dashboard → Process Runner: starts jobs (evidence: `tools/dashboard/server.py`)
- Process Runner → Tool Registry: builds commands (evidence: `tools/dashboard/runner.py`)
