# forbes-automotive/openhaldex-c6 architecture

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

- Interactive diagram: https://gitdiagram.com/forbes-automotive/openhaldex-c6
- Repository: https://github.com/forbes-automotive/openhaldex-c6
- Video tour (about a minute): https://gitdiagram.com/forbes-automotive/openhaldex-c6/video

## Overview

OpenHaldex is ESP32-C6 firmware that sits between a vehicle and its Haldex differential. Vehicle CAN signals drive configured modes and lock calculations; the firmware then relays or generates CAN commands. Users configure and inspect it through the web UI, with Bluetooth, diagnostics, wireless updates, and gauge relay as additional capabilities. The graph preserves README-documented capabilities; where sampled code does not expose runtime wiring, it omits those links rather than inferring calls.

Main entry points: [`src/OpenHaldexC6_can.cpp`](https://github.com/forbes-automotive/openhaldex-c6/blob/main/src/OpenHaldexC6_can.cpp) (CAN interfaces), [`src/OpenHaldexC6_Calculations.cpp`](https://github.com/forbes-automotive/openhaldex-c6/blob/main/src/OpenHaldexC6_Calculations.cpp) (Mode and lock calculations), [`src/OpenHaldexC6_WiFi.cpp`](https://github.com/forbes-automotive/openhaldex-c6/blob/main/src/OpenHaldexC6_WiFi.cpp) (Wi-Fi access and bridge), [`src/OpenHaldexC6_tasks.cpp`](https://github.com/forbes-automotive/openhaldex-c6/blob/main/src/OpenHaldexC6_tasks.cpp) (Learning and background tasks)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_control["Vehicle control"]
  node_can["CAN interfaces"]
  node_chassis["Chassis decoding"]
  node_calculations["Mode and lock calculations"]
  node_standalone["Standalone CAN generation"]
  node_tasks["Learning and background tasks"]
end

subgraph group_access["Configuration and access"]
  node_ui["Web configuration and diagnostics<br/>[app.js]"]
  node_api["HTTP API"]
  node_settings["Settings persistence"]
  node_storage[("EEPROM settings store")]
end

subgraph group_connectivity["Diagnostics and connectivity"]
  node_wifi["Wi-Fi access and bridge"]
  node_ble["Bluetooth LE"]
  node_ota["Wireless updates"]
  node_analyzer["CAN analyzer bridge"]
  node_uds["UDS and TP2 diagnostics"]
  node_espnow["Gauge frame relay"]
end

subgraph group_runtime["Firmware runtime"]
  node_io["Buttons and outputs"]
  node_boot["Firmware startup<br/>[main.cpp]"]
  node_globals["Shared firmware state"]
  node_definitions["Controller definitions"]
  node_version["Firmware version metadata<br/>[OpenHaldexC6_ver.h]"]
end

node_driver(("Driver"))
node_vehicle{{"Vehicle CAN networks"}}
node_haldex{{"Haldex differential"}}

node_driver -->|"configures"| node_ui
node_ui -->|"sends settings"| node_api
node_vehicle -->|"sends CAN signals"| node_can
node_can -->|"bridges CAN traffic"| node_vehicle
node_vehicle -->|"provides chassis signals"| node_chassis
node_vehicle -->|"provides OEM signals"| node_calculations
node_calculations -->|"modifies lock requests"| node_haldex
node_standalone -->|"generates CAN commands"| node_haldex
node_driver -->|"uses controls"| node_io
node_api -.->|"applies settings"| node_settings
node_settings -.->|"persists settings"| node_storage
node_driver -->|"uses phone app"| node_ble
node_driver -->|"configures device"| node_wifi
node_wifi -->|"supports updates"| node_ota
node_can -->|"exposes CAN traffic"| node_analyzer
node_haldex -->|"provides diagnostic data"| node_uds
node_can -->|"relays CAN frames"| node_espnow
node_boot -->|"starts Wi-Fi"| node_wifi
node_boot -->|"stops relay during reset"| node_espnow
node_tasks -->|"uses CAN generation"| node_standalone
node_tasks -->|"uses calculations"| node_calculations

click node_can "https://github.com/forbes-automotive/openhaldex-c6/blob/main/src/OpenHaldexC6_can.cpp"
click node_chassis "https://github.com/forbes-automotive/openhaldex-c6/blob/main/src/OpenHaldexC6_ChassisOther.cpp"
click node_calculations "https://github.com/forbes-automotive/openhaldex-c6/blob/main/src/OpenHaldexC6_Calculations.cpp"
click node_standalone "https://github.com/forbes-automotive/openhaldex-c6/blob/main/src/OpenHaldexC6_StandaloneCAN.cpp"
click node_tasks "https://github.com/forbes-automotive/openhaldex-c6/blob/main/src/OpenHaldexC6_tasks.cpp"
click node_ui "https://github.com/forbes-automotive/openhaldex-c6/blob/main/data/app.js"
click node_api "https://github.com/forbes-automotive/openhaldex-c6/blob/main/src/OpenHaldexC6_API.cpp"
click node_settings "https://github.com/forbes-automotive/openhaldex-c6/blob/main/src/OpenHaldexC6_Settings.cpp"
click node_storage "https://github.com/forbes-automotive/openhaldex-c6/blob/main/src/OpenHaldexC6_EEP.cpp"
click node_wifi "https://github.com/forbes-automotive/openhaldex-c6/blob/main/src/OpenHaldexC6_WiFi.cpp"
click node_ble "https://github.com/forbes-automotive/openhaldex-c6/blob/main/src/OpenHaldexC6_BLE.cpp"
click node_ota "https://github.com/forbes-automotive/openhaldex-c6/blob/main/src/OpenHaldexC6_OTA.cpp"
click node_analyzer "https://github.com/forbes-automotive/openhaldex-c6/blob/main/src/OpenHaldexC6_Analyzer.cpp"
click node_uds "https://github.com/forbes-automotive/openhaldex-c6/blob/main/src/OpenHaldexC6_UDS.cpp"
click node_espnow "https://github.com/forbes-automotive/openhaldex-c6/blob/main/src/OpenHaldexC6_ESPNow.cpp"
click node_io "https://github.com/forbes-automotive/openhaldex-c6/blob/main/src/OpenHaldexC6_IO.cpp"
click node_boot "https://github.com/forbes-automotive/openhaldex-c6/blob/main/src/main.cpp"
click node_globals "https://github.com/forbes-automotive/openhaldex-c6/blob/main/src/OpenHaldexC6_globals.cpp"
click node_definitions "https://github.com/forbes-automotive/openhaldex-c6/blob/main/include/OpenHaldexC6_defs.h"
click node_version "https://github.com/forbes-automotive/openhaldex-c6/blob/main/include/OpenHaldexC6_ver.h"

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_can,node_chassis,node_calculations,node_standalone,node_tasks toneBlue
class node_ui,node_api,node_settings,node_storage toneAmber
class node_wifi,node_ble,node_ota,node_analyzer,node_uds,node_espnow toneMint
class node_io,node_boot,node_globals,node_definitions,node_version toneRose
class node_driver,node_vehicle,node_haldex toneIndigo
```

## Components

### Vehicle control

- [CAN interfaces](https://github.com/forbes-automotive/openhaldex-c6/blob/main/src/OpenHaldexC6_can.cpp): `src/OpenHaldexC6_can.cpp`
- [Chassis decoding](https://github.com/forbes-automotive/openhaldex-c6/blob/main/src/OpenHaldexC6_ChassisOther.cpp): `src/OpenHaldexC6_ChassisOther.cpp`
- [Mode and lock calculations](https://github.com/forbes-automotive/openhaldex-c6/blob/main/src/OpenHaldexC6_Calculations.cpp): `src/OpenHaldexC6_Calculations.cpp`
- [Standalone CAN generation](https://github.com/forbes-automotive/openhaldex-c6/blob/main/src/OpenHaldexC6_StandaloneCAN.cpp): `src/OpenHaldexC6_StandaloneCAN.cpp`
- [Learning and background tasks](https://github.com/forbes-automotive/openhaldex-c6/blob/main/src/OpenHaldexC6_tasks.cpp): `src/OpenHaldexC6_tasks.cpp`

### Configuration and access

- [Web configuration and diagnostics](https://github.com/forbes-automotive/openhaldex-c6/blob/main/data/app.js): `data/app.js`
- [HTTP API](https://github.com/forbes-automotive/openhaldex-c6/blob/main/src/OpenHaldexC6_API.cpp): `src/OpenHaldexC6_API.cpp`
- [Settings persistence](https://github.com/forbes-automotive/openhaldex-c6/blob/main/src/OpenHaldexC6_Settings.cpp): `src/OpenHaldexC6_Settings.cpp`
- [EEPROM settings store](https://github.com/forbes-automotive/openhaldex-c6/blob/main/src/OpenHaldexC6_EEP.cpp): `src/OpenHaldexC6_EEP.cpp`

### Diagnostics and connectivity

- [Wi-Fi access and bridge](https://github.com/forbes-automotive/openhaldex-c6/blob/main/src/OpenHaldexC6_WiFi.cpp): `src/OpenHaldexC6_WiFi.cpp`
- [Bluetooth LE](https://github.com/forbes-automotive/openhaldex-c6/blob/main/src/OpenHaldexC6_BLE.cpp): `src/OpenHaldexC6_BLE.cpp`
- [Wireless updates](https://github.com/forbes-automotive/openhaldex-c6/blob/main/src/OpenHaldexC6_OTA.cpp): `src/OpenHaldexC6_OTA.cpp`
- [CAN analyzer bridge](https://github.com/forbes-automotive/openhaldex-c6/blob/main/src/OpenHaldexC6_Analyzer.cpp): `src/OpenHaldexC6_Analyzer.cpp`
- [UDS and TP2 diagnostics](https://github.com/forbes-automotive/openhaldex-c6/blob/main/src/OpenHaldexC6_UDS.cpp): `src/OpenHaldexC6_UDS.cpp`
- [Gauge frame relay](https://github.com/forbes-automotive/openhaldex-c6/blob/main/src/OpenHaldexC6_ESPNow.cpp): `src/OpenHaldexC6_ESPNow.cpp`

### Firmware runtime

- [Buttons and outputs](https://github.com/forbes-automotive/openhaldex-c6/blob/main/src/OpenHaldexC6_IO.cpp): `src/OpenHaldexC6_IO.cpp`
- [Firmware startup](https://github.com/forbes-automotive/openhaldex-c6/blob/main/src/main.cpp): `src/main.cpp`
- [Shared firmware state](https://github.com/forbes-automotive/openhaldex-c6/blob/main/src/OpenHaldexC6_globals.cpp): `src/OpenHaldexC6_globals.cpp`
- [Controller definitions](https://github.com/forbes-automotive/openhaldex-c6/blob/main/include/OpenHaldexC6_defs.h): `include/OpenHaldexC6_defs.h`
- [Firmware version metadata](https://github.com/forbes-automotive/openhaldex-c6/blob/main/include/OpenHaldexC6_ver.h): `include/OpenHaldexC6_ver.h`

### Other components

- **Driver**
- **Vehicle CAN networks**
- **Haldex differential**

## Connections

- Driver → Web configuration and diagnostics: configures (evidence: `README.md`)
- Web configuration and diagnostics → HTTP API: sends settings (evidence: `data/app.js`)
- Vehicle CAN networks → CAN interfaces: sends CAN signals (evidence: `README.md`)
- CAN interfaces → Vehicle CAN networks: bridges CAN traffic (evidence: `README.md`)
- Vehicle CAN networks → Chassis decoding: provides chassis signals (evidence: `README.md`)
- Vehicle CAN networks → Mode and lock calculations: provides OEM signals (evidence: `README.md`)
- Mode and lock calculations → Haldex differential: modifies lock requests (evidence: `README.md`)
- Standalone CAN generation → Haldex differential: generates CAN commands (evidence: `README.md`)
- Driver → Buttons and outputs: uses controls (evidence: `README.md`)
- HTTP API → Settings persistence: applies settings
- Settings persistence → EEPROM settings store: persists settings
- Driver → Bluetooth LE: uses phone app (evidence: `README.md`)
- Driver → Wi-Fi access and bridge: configures device (evidence: `README.md`)
- Wi-Fi access and bridge → Wireless updates: supports updates (evidence: `README.md`)
- CAN interfaces → CAN analyzer bridge: exposes CAN traffic (evidence: `README.md`)
- Haldex differential → UDS and TP2 diagnostics: provides diagnostic data (evidence: `README.md`)
- CAN interfaces → Gauge frame relay: relays CAN frames (evidence: `README.md`)
- Firmware startup → Wi-Fi access and bridge: starts Wi-Fi (evidence: `src/main.cpp`)
- Firmware startup → Gauge frame relay: stops relay during reset (evidence: `src/main.cpp`)
- Learning and background tasks → Standalone CAN generation: uses CAN generation (evidence: `src/OpenHaldexC6_tasks.cpp`)
- Learning and background tasks → Mode and lock calculations: uses calculations (evidence: `src/OpenHaldexC6_tasks.cpp`)
