# blulightningxd/roadnet architecture

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

- Interactive diagram: https://gitdiagram.com/blulightningxd/roadnet
- Repository: https://github.com/blulightningxd/roadnet

## Overview

RoadNet is a browser dashboard and local telemetry server for monitoring ESP32 road-safety data. The main workflow connects by Web Bluetooth or configures the server’s demo, serial, or Wi-Fi stream; telemetry is normalized and buffered, then displayed as GPS tracking, inertial graphs, mesh status, and collision alerts. The README also documents ESP32 GPS/IMU/LoRa hardware and Bluetooth Classic SPP setup. Firmware and HTML are present but unsampled, so their internal behavior and links to the sampled runtime are not inferred.

Main entry points: [`static/app.js`](https://github.com/blulightningxd/roadnet/blob/master/static/app.js) (Dashboard Controller), [`app.py`](https://github.com/blulightningxd/roadnet/blob/master/app.py) (Telemetry Store), [`static/bluetooth.js`](https://github.com/blulightningxd/roadnet/blob/master/static/bluetooth.js) (BLE Manager), [`esp32/roadnet_esp32.ino`](https://github.com/blulightningxd/roadnet/blob/master/esp32/roadnet_esp32.ino) (Telemetry Firmware)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["Telemetry Ingestion"]
  node_ble_manager["BLE Manager<br/>[bluetooth.js]"]
end

subgraph group_server["Local Server"]
  node_telemetry_store[("Telemetry Store<br/>[app.py]")]
  node_normalizer["Frame Normalizer<br/>[app.py]"]
  node_demo_stream["Demo Stream<br/>[app.py]"]
  node_serial_stream["Serial Stream<br/>[app.py]"]
  node_wifi_stream["Wi-Fi Stream<br/>[app.py]"]
  node_http_handler["HTTP API and Files<br/>[app.py]"]
end

subgraph group_dashboard["Safety Dashboard"]
  node_dashboard_app["Dashboard Controller<br/>[app.js]"]
  node_gps_map["GPS Map and Route<br/>[app.js]"]
  node_inertial_graphs["Inertial Graphs<br/>[app.js]"]
  node_mesh_status["Mesh Status<br/>[app.js]"]
  node_collision_alerts["Collision Alerts<br/>[app.js]"]
  node_browser_ui["Dashboard Interface<br/>[index.html]"]
end

subgraph group_firmware["ESP32 Device"]
  node_esp32{{"ESP32 Hardware"}}
  node_firmware_code["Telemetry Firmware<br/>[roadnet_esp32.ino]"]
end

node_operator(("Dashboard User"))
node_browser(("Web Browser"))
node_map_tiles["OpenStreetMap Tiles"]
node_bluetooth_device["Bluetooth Device"]

node_operator -->|"uses"| node_browser
node_browser -->|"requests dashboard"| node_http_handler
node_http_handler -->|"serves files"| node_browser_ui
node_browser -->|"connects"| node_ble_manager
node_ble_manager -->|"reads notifications"| node_bluetooth_device
node_ble_manager -->|"writes commands"| node_bluetooth_device
node_dashboard_app -->|"receives telemetry"| node_ble_manager
node_dashboard_app -->|"sends reset"| node_ble_manager
node_browser -->|"polls telemetry"| node_http_handler
node_dashboard_app -->|"sets connection"| node_http_handler
node_http_handler -->|"reads and configures"| node_telemetry_store
node_telemetry_store -->|"normalizes frames"| node_normalizer
node_demo_stream -->|"adds frames"| node_telemetry_store
node_serial_stream -->|"adds frames"| node_telemetry_store
node_wifi_stream -->|"adds frames"| node_telemetry_store
node_telemetry_store -->|"serves snapshots"| node_dashboard_app
node_dashboard_app -->|"updates position"| node_gps_map
node_gps_map -->|"loads map tiles"| node_map_tiles
node_dashboard_app -->|"draws waveforms"| node_inertial_graphs
node_dashboard_app -->|"shows node stats"| node_mesh_status
node_dashboard_app -->|"records collisions"| node_collision_alerts
node_esp32 -.->|"runs"| node_firmware_code
node_firmware_code -.->|"provides telemetry"| node_bluetooth_device

click node_firmware_code "https://github.com/blulightningxd/roadnet/blob/master/esp32/roadnet_esp32.ino"
click node_ble_manager "https://github.com/blulightningxd/roadnet/blob/master/static/bluetooth.js"
click node_dashboard_app "https://github.com/blulightningxd/roadnet/blob/master/static/app.js"
click node_telemetry_store "https://github.com/blulightningxd/roadnet/blob/master/app.py"
click node_normalizer "https://github.com/blulightningxd/roadnet/blob/master/app.py"
click node_demo_stream "https://github.com/blulightningxd/roadnet/blob/master/app.py"
click node_serial_stream "https://github.com/blulightningxd/roadnet/blob/master/app.py"
click node_wifi_stream "https://github.com/blulightningxd/roadnet/blob/master/app.py"
click node_http_handler "https://github.com/blulightningxd/roadnet/blob/master/app.py"
click node_gps_map "https://github.com/blulightningxd/roadnet/blob/master/static/app.js"
click node_inertial_graphs "https://github.com/blulightningxd/roadnet/blob/master/static/app.js"
click node_mesh_status "https://github.com/blulightningxd/roadnet/blob/master/static/app.js"
click node_collision_alerts "https://github.com/blulightningxd/roadnet/blob/master/static/app.js"
click node_browser_ui "https://github.com/blulightningxd/roadnet/blob/master/static/index.html"

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_ble_manager,node_operator,node_browser toneBlue
class node_telemetry_store,node_normalizer,node_demo_stream,node_serial_stream,node_wifi_stream,node_http_handler toneAmber
class node_dashboard_app,node_gps_map,node_inertial_graphs,node_mesh_status,node_collision_alerts,node_browser_ui toneMint
class node_esp32,node_firmware_code toneRose
class node_map_tiles,node_bluetooth_device toneIndigo
```

## Components

### Telemetry Ingestion

- [BLE Manager](https://github.com/blulightningxd/roadnet/blob/master/static/bluetooth.js): `static/bluetooth.js`

### Local Server

- [Telemetry Store](https://github.com/blulightningxd/roadnet/blob/master/app.py): `app.py`
- [Frame Normalizer](https://github.com/blulightningxd/roadnet/blob/master/app.py): `app.py`
- [Demo Stream](https://github.com/blulightningxd/roadnet/blob/master/app.py): `app.py`
- [Serial Stream](https://github.com/blulightningxd/roadnet/blob/master/app.py): `app.py`
- [Wi-Fi Stream](https://github.com/blulightningxd/roadnet/blob/master/app.py): `app.py`
- [HTTP API and Files](https://github.com/blulightningxd/roadnet/blob/master/app.py): `app.py`

### Safety Dashboard

- [Dashboard Controller](https://github.com/blulightningxd/roadnet/blob/master/static/app.js): `static/app.js`
- [GPS Map and Route](https://github.com/blulightningxd/roadnet/blob/master/static/app.js): `static/app.js`
- [Inertial Graphs](https://github.com/blulightningxd/roadnet/blob/master/static/app.js): `static/app.js`
- [Mesh Status](https://github.com/blulightningxd/roadnet/blob/master/static/app.js): `static/app.js`
- [Collision Alerts](https://github.com/blulightningxd/roadnet/blob/master/static/app.js): `static/app.js`
- [Dashboard Interface](https://github.com/blulightningxd/roadnet/blob/master/static/index.html): `static/index.html`

### ESP32 Device

- **ESP32 Hardware**
- [Telemetry Firmware](https://github.com/blulightningxd/roadnet/blob/master/esp32/roadnet_esp32.ino): `esp32/roadnet_esp32.ino`

### Other components

- **Dashboard User**
- **Web Browser**
- **OpenStreetMap Tiles**
- **Bluetooth Device**

## Connections

- Dashboard User → Web Browser: uses (evidence: `README.md`)
- Web Browser → HTTP API and Files: requests dashboard (evidence: `README.md`)
- HTTP API and Files → Dashboard Interface: serves files (evidence: `app.py`)
- Web Browser → BLE Manager: connects (evidence: `static/bluetooth.js`)
- BLE Manager → Bluetooth Device: reads notifications (evidence: `static/bluetooth.js`)
- BLE Manager → Bluetooth Device: writes commands (evidence: `static/bluetooth.js`)
- Dashboard Controller → BLE Manager: receives telemetry (evidence: `static/app.js`)
- Dashboard Controller → BLE Manager: sends reset (evidence: `static/app.js`)
- Web Browser → HTTP API and Files: polls telemetry
- Dashboard Controller → HTTP API and Files: sets connection (evidence: `static/app.js`)
- HTTP API and Files → Telemetry Store: reads and configures (evidence: `app.py`)
- Telemetry Store → Frame Normalizer: normalizes frames (evidence: `app.py`)
- Demo Stream → Telemetry Store: adds frames (evidence: `app.py`)
- Serial Stream → Telemetry Store: adds frames (evidence: `app.py`)
- Wi-Fi Stream → Telemetry Store: adds frames (evidence: `app.py`)
- Telemetry Store → Dashboard Controller: serves snapshots (evidence: `static/app.js`)
- Dashboard Controller → GPS Map and Route: updates position (evidence: `static/app.js`)
- GPS Map and Route → OpenStreetMap Tiles: loads map tiles (evidence: `static/app.js`)
- Dashboard Controller → Inertial Graphs: draws waveforms (evidence: `static/app.js`)
- Dashboard Controller → Mesh Status: shows node stats (evidence: `static/app.js`)
- Dashboard Controller → Collision Alerts: records collisions (evidence: `static/app.js`)
- ESP32 Hardware → Telemetry Firmware: runs (evidence: `README.md`)
- Telemetry Firmware → Bluetooth Device: provides telemetry (evidence: `README.md`)
