# drngominhtu/esp32_webserver_rbcteam_v2 architecture

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

- Interactive diagram: https://gitdiagram.com/drngominhtu/esp32_webserver_rbcteam_v2
- Repository: https://github.com/drngominhtu/esp32_webserver_rbcteam_v2

## Overview

This repository implements an ESP32-hosted MQTT dashboard for live robot monitoring and control. A browser loads the dashboard from the ESP32, connects over WebSocket, and receives broker messages for topic discovery, tables, charts, and the robot map; browser commands travel back through the ESP32 to the MQTT broker. The map and R1 scripts are separate browser views in the tree. Source excerpts show the firmware bridge and portions of the browser behavior; links for unsampled page assets reflect explicit firmware routes or documented capabilities.

Main entry points: [`src/main.cpp`](https://github.com/drngominhtu/esp32_webserver_rbcteam_v2/blob/main/src/main.cpp) (HTTP and WS Server), [`data/script.js`](https://github.com/drngominhtu/esp32_webserver_rbcteam_v2/blob/main/data/script.js) (Dashboard Logic), [`not_main/scriptmap.js`](https://github.com/drngominhtu/esp32_webserver_rbcteam_v2/blob/main/not_main/scriptmap.js) (Robot Position Map), [`not_main/scriptR1.js`](https://github.com/drngominhtu/esp32_webserver_rbcteam_v2/blob/main/not_main/scriptR1.js) (R1 Dashboard View)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_firmware["ESP32 Gateway"]
  node_firmware["HTTP and WS Server<br/>[main.cpp]"]
  node_mqtt_bridge["MQTT Bridge<br/>[main.cpp]"]
end

subgraph group_dashboard["Dashboard UI"]
  node_dashboard_page["Dashboard Page<br/>[index.html]"]
  node_dashboard_assets["Dashboard Assets"]
  node_dashboard_logic["Dashboard Logic<br/>[script.js]"]
  node_tables["Parameter Tables<br/>[script.js]"]
  node_charts["Charts and Export<br/>[script.js]"]
  node_topic_controls["Topic Controls<br/>[script.js]"]
end

subgraph group_visualization["Robot Visualization"]
  node_map_page["Map Page<br/>[map.html]"]
  node_map_logic["Robot Position Map<br/>[scriptmap.js]"]
  node_r1_logic["R1 Dashboard View<br/>[scriptR1.js]"]
  node_map_assets["Map Styles<br/>[stylemap.css]"]
end

subgraph group_external["External Systems"]
  node_broker["MQTT Broker"]
  node_robot["Robot Devices"]
end

node_browser(("Browser User"))

node_browser -->|"requests pages"| node_firmware
node_firmware -->|"serves page"| node_dashboard_page
node_firmware -->|"serves assets"| node_dashboard_assets
node_firmware -->|"serves map"| node_map_page
node_firmware -->|"routes stylesheet"| node_map_assets
node_browser -->|"runs dashboard"| node_dashboard_logic
node_dashboard_logic -->|"updates values"| node_tables
node_dashboard_logic -->|"plots values"| node_charts
node_dashboard_logic -->|"sends subscriptions"| node_topic_controls
node_browser -->|"opens WebSocket"| node_firmware
node_firmware -->|"handles WS events"| node_mqtt_bridge
node_mqtt_bridge -->|"subscribes and publishes"| node_broker
node_broker -->|"delivers messages"| node_mqtt_bridge
node_mqtt_bridge -->|"forwards updates"| node_browser
node_broker -->|"delivers commands"| node_robot
node_browser -->|"runs map view"| node_map_logic
node_map_logic -->|"opens WebSocket"| node_firmware
node_firmware -.->|"forwards position data"| node_map_logic
node_browser -->|"runs R1 view"| node_r1_logic
node_r1_logic -->|"requests R1 topic"| node_firmware
node_firmware -.->|"forwards topic data"| node_r1_logic
node_broker -->|"discovers topics"| node_mqtt_bridge

click node_firmware "https://github.com/drngominhtu/esp32_webserver_rbcteam_v2/blob/main/src/main.cpp"
click node_mqtt_bridge "https://github.com/drngominhtu/esp32_webserver_rbcteam_v2/blob/main/src/main.cpp"
click node_dashboard_page "https://github.com/drngominhtu/esp32_webserver_rbcteam_v2/blob/main/data/index.html"
click node_dashboard_assets "https://github.com/drngominhtu/esp32_webserver_rbcteam_v2/tree/main/data"
click node_dashboard_logic "https://github.com/drngominhtu/esp32_webserver_rbcteam_v2/blob/main/data/script.js"
click node_tables "https://github.com/drngominhtu/esp32_webserver_rbcteam_v2/blob/main/data/script.js"
click node_charts "https://github.com/drngominhtu/esp32_webserver_rbcteam_v2/blob/main/data/script.js"
click node_topic_controls "https://github.com/drngominhtu/esp32_webserver_rbcteam_v2/blob/main/data/script.js"
click node_map_page "https://github.com/drngominhtu/esp32_webserver_rbcteam_v2/blob/main/data/map.html"
click node_map_logic "https://github.com/drngominhtu/esp32_webserver_rbcteam_v2/blob/main/not_main/scriptmap.js"
click node_r1_logic "https://github.com/drngominhtu/esp32_webserver_rbcteam_v2/blob/main/not_main/scriptR1.js"
click node_map_assets "https://github.com/drngominhtu/esp32_webserver_rbcteam_v2/blob/main/not_main/stylemap.css"

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_firmware,node_mqtt_bridge,node_browser toneBlue
class node_dashboard_page,node_dashboard_assets,node_dashboard_logic,node_tables,node_charts,node_topic_controls toneAmber
class node_map_page,node_map_logic,node_r1_logic,node_map_assets toneMint
class node_broker,node_robot toneRose
```

## Components

### ESP32 Gateway

- [HTTP and WS Server](https://github.com/drngominhtu/esp32_webserver_rbcteam_v2/blob/main/src/main.cpp): `src/main.cpp`
- [MQTT Bridge](https://github.com/drngominhtu/esp32_webserver_rbcteam_v2/blob/main/src/main.cpp): `src/main.cpp`

### Dashboard UI

- [Dashboard Page](https://github.com/drngominhtu/esp32_webserver_rbcteam_v2/blob/main/data/index.html): `data/index.html`
- [Dashboard Assets](https://github.com/drngominhtu/esp32_webserver_rbcteam_v2/tree/main/data): `data`
- [Dashboard Logic](https://github.com/drngominhtu/esp32_webserver_rbcteam_v2/blob/main/data/script.js): `data/script.js`
- [Parameter Tables](https://github.com/drngominhtu/esp32_webserver_rbcteam_v2/blob/main/data/script.js): `data/script.js`
- [Charts and Export](https://github.com/drngominhtu/esp32_webserver_rbcteam_v2/blob/main/data/script.js): `data/script.js`
- [Topic Controls](https://github.com/drngominhtu/esp32_webserver_rbcteam_v2/blob/main/data/script.js): `data/script.js`

### Robot Visualization

- [Map Page](https://github.com/drngominhtu/esp32_webserver_rbcteam_v2/blob/main/data/map.html): `data/map.html`
- [Robot Position Map](https://github.com/drngominhtu/esp32_webserver_rbcteam_v2/blob/main/not_main/scriptmap.js): `not_main/scriptmap.js`
- [R1 Dashboard View](https://github.com/drngominhtu/esp32_webserver_rbcteam_v2/blob/main/not_main/scriptR1.js): `not_main/scriptR1.js`
- [Map Styles](https://github.com/drngominhtu/esp32_webserver_rbcteam_v2/blob/main/not_main/stylemap.css): `not_main/stylemap.css`

### External Systems

- **MQTT Broker**
- **Robot Devices**

### Other components

- **Browser User**

## Connections

- Browser User → HTTP and WS Server: requests pages (evidence: `src/main.cpp`)
- HTTP and WS Server → Dashboard Page: serves page (evidence: `src/main.cpp`)
- HTTP and WS Server → Dashboard Assets: serves assets (evidence: `src/main.cpp`)
- HTTP and WS Server → Map Page: serves map (evidence: `src/main.cpp`)
- HTTP and WS Server → Map Styles: routes stylesheet (evidence: `src/main.cpp`)
- Browser User → Dashboard Logic: runs dashboard (evidence: `data/script.js`)
- Dashboard Logic → Parameter Tables: updates values (evidence: `data/script.js`)
- Dashboard Logic → Charts and Export: plots values (evidence: `data/script.js`)
- Dashboard Logic → Topic Controls: sends subscriptions (evidence: `data/script.js`)
- Browser User → HTTP and WS Server: opens WebSocket (evidence: `src/main.cpp`)
- HTTP and WS Server → MQTT Bridge: handles WS events (evidence: `src/main.cpp`)
- MQTT Bridge → MQTT Broker: subscribes and publishes (evidence: `src/main.cpp`)
- MQTT Broker → MQTT Bridge: delivers messages (evidence: `src/main.cpp`)
- MQTT Bridge → Browser User: forwards updates (evidence: `src/main.cpp`)
- MQTT Broker → Robot Devices: delivers commands (evidence: `README.md`)
- Browser User → Robot Position Map: runs map view (evidence: `not_main/scriptmap.js`)
- Robot Position Map → HTTP and WS Server: opens WebSocket (evidence: `not_main/scriptmap.js`)
- HTTP and WS Server → Robot Position Map: forwards position data
- Browser User → R1 Dashboard View: runs R1 view (evidence: `not_main/scriptR1.js`)
- R1 Dashboard View → HTTP and WS Server: requests R1 topic (evidence: `not_main/scriptR1.js`)
- HTTP and WS Server → R1 Dashboard View: forwards topic data
- MQTT Broker → MQTT Bridge: discovers topics (evidence: `src/main.cpp`)
