# bruinformula/mk11-mdu-code architecture

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

- Interactive diagram: https://gitdiagram.com/bruinformula/mk11-mdu-code
- Repository: https://github.com/bruinformula/mk11-mdu-code

## Overview

This repository combines STM32-based vehicle electronics with an Electron telemetry and debugging GUI. The principal workflow is live CAN/USB data acquisition, telemetry parsing and display, with log and playback capabilities in the GUI; firmware also initializes the vehicle-side hardware. The graph preserves documented GUI views and the separate MK11 current-sensing firmware. Source excerpts are partial, so unverified implementation links are omitted rather than inferred.

Main entry points: [`mdu_debug_gui/src/renderer/App.jsx`](https://github.com/bruinformula/mk11-mdu-code/blob/main/mdu_debug_gui/src/renderer/App.jsx) (GUI application), [`Core/Src/main.c`](https://github.com/bruinformula/mk11-mdu-code/blob/main/Core/Src/main.c) (Firmware runtime), [`mdu_debug_gui/src/main/main.js`](https://github.com/bruinformula/mk11-mdu-code/blob/main/mdu_debug_gui/src/main/main.js) (Desktop process), [`USB_Device/App/usb_device.c`](https://github.com/bruinformula/mk11-mdu-code/blob/main/USB_Device/App/usb_device.c) (USB device)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_firmware["Vehicle Firmware"]
  node_main_fw["Firmware runtime<br/>[main.c]"]
  node_can["CAN setup<br/>[fdcan.c]"]
  node_gpio["GPIO setup<br/>[gpio.c]"]
  node_mk11_runtime["MK11 current sensing<br/>[main.c]"]
end

subgraph group_transport["Device Transport"]
  node_usb_driver["USB driver<br/>[usb_driver.c]"]
  node_usb_device["USB device<br/>[usb_device.c]"]
  node_cdc_if["CDC interface<br/>[usbd_cdc_if.c]"]
  node_usb_stack["USB device stack<br/>[usbd_core.c]"]
  node_usb_target["USB board support<br/>[usbd_conf.c]"]
end

subgraph group_gui["Telemetry GUI"]
  node_desktop["Desktop process<br/>[main.js]"]
  node_device_monitor["Device monitor<br/>[device-monitor.js]"]
  node_frame_parser["MDU frame parser<br/>[mdu-frame.js]"]
  node_telemetry["Telemetry state"]
  node_app["GUI application<br/>[App.jsx]"]
end

subgraph group_views["Analysis Views"]
  node_connection["Connection controls<br/>[ConnectionBar.jsx]"]
  node_overview["Overview dashboard<br/>[Overview.jsx]"]
  node_plotter["Custom plotter<br/>[CustomPlotter.jsx]"]
  node_gps["GPS playback<br/>[GPSPlayback.jsx]"]
  node_imu["IMU motion<br/>[ImuMotion.jsx]"]
  node_map["Track map<br/>[TrackMap.jsx]"]
  node_table["Telemetry table<br/>[DataTable.jsx]"]
  node_console["Live console<br/>[LiveConsole.jsx]"]
  node_firmware_deploy["Firmware deployment<br/>[DeployFirmware.jsx]"]
end

node_operator(("Operator"))
node_vehicle(("Vehicle hardware"))

node_operator -->|"uses"| node_desktop
node_vehicle -.->|"provides signals"| node_main_fw
node_main_fw -->|"references"| node_can
node_main_fw -->|"references"| node_usb_driver
node_main_fw -->|"references"| node_usb_device
node_main_fw -->|"references"| node_cdc_if
node_usb_device -.->|"uses"| node_usb_stack
node_usb_target -->|"implements low level"| node_usb_stack
node_desktop -->|"uses"| node_device_monitor
node_desktop -->|"uses"| node_frame_parser
node_desktop -->|"parses telemetry"| node_telemetry
node_desktop -.->|"reads files"| node_operator
node_operator -.->|"views"| node_app
node_app -->|"reads state"| node_telemetry
node_app -->|"renders"| node_connection
node_app -->|"renders"| node_overview
node_app -->|"renders"| node_plotter
node_app -->|"renders"| node_gps
node_app -->|"renders"| node_imu
node_app -->|"renders"| node_map
node_app -->|"renders"| node_table
node_app -->|"renders"| node_console
node_app -->|"renders"| node_firmware_deploy
node_mk11_runtime -.->|"samples current"| node_vehicle

click node_main_fw "https://github.com/bruinformula/mk11-mdu-code/blob/main/Core/Src/main.c"
click node_can "https://github.com/bruinformula/mk11-mdu-code/blob/main/Core/Src/fdcan.c"
click node_gpio "https://github.com/bruinformula/mk11-mdu-code/blob/main/Core/Src/gpio.c"
click node_usb_driver "https://github.com/bruinformula/mk11-mdu-code/blob/main/Drivers/BFR_Krill_Drivers/src/usb_driver.c"
click node_usb_device "https://github.com/bruinformula/mk11-mdu-code/blob/main/USB_Device/App/usb_device.c"
click node_cdc_if "https://github.com/bruinformula/mk11-mdu-code/blob/main/USB_Device/App/usbd_cdc_if.c"
click node_usb_stack "https://github.com/bruinformula/mk11-mdu-code/blob/main/Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_core.c"
click node_usb_target "https://github.com/bruinformula/mk11-mdu-code/blob/main/USB_Device/Target/usbd_conf.c"
click node_desktop "https://github.com/bruinformula/mk11-mdu-code/blob/main/mdu_debug_gui/src/main/main.js"
click node_device_monitor "https://github.com/bruinformula/mk11-mdu-code/blob/main/mdu_debug_gui/src/main/device-monitor.js"
click node_frame_parser "https://github.com/bruinformula/mk11-mdu-code/blob/main/mdu_debug_gui/src/main/mdu-frame.js"
click node_telemetry "https://github.com/bruinformula/mk11-mdu-code/blob/main/mdu_debug_gui/src/renderer/context/TelemetryContext.jsx"
click node_app "https://github.com/bruinformula/mk11-mdu-code/blob/main/mdu_debug_gui/src/renderer/App.jsx"
click node_connection "https://github.com/bruinformula/mk11-mdu-code/blob/main/mdu_debug_gui/src/renderer/components/ConnectionBar.jsx"
click node_overview "https://github.com/bruinformula/mk11-mdu-code/blob/main/mdu_debug_gui/src/renderer/components/Overview.jsx"
click node_plotter "https://github.com/bruinformula/mk11-mdu-code/blob/main/mdu_debug_gui/src/renderer/components/CustomPlotter.jsx"
click node_gps "https://github.com/bruinformula/mk11-mdu-code/blob/main/mdu_debug_gui/src/renderer/components/GPSPlayback.jsx"
click node_imu "https://github.com/bruinformula/mk11-mdu-code/blob/main/mdu_debug_gui/src/renderer/components/ImuMotion.jsx"
click node_map "https://github.com/bruinformula/mk11-mdu-code/blob/main/mdu_debug_gui/src/renderer/components/TrackMap.jsx"
click node_table "https://github.com/bruinformula/mk11-mdu-code/blob/main/mdu_debug_gui/src/renderer/components/DataTable.jsx"
click node_console "https://github.com/bruinformula/mk11-mdu-code/blob/main/mdu_debug_gui/src/renderer/components/LiveConsole.jsx"
click node_firmware_deploy "https://github.com/bruinformula/mk11-mdu-code/blob/main/mdu_debug_gui/src/renderer/components/DeployFirmware.jsx"
click node_mk11_runtime "https://github.com/bruinformula/mk11-mdu-code/blob/main/mk11-mdu-main-code/Core/Src/main.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_main_fw,node_can,node_gpio,node_mk11_runtime toneBlue
class node_usb_driver,node_usb_device,node_cdc_if,node_usb_stack,node_usb_target toneAmber
class node_desktop,node_device_monitor,node_frame_parser,node_telemetry,node_app toneMint
class node_connection,node_overview,node_plotter,node_gps,node_imu,node_map,node_table,node_console,node_firmware_deploy toneRose
class node_operator,node_vehicle toneIndigo
```

## Components

### Vehicle Firmware

- [Firmware runtime](https://github.com/bruinformula/mk11-mdu-code/blob/main/Core/Src/main.c): `Core/Src/main.c`
- [CAN setup](https://github.com/bruinformula/mk11-mdu-code/blob/main/Core/Src/fdcan.c): `Core/Src/fdcan.c`
- [GPIO setup](https://github.com/bruinformula/mk11-mdu-code/blob/main/Core/Src/gpio.c): `Core/Src/gpio.c`
- [MK11 current sensing](https://github.com/bruinformula/mk11-mdu-code/blob/main/mk11-mdu-main-code/Core/Src/main.c): `mk11-mdu-main-code/Core/Src/main.c`

### Device Transport

- [USB driver](https://github.com/bruinformula/mk11-mdu-code/blob/main/Drivers/BFR_Krill_Drivers/src/usb_driver.c): `Drivers/BFR_Krill_Drivers/src/usb_driver.c`
- [USB device](https://github.com/bruinformula/mk11-mdu-code/blob/main/USB_Device/App/usb_device.c): `USB_Device/App/usb_device.c`
- [CDC interface](https://github.com/bruinformula/mk11-mdu-code/blob/main/USB_Device/App/usbd_cdc_if.c): `USB_Device/App/usbd_cdc_if.c`
- [USB device stack](https://github.com/bruinformula/mk11-mdu-code/blob/main/Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_core.c): `Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_core.c`
- [USB board support](https://github.com/bruinformula/mk11-mdu-code/blob/main/USB_Device/Target/usbd_conf.c): `USB_Device/Target/usbd_conf.c`

### Telemetry GUI

- [Desktop process](https://github.com/bruinformula/mk11-mdu-code/blob/main/mdu_debug_gui/src/main/main.js): `mdu_debug_gui/src/main/main.js`
- [Device monitor](https://github.com/bruinformula/mk11-mdu-code/blob/main/mdu_debug_gui/src/main/device-monitor.js): `mdu_debug_gui/src/main/device-monitor.js`
- [MDU frame parser](https://github.com/bruinformula/mk11-mdu-code/blob/main/mdu_debug_gui/src/main/mdu-frame.js): `mdu_debug_gui/src/main/mdu-frame.js`
- [Telemetry state](https://github.com/bruinformula/mk11-mdu-code/blob/main/mdu_debug_gui/src/renderer/context/TelemetryContext.jsx): `mdu_debug_gui/src/renderer/context/TelemetryContext.jsx`
- [GUI application](https://github.com/bruinformula/mk11-mdu-code/blob/main/mdu_debug_gui/src/renderer/App.jsx): `mdu_debug_gui/src/renderer/App.jsx`

### Analysis Views

- [Connection controls](https://github.com/bruinformula/mk11-mdu-code/blob/main/mdu_debug_gui/src/renderer/components/ConnectionBar.jsx): `mdu_debug_gui/src/renderer/components/ConnectionBar.jsx`
- [Overview dashboard](https://github.com/bruinformula/mk11-mdu-code/blob/main/mdu_debug_gui/src/renderer/components/Overview.jsx): `mdu_debug_gui/src/renderer/components/Overview.jsx`
- [Custom plotter](https://github.com/bruinformula/mk11-mdu-code/blob/main/mdu_debug_gui/src/renderer/components/CustomPlotter.jsx): `mdu_debug_gui/src/renderer/components/CustomPlotter.jsx`
- [GPS playback](https://github.com/bruinformula/mk11-mdu-code/blob/main/mdu_debug_gui/src/renderer/components/GPSPlayback.jsx): `mdu_debug_gui/src/renderer/components/GPSPlayback.jsx`
- [IMU motion](https://github.com/bruinformula/mk11-mdu-code/blob/main/mdu_debug_gui/src/renderer/components/ImuMotion.jsx): `mdu_debug_gui/src/renderer/components/ImuMotion.jsx`
- [Track map](https://github.com/bruinformula/mk11-mdu-code/blob/main/mdu_debug_gui/src/renderer/components/TrackMap.jsx): `mdu_debug_gui/src/renderer/components/TrackMap.jsx`
- [Telemetry table](https://github.com/bruinformula/mk11-mdu-code/blob/main/mdu_debug_gui/src/renderer/components/DataTable.jsx): `mdu_debug_gui/src/renderer/components/DataTable.jsx`
- [Live console](https://github.com/bruinformula/mk11-mdu-code/blob/main/mdu_debug_gui/src/renderer/components/LiveConsole.jsx): `mdu_debug_gui/src/renderer/components/LiveConsole.jsx`
- [Firmware deployment](https://github.com/bruinformula/mk11-mdu-code/blob/main/mdu_debug_gui/src/renderer/components/DeployFirmware.jsx): `mdu_debug_gui/src/renderer/components/DeployFirmware.jsx`

### Other components

- **Operator**
- **Vehicle hardware**

## Connections

- Operator → Desktop process: uses
- Vehicle hardware → Firmware runtime: provides signals
- Firmware runtime → CAN setup: references (evidence: `Core/Src/main.c`)
- Firmware runtime → USB driver: references (evidence: `Core/Src/main.c`)
- Firmware runtime → USB device: references (evidence: `Core/Src/main.c`)
- Firmware runtime → CDC interface: references (evidence: `Core/Src/main.c`)
- USB device → USB device stack: uses
- USB board support → USB device stack: implements low level (evidence: `USB_Device/Target/usbd_conf.c`)
- Desktop process → Device monitor: uses (evidence: `mdu_debug_gui/src/main/main.js`)
- Desktop process → MDU frame parser: uses (evidence: `mdu_debug_gui/src/main/main.js`)
- Desktop process → Telemetry state: parses telemetry (evidence: `mdu_debug_gui/src/main/main.js`)
- Desktop process → Operator: reads files
- Operator → GUI application: views
- GUI application → Telemetry state: reads state (evidence: `mdu_debug_gui/src/renderer/App.jsx`)
- GUI application → Connection controls: renders (evidence: `mdu_debug_gui/src/renderer/App.jsx`)
- GUI application → Overview dashboard: renders (evidence: `mdu_debug_gui/src/renderer/App.jsx`)
- GUI application → Custom plotter: renders (evidence: `mdu_debug_gui/src/renderer/App.jsx`)
- GUI application → GPS playback: renders (evidence: `mdu_debug_gui/src/renderer/App.jsx`)
- GUI application → IMU motion: renders (evidence: `mdu_debug_gui/src/renderer/App.jsx`)
- GUI application → Track map: renders (evidence: `mdu_debug_gui/src/renderer/App.jsx`)
- GUI application → Telemetry table: renders (evidence: `mdu_debug_gui/src/renderer/App.jsx`)
- GUI application → Live console: renders (evidence: `mdu_debug_gui/src/renderer/App.jsx`)
- GUI application → Firmware deployment: renders (evidence: `mdu_debug_gui/src/renderer/App.jsx`)
- MK11 current sensing → Vehicle hardware: samples current
