# gedxxe/esp32-modbus-energy architecture

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

- Interactive diagram: https://gitdiagram.com/gedxxe/esp32-modbus-energy
- Repository: https://github.com/gedxxe/esp32-modbus-energy

## Overview

Modbus Energy Station is ESP32 firmware plus a locally served dashboard for configuring meters, acquiring energy readings, recording scheduled daily checkpoints, and reviewing/exporting records. The central workflow is dashboard setup → meter scan/read → checkpoint capture and persistent recovery → dashboard display/export. README documents meter discovery, diagnostics, Enterprise Wi-Fi, optional LoRa, and an opt-in HTTPS uplink as additional capabilities. Unsampled firmware modules are represented at their exact include paths; edges are limited to relationships shown in excerpts, the source index, or README documentation.

Main entry points: [`firmware/src/main.cpp`](https://github.com/gedxxe/esp32-modbus-energy/blob/main/firmware/src/main.cpp) (Firmware web API), [`web/Application.jsx`](https://github.com/gedxxe/esp32-modbus-energy/blob/main/web/Application.jsx) (Dashboard application), [`web/views/MeterSetup.jsx`](https://github.com/gedxxe/esp32-modbus-energy/blob/main/web/views/MeterSetup.jsx) (Meter setup), [`web/device.js`](https://github.com/gedxxe/esp32-modbus-energy/blob/main/web/device.js) (Device state client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_meter["Meter acquisition"]
  node_profile["Meter profiles<br/>[MeterProfiles.h]"]
  node_modbus["Modbus transport<br/>[ModbusMaster.cpp]"]
  node_discovery["Meter discovery<br/>[MeterDiscovery.h]"]
  node_diagnostics["Meter diagnostics<br/>[FortDiagnostics.h]"]
end

subgraph group_records["Records and recovery"]
  node_capture["Scheduled capture<br/>[checkpoint_log.h]"]
  node_archive[("Capture archive<br/>[capture_archive.h]")]
  node_recovery["Storage recovery<br/>[recovery.h]"]
end

subgraph group_panel["Local dashboard"]
  node_webapp["Dashboard application<br/>[Application.jsx]"]
  node_setup["Meter setup<br/>[MeterSetup.jsx]"]
  node_overview["Energy overview<br/>[Overview.jsx]"]
  node_deviceview["Device records<br/>[DeviceRecords.jsx]"]
  node_deviceapi["Device state client<br/>[device.js]"]
  node_api["Firmware web API<br/>[main.cpp]"]
end

subgraph group_connectivity["Connectivity and radio"]
  node_network["Network settings<br/>[network_settings.h]"]
  node_enterprise["Enterprise Wi-Fi"]
  node_lora["LoRa service<br/>[lora_service.cpp]"]
  node_uplink["HTTPS uplink<br/>[iot_uplink.cpp]"]
end

node_operator(("Station operator"))
node_gateway(("LoRa gateway"))
node_iotservice(("Energy Record service"))

node_operator -->|"uses"| node_webapp
node_webapp -->|"routes to"| node_setup
node_webapp -->|"routes to"| node_overview
node_webapp -->|"routes to"| node_deviceview
node_webapp -->|"reads state"| node_deviceapi
node_setup -->|"configures and scans"| node_api
node_overview -->|"renders readings"| node_deviceapi
node_deviceview -->|"requests records"| node_deviceapi
node_deviceapi -.->|"requests device data"| node_api
node_api -.->|"reads meter"| node_modbus
node_modbus -->|"uses register profiles"| node_profile
node_setup -->|"starts discovery"| node_discovery
node_setup -->|"opens diagnostics"| node_diagnostics
node_diagnostics -->|"uses transport"| node_modbus
node_api -->|"records checkpoints"| node_capture
node_capture -->|"calculates energy"| node_profile
node_api -.->|"persists captures"| node_archive
node_api -->|"recovers storage"| node_recovery
node_api -.->|"configures network"| node_network
node_network -->|"supports Enterprise"| node_enterprise
node_api -->|"controls radio"| node_lora
node_lora -->|"queries archives"| node_capture
node_lora -->|"exchanges radio data"| node_gateway
node_api -.->|"optionally enables"| node_uplink
node_uplink -->|"uploads records"| node_iotservice

click node_webapp "https://github.com/gedxxe/esp32-modbus-energy/blob/main/web/Application.jsx"
click node_setup "https://github.com/gedxxe/esp32-modbus-energy/blob/main/web/views/MeterSetup.jsx"
click node_overview "https://github.com/gedxxe/esp32-modbus-energy/blob/main/web/views/Overview.jsx"
click node_deviceview "https://github.com/gedxxe/esp32-modbus-energy/blob/main/web/views/DeviceRecords.jsx"
click node_deviceapi "https://github.com/gedxxe/esp32-modbus-energy/blob/main/web/device.js"
click node_api "https://github.com/gedxxe/esp32-modbus-energy/blob/main/firmware/src/main.cpp"
click node_profile "https://github.com/gedxxe/esp32-modbus-energy/blob/main/firmware/lib/FortMeter/src/MeterProfiles.h"
click node_modbus "https://github.com/gedxxe/esp32-modbus-energy/blob/main/firmware/lib/FortMeter/src/ModbusMaster.cpp"
click node_discovery "https://github.com/gedxxe/esp32-modbus-energy/blob/main/firmware/lib/FortMeter/src/MeterDiscovery.h"
click node_diagnostics "https://github.com/gedxxe/esp32-modbus-energy/blob/main/firmware/lib/FortMeter/src/FortDiagnostics.h"
click node_capture "https://github.com/gedxxe/esp32-modbus-energy/blob/main/firmware/include/checkpoint_log.h"
click node_archive "https://github.com/gedxxe/esp32-modbus-energy/blob/main/firmware/include/capture_archive.h"
click node_recovery "https://github.com/gedxxe/esp32-modbus-energy/blob/main/firmware/include/recovery.h"
click node_network "https://github.com/gedxxe/esp32-modbus-energy/blob/main/firmware/include/network_settings.h"
click node_enterprise "https://github.com/gedxxe/esp32-modbus-energy/blob/main/firmware/src/enterprise_wifi.cpp"
click node_lora "https://github.com/gedxxe/esp32-modbus-energy/blob/main/firmware/src/lora_service.cpp"
click node_uplink "https://github.com/gedxxe/esp32-modbus-energy/blob/main/firmware/src/iot_uplink.cpp"

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_profile,node_modbus,node_discovery,node_diagnostics toneBlue
class node_capture,node_archive,node_recovery toneAmber
class node_webapp,node_setup,node_overview,node_deviceview,node_deviceapi,node_api toneMint
class node_network,node_enterprise,node_lora,node_uplink toneRose
class node_operator,node_gateway,node_iotservice toneIndigo
```

## Components

### Meter acquisition

- [Meter profiles](https://github.com/gedxxe/esp32-modbus-energy/blob/main/firmware/lib/FortMeter/src/MeterProfiles.h): `firmware/lib/FortMeter/src/MeterProfiles.h`
- [Modbus transport](https://github.com/gedxxe/esp32-modbus-energy/blob/main/firmware/lib/FortMeter/src/ModbusMaster.cpp): `firmware/lib/FortMeter/src/ModbusMaster.cpp`
- [Meter discovery](https://github.com/gedxxe/esp32-modbus-energy/blob/main/firmware/lib/FortMeter/src/MeterDiscovery.h): `firmware/lib/FortMeter/src/MeterDiscovery.h`
- [Meter diagnostics](https://github.com/gedxxe/esp32-modbus-energy/blob/main/firmware/lib/FortMeter/src/FortDiagnostics.h): `firmware/lib/FortMeter/src/FortDiagnostics.h`

### Records and recovery

- [Scheduled capture](https://github.com/gedxxe/esp32-modbus-energy/blob/main/firmware/include/checkpoint_log.h): `firmware/include/checkpoint_log.h`
- [Capture archive](https://github.com/gedxxe/esp32-modbus-energy/blob/main/firmware/include/capture_archive.h): `firmware/include/capture_archive.h`
- [Storage recovery](https://github.com/gedxxe/esp32-modbus-energy/blob/main/firmware/include/recovery.h): `firmware/include/recovery.h`

### Local dashboard

- [Dashboard application](https://github.com/gedxxe/esp32-modbus-energy/blob/main/web/Application.jsx): `web/Application.jsx`
- [Meter setup](https://github.com/gedxxe/esp32-modbus-energy/blob/main/web/views/MeterSetup.jsx): `web/views/MeterSetup.jsx`
- [Energy overview](https://github.com/gedxxe/esp32-modbus-energy/blob/main/web/views/Overview.jsx): `web/views/Overview.jsx`
- [Device records](https://github.com/gedxxe/esp32-modbus-energy/blob/main/web/views/DeviceRecords.jsx): `web/views/DeviceRecords.jsx`
- [Device state client](https://github.com/gedxxe/esp32-modbus-energy/blob/main/web/device.js): `web/device.js`
- [Firmware web API](https://github.com/gedxxe/esp32-modbus-energy/blob/main/firmware/src/main.cpp): `firmware/src/main.cpp`

### Connectivity and radio

- [Network settings](https://github.com/gedxxe/esp32-modbus-energy/blob/main/firmware/include/network_settings.h): `firmware/include/network_settings.h`
- [Enterprise Wi-Fi](https://github.com/gedxxe/esp32-modbus-energy/blob/main/firmware/src/enterprise_wifi.cpp): `firmware/src/enterprise_wifi.cpp`
- [LoRa service](https://github.com/gedxxe/esp32-modbus-energy/blob/main/firmware/src/lora_service.cpp): `firmware/src/lora_service.cpp`
- [HTTPS uplink](https://github.com/gedxxe/esp32-modbus-energy/blob/main/firmware/src/iot_uplink.cpp): `firmware/src/iot_uplink.cpp`

### Other components

- **Station operator**
- **LoRa gateway**
- **Energy Record service**

## Connections

- Station operator → Dashboard application: uses (evidence: `README.md`)
- Dashboard application → Meter setup: routes to (evidence: `web/Application.jsx`)
- Dashboard application → Energy overview: routes to (evidence: `web/Application.jsx`)
- Dashboard application → Device records: routes to (evidence: `web/Application.jsx`)
- Dashboard application → Device state client: reads state (evidence: `web/Application.jsx`)
- Meter setup → Firmware web API: configures and scans (evidence: `README.md`)
- Energy overview → Device state client: renders readings (evidence: `web/views/Overview.jsx`)
- Device records → Device state client: requests records (evidence: `web/views/DeviceRecords.jsx`)
- Device state client → Firmware web API: requests device data
- Firmware web API → Modbus transport: reads meter
- Modbus transport → Meter profiles: uses register profiles
- Meter setup → Meter discovery: starts discovery (evidence: `README.md`)
- Meter setup → Meter diagnostics: opens diagnostics (evidence: `web/views/MeterSetup.jsx`)
- Meter diagnostics → Modbus transport: uses transport (evidence: `firmware/lib/FortMeter/src/FortDiagnostics.h`)
- Firmware web API → Scheduled capture: records checkpoints (evidence: `README.md`)
- Scheduled capture → Meter profiles: calculates energy (evidence: `firmware/include/checkpoint_log.h`)
- Firmware web API → Capture archive: persists captures (evidence: `firmware/src/main.cpp`)
- Firmware web API → Storage recovery: recovers storage (evidence: `firmware/src/main.cpp`)
- Firmware web API → Network settings: configures network (evidence: `firmware/src/main.cpp`)
- Network settings → Enterprise Wi-Fi: supports Enterprise (evidence: `README.md`)
- Firmware web API → LoRa service: controls radio (evidence: `firmware/src/main.cpp`)
- LoRa service → Scheduled capture: queries archives
- LoRa service → LoRa gateway: exchanges radio data (evidence: `README.md`)
- Firmware web API → HTTPS uplink: optionally enables (evidence: `README.md`)
- HTTPS uplink → Energy Record service: uploads records (evidence: `README.md`)
