# lilicqyu-ship-it/esp32c6_car architecture

> Architecture diagram of the GitHub repository lilicqyu-ship-it/esp32c6_car, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/lilicqyu-ship-it/esp32c6_car
- Repository: https://github.com/lilicqyu-ship-it/esp32c6_car

## Overview

c6_car is ESP32-C6 network-coprocessor firmware for SmartDrive: it provides a softAP control surface and relays commands, telemetry, and TC275 firmware updates over SPI. The main workflow is client → HTTP/WebSocket and pairing → bridge → LINK/SF transport → TC275; self-firmware OTA is a separate web-triggered path. The README documents the main subsystem boundaries and optional BLE/TCP features; source excerpts and index references support several internal calls. HTTP routing and some subsystem wiring are unsampled, so uncertain links are omitted.

Main entry points: [`components/c6_http/http_server.c`](https://github.com/lilicqyu-ship-it/esp32c6_car/blob/main/components/c6_http/http_server.c) (HTTP and WS), [`components/c6_link/link.c`](https://github.com/lilicqyu-ship-it/esp32c6_car/blob/main/components/c6_link/link.c) (SPI LINK), [`main/app_main.c`](https://github.com/lilicqyu-ship-it/esp32c6_car/blob/main/main/app_main.c) (Startup and State), [`components/c6_bridge/bridge.c`](https://github.com/lilicqyu-ship-it/esp32c6_car/blob/main/components/c6_bridge/bridge.c) (Command and OTA Bridge)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client Surface"]
  node_webui["Control UI<br/>[app.js]"]
  node_http["HTTP and WS<br/>[http_server.c]"]
  node_assets["Assets Service<br/>[assets_store.c]"]
  node_sessions["WS Sessions<br/>[ws_sessions.c]"]
end

subgraph group_session["Sessions and Control"]
  node_pair["Pairing and Tokens<br/>[pair.c]"]
  node_bridge["Command and OTA Bridge<br/>[bridge.c]"]
end

subgraph group_transport["Board Transport"]
  node_proto["Protocol v2 Codec<br/>[proto_frames.c]"]
  node_link["SPI LINK<br/>[link.c]"]
  node_sf["SF Frame Codec<br/>[sf_frame.c]"]
  node_legacy["Legacy TCP Bridge<br/>[legacy_tcp.c]"]
end

subgraph group_device["Device Services"]
  node_network["SoftAP and Discovery<br/>[net.c]"]
  node_factory[("Factory NVS<br/>[factory.c]")]
  node_app["Startup and State<br/>[app_main.c]"]
  node_diagnostics["Diagnostics<br/>[app_state.c]"]
  node_accelerometer["ADXL345 Sensor<br/>[adxl345.c]"]
  node_ble["Maintenance BLE<br/>[maint_ble.c]"]
end

subgraph group_updates["Firmware Updates"]
  node_ota_http["C6 A/B OTA<br/>[ota_self.c]"]
  node_bundle["Bundle Parser<br/>[bundle.c]"]
  node_signature["Ed25519 Verification<br/>[ed25519v.c]"]
end

node_phone(("Phone Browser"))
node_remote(("S3 Remote"))
node_tc275(("TC275 Controller"))

node_phone -->|"uses"| node_webui
node_remote -->|"connects"| node_http
node_webui -->|"sends control"| node_http
node_http -.->|"serves assets"| node_assets
node_http -.->|"tracks sessions"| node_sessions
node_http -.->|"requests pairing"| node_pair
node_http -.->|"routes OTA"| node_ota_http
node_pair -->|"persists grace"| node_factory
node_pair -->|"frames requests"| node_proto
node_bridge -->|"sends and receives"| node_link
node_bridge -->|"routes pair frames"| node_pair
node_bridge -->|"broadcasts frames"| node_http
node_link -->|"encodes segments"| node_sf
node_link -->|"maps frames"| node_proto
node_tc275 -->|"exchanges SPI"| node_link
node_app -->|"starts"| node_network
node_app -->|"initializes"| node_factory
node_app -->|"initializes"| node_link
node_app -->|"starts"| node_bridge
node_app -->|"starts"| node_http
node_app -->|"initializes"| node_pair
node_app -->|"starts"| node_accelerometer
node_diagnostics -->|"reads health"| node_link
node_diagnostics -->|"renders readings"| node_accelerometer
node_ota_http -->|"parses bundle"| node_bundle
node_bundle -.->|"verifies signature"| node_signature
node_bridge -->|"relays firmware"| node_tc275
node_ble -->|"uses LINK"| node_link
node_legacy -->|"forwards traffic"| node_link

click node_webui "https://github.com/lilicqyu-ship-it/esp32c6_car/blob/main/assets_src/app.js"
click node_http "https://github.com/lilicqyu-ship-it/esp32c6_car/blob/main/components/c6_http/http_server.c"
click node_assets "https://github.com/lilicqyu-ship-it/esp32c6_car/blob/main/components/c6_http/assets_store.c"
click node_sessions "https://github.com/lilicqyu-ship-it/esp32c6_car/blob/main/components/c6_http/ws_sessions.c"
click node_pair "https://github.com/lilicqyu-ship-it/esp32c6_car/blob/main/components/c6_pair/pair.c"
click node_bridge "https://github.com/lilicqyu-ship-it/esp32c6_car/blob/main/components/c6_bridge/bridge.c"
click node_proto "https://github.com/lilicqyu-ship-it/esp32c6_car/blob/main/components/c6_proto/proto_frames.c"
click node_link "https://github.com/lilicqyu-ship-it/esp32c6_car/blob/main/components/c6_link/link.c"
click node_sf "https://github.com/lilicqyu-ship-it/esp32c6_car/blob/main/components/c6_sf/sf_frame.c"
click node_network "https://github.com/lilicqyu-ship-it/esp32c6_car/blob/main/components/c6_net/net.c"
click node_factory "https://github.com/lilicqyu-ship-it/esp32c6_car/blob/main/components/c6_factory/factory.c"
click node_app "https://github.com/lilicqyu-ship-it/esp32c6_car/blob/main/main/app_main.c"
click node_diagnostics "https://github.com/lilicqyu-ship-it/esp32c6_car/blob/main/main/app_state.c"
click node_accelerometer "https://github.com/lilicqyu-ship-it/esp32c6_car/blob/main/components/c6_adxl345/adxl345.c"
click node_ota_http "https://github.com/lilicqyu-ship-it/esp32c6_car/blob/main/components/c6_ota/ota_self.c"
click node_bundle "https://github.com/lilicqyu-ship-it/esp32c6_car/blob/main/components/c6_ota/bundle.c"
click node_signature "https://github.com/lilicqyu-ship-it/esp32c6_car/blob/main/components/c6_ota/ed25519v.c"
click node_ble "https://github.com/lilicqyu-ship-it/esp32c6_car/blob/main/components/c6_maint/maint_ble.c"
click node_legacy "https://github.com/lilicqyu-ship-it/esp32c6_car/blob/main/components/c6_legacy/legacy_tcp.c"

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_webui,node_http,node_assets,node_sessions,node_phone toneBlue
class node_pair,node_bridge toneAmber
class node_proto,node_link,node_sf,node_legacy toneMint
class node_network,node_factory,node_app,node_diagnostics,node_accelerometer,node_ble toneRose
class node_ota_http,node_bundle,node_signature,node_remote,node_tc275 toneIndigo
```

## Components

### Client Surface

- [Control UI](https://github.com/lilicqyu-ship-it/esp32c6_car/blob/main/assets_src/app.js): `assets_src/app.js`
- [HTTP and WS](https://github.com/lilicqyu-ship-it/esp32c6_car/blob/main/components/c6_http/http_server.c): `components/c6_http/http_server.c`
- [Assets Service](https://github.com/lilicqyu-ship-it/esp32c6_car/blob/main/components/c6_http/assets_store.c): `components/c6_http/assets_store.c`
- [WS Sessions](https://github.com/lilicqyu-ship-it/esp32c6_car/blob/main/components/c6_http/ws_sessions.c): `components/c6_http/ws_sessions.c`

### Sessions and Control

- [Pairing and Tokens](https://github.com/lilicqyu-ship-it/esp32c6_car/blob/main/components/c6_pair/pair.c): `components/c6_pair/pair.c`
- [Command and OTA Bridge](https://github.com/lilicqyu-ship-it/esp32c6_car/blob/main/components/c6_bridge/bridge.c): `components/c6_bridge/bridge.c`

### Board Transport

- [Protocol v2 Codec](https://github.com/lilicqyu-ship-it/esp32c6_car/blob/main/components/c6_proto/proto_frames.c): `components/c6_proto/proto_frames.c`
- [SPI LINK](https://github.com/lilicqyu-ship-it/esp32c6_car/blob/main/components/c6_link/link.c): `components/c6_link/link.c`
- [SF Frame Codec](https://github.com/lilicqyu-ship-it/esp32c6_car/blob/main/components/c6_sf/sf_frame.c): `components/c6_sf/sf_frame.c`
- [Legacy TCP Bridge](https://github.com/lilicqyu-ship-it/esp32c6_car/blob/main/components/c6_legacy/legacy_tcp.c): `components/c6_legacy/legacy_tcp.c`

### Device Services

- [SoftAP and Discovery](https://github.com/lilicqyu-ship-it/esp32c6_car/blob/main/components/c6_net/net.c): `components/c6_net/net.c`
- [Factory NVS](https://github.com/lilicqyu-ship-it/esp32c6_car/blob/main/components/c6_factory/factory.c): `components/c6_factory/factory.c`
- [Startup and State](https://github.com/lilicqyu-ship-it/esp32c6_car/blob/main/main/app_main.c): `main/app_main.c`
- [Diagnostics](https://github.com/lilicqyu-ship-it/esp32c6_car/blob/main/main/app_state.c): `main/app_state.c`
- [ADXL345 Sensor](https://github.com/lilicqyu-ship-it/esp32c6_car/blob/main/components/c6_adxl345/adxl345.c): `components/c6_adxl345/adxl345.c`
- [Maintenance BLE](https://github.com/lilicqyu-ship-it/esp32c6_car/blob/main/components/c6_maint/maint_ble.c): `components/c6_maint/maint_ble.c`

### Firmware Updates

- [C6 A/B OTA](https://github.com/lilicqyu-ship-it/esp32c6_car/blob/main/components/c6_ota/ota_self.c): `components/c6_ota/ota_self.c`
- [Bundle Parser](https://github.com/lilicqyu-ship-it/esp32c6_car/blob/main/components/c6_ota/bundle.c): `components/c6_ota/bundle.c`
- [Ed25519 Verification](https://github.com/lilicqyu-ship-it/esp32c6_car/blob/main/components/c6_ota/ed25519v.c): `components/c6_ota/ed25519v.c`

### Other components

- **Phone Browser**
- **S3 Remote**
- **TC275 Controller**

## Connections

- Phone Browser → Control UI: uses (evidence: `README.md`)
- S3 Remote → HTTP and WS: connects (evidence: `README.md`)
- Control UI → HTTP and WS: sends control (evidence: `README.md`)
- HTTP and WS → Assets Service: serves assets
- HTTP and WS → WS Sessions: tracks sessions
- HTTP and WS → Pairing and Tokens: requests pairing
- HTTP and WS → C6 A/B OTA: routes OTA
- Pairing and Tokens → Factory NVS: persists grace (evidence: `components/c6_pair/pair.c`)
- Pairing and Tokens → Protocol v2 Codec: frames requests (evidence: `components/c6_pair/pair.c`)
- Command and OTA Bridge → SPI LINK: sends and receives (evidence: `components/c6_bridge/bridge.c`)
- Command and OTA Bridge → Pairing and Tokens: routes pair frames (evidence: `components/c6_bridge/bridge.c`)
- Command and OTA Bridge → HTTP and WS: broadcasts frames (evidence: `components/c6_bridge/bridge.c`)
- SPI LINK → SF Frame Codec: encodes segments (evidence: `components/c6_link/link.c`)
- SPI LINK → Protocol v2 Codec: maps frames (evidence: `components/c6_link/link.c`)
- TC275 Controller → SPI LINK: exchanges SPI (evidence: `README.md`)
- Startup and State → SoftAP and Discovery: starts (evidence: `README.md`)
- Startup and State → Factory NVS: initializes (evidence: `README.md`)
- Startup and State → SPI LINK: initializes (evidence: `README.md`)
- Startup and State → Command and OTA Bridge: starts (evidence: `README.md`)
- Startup and State → HTTP and WS: starts (evidence: `README.md`)
- Startup and State → Pairing and Tokens: initializes (evidence: `README.md`)
- Startup and State → ADXL345 Sensor: starts (evidence: `main/app_main.c`)
- Diagnostics → SPI LINK: reads health (evidence: `main/app_state.c`)
- Diagnostics → ADXL345 Sensor: renders readings (evidence: `main/app_state.c`)
- C6 A/B OTA → Bundle Parser: parses bundle (evidence: `components/c6_ota/ota_self.c`)
- Bundle Parser → Ed25519 Verification: verifies signature
- Command and OTA Bridge → TC275 Controller: relays firmware (evidence: `README.md`)
- Maintenance BLE → SPI LINK: uses LINK (evidence: `components/c6_maint/maint_ble.c`)
- Legacy TCP Bridge → SPI LINK: forwards traffic (evidence: `components/c6_legacy/legacy_tcp.c`)
