# jackgamercyt/iot-project3- architecture

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

- Interactive diagram: https://gitdiagram.com/jackgamercyt/iot-project3-
- Repository: https://github.com/jackgamercyt/iot-project3-

## Overview

Smart Energy Monitoring is an end-to-end IoT system: the ESP32 measures energy and locally sheds or restores lower-priority loads, while MQTT carries telemetry and commands; the backend persists history and serves APIs, and the web dashboard combines live data with historical views and a data assistant. Paths for firmware subsystems are supported by the README; backend and dashboard responsibilities share their single source files. The sampled backend excerpt is partial, so uncertain internal routing is omitted.

Main entry points: [`firmware/esp32_firmware/esp32_firmware.ino`](https://github.com/jackgamercyt/iot-project3-/blob/main/firmware/esp32_firmware/esp32_firmware.ino) (ESP32 Firmware), [`index.html`](https://github.com/jackgamercyt/iot-project3-/blob/main/index.html) (Web Dashboard), [`backend/main.py`](https://github.com/jackgamercyt/iot-project3-/blob/main/backend/main.py) (REST API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_device["Device Control"]
  node_esp["ESP32 Firmware<br/>[esp32_firmware.ino]"]
  node_meter["Measurement &amp; Energy<br/>[esp32_firmware.ino]"]
  node_load_control["Load Management<br/>[esp32_firmware.ino]"]
  node_time_buffer["RTC &amp; Offline Buffer<br/>[esp32_firmware.ino]"]
end

subgraph group_transport["Messaging"]
  node_broker["MQTT Broker"]
end

subgraph group_server["Backend Data"]
  node_backend_ingest["MQTT Ingest<br/>[main.py]"]
  node_api["REST API<br/>[main.py]"]
  node_analytics["Energy &amp; History<br/>[main.py]"]
  node_assistant["Data Assistant<br/>[main.py]"]
  node_store[("Time-Series Database<br/>[main.py]")]
end

subgraph group_web["Dashboard"]
  node_dashboard["Web Dashboard<br/>[index.html]"]
  node_live_view["Live Monitoring<br/>[index.html]"]
  node_history_view["History &amp; Costs<br/>[index.html]"]
  node_command_ui["Commands &amp; ACKs<br/>[index.html]"]
  node_chat_ui["Assistant Interface<br/>[index.html]"]
end

node_operator(("Operator"))
node_loads["Fan &amp; LED Loads"]

node_operator -->|"uses"| node_dashboard
node_esp -->|"samples"| node_meter
node_meter -->|"provides readings"| node_load_control
node_load_control -->|"switches"| node_loads
node_time_buffer -->|"supplies time"| node_esp
node_esp -->|"publishes telemetry"| node_broker
node_broker -->|"dispatches commands"| node_esp
node_esp -->|"buffers offline"| node_time_buffer
node_broker -->|"delivers topics"| node_backend_ingest
node_backend_ingest -->|"writes records"| node_store
node_backend_ingest -->|"publishes commands"| node_broker
node_api -->|"reads and writes"| node_store
node_analytics -->|"queries history"| node_store
node_assistant -->|"uses queries"| node_analytics
node_dashboard -->|"subscribes live"| node_broker
node_dashboard -->|"requests REST data"| node_api
node_live_view -->|"renders live data"| node_dashboard
node_history_view -->|"renders history"| node_dashboard
node_command_ui -->|"publishes commands"| node_broker
node_broker -->|"delivers ACKs"| node_command_ui
node_chat_ui -->|"sends questions"| node_api
node_api -->|"returns answers"| node_chat_ui

click node_esp "https://github.com/jackgamercyt/iot-project3-/blob/main/firmware/esp32_firmware/esp32_firmware.ino"
click node_meter "https://github.com/jackgamercyt/iot-project3-/blob/main/firmware/esp32_firmware/esp32_firmware.ino"
click node_load_control "https://github.com/jackgamercyt/iot-project3-/blob/main/firmware/esp32_firmware/esp32_firmware.ino"
click node_time_buffer "https://github.com/jackgamercyt/iot-project3-/blob/main/firmware/esp32_firmware/esp32_firmware.ino"
click node_backend_ingest "https://github.com/jackgamercyt/iot-project3-/blob/main/backend/main.py"
click node_api "https://github.com/jackgamercyt/iot-project3-/blob/main/backend/main.py"
click node_analytics "https://github.com/jackgamercyt/iot-project3-/blob/main/backend/main.py"
click node_assistant "https://github.com/jackgamercyt/iot-project3-/blob/main/backend/main.py"
click node_store "https://github.com/jackgamercyt/iot-project3-/blob/main/backend/main.py"
click node_dashboard "https://github.com/jackgamercyt/iot-project3-/blob/main/index.html"
click node_live_view "https://github.com/jackgamercyt/iot-project3-/blob/main/index.html"
click node_history_view "https://github.com/jackgamercyt/iot-project3-/blob/main/index.html"
click node_command_ui "https://github.com/jackgamercyt/iot-project3-/blob/main/index.html"
click node_chat_ui "https://github.com/jackgamercyt/iot-project3-/blob/main/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_esp,node_meter,node_load_control,node_time_buffer toneBlue
class node_broker toneAmber
class node_backend_ingest,node_api,node_analytics,node_assistant,node_store toneMint
class node_dashboard,node_live_view,node_history_view,node_command_ui,node_chat_ui toneRose
class node_operator,node_loads toneIndigo
```

## Components

### Device Control

- [ESP32 Firmware](https://github.com/jackgamercyt/iot-project3-/blob/main/firmware/esp32_firmware/esp32_firmware.ino): `firmware/esp32_firmware/esp32_firmware.ino`
- [Measurement & Energy](https://github.com/jackgamercyt/iot-project3-/blob/main/firmware/esp32_firmware/esp32_firmware.ino): `firmware/esp32_firmware/esp32_firmware.ino`
- [Load Management](https://github.com/jackgamercyt/iot-project3-/blob/main/firmware/esp32_firmware/esp32_firmware.ino): `firmware/esp32_firmware/esp32_firmware.ino`
- [RTC & Offline Buffer](https://github.com/jackgamercyt/iot-project3-/blob/main/firmware/esp32_firmware/esp32_firmware.ino): `firmware/esp32_firmware/esp32_firmware.ino`

### Messaging

- **MQTT Broker**

### Backend Data

- [MQTT Ingest](https://github.com/jackgamercyt/iot-project3-/blob/main/backend/main.py): `backend/main.py`
- [REST API](https://github.com/jackgamercyt/iot-project3-/blob/main/backend/main.py): `backend/main.py`
- [Energy & History](https://github.com/jackgamercyt/iot-project3-/blob/main/backend/main.py): `backend/main.py`
- [Data Assistant](https://github.com/jackgamercyt/iot-project3-/blob/main/backend/main.py): `backend/main.py`
- [Time-Series Database](https://github.com/jackgamercyt/iot-project3-/blob/main/backend/main.py): `backend/main.py`

### Dashboard

- [Web Dashboard](https://github.com/jackgamercyt/iot-project3-/blob/main/index.html): `index.html`
- [Live Monitoring](https://github.com/jackgamercyt/iot-project3-/blob/main/index.html): `index.html`
- [History & Costs](https://github.com/jackgamercyt/iot-project3-/blob/main/index.html): `index.html`
- [Commands & ACKs](https://github.com/jackgamercyt/iot-project3-/blob/main/index.html): `index.html`
- [Assistant Interface](https://github.com/jackgamercyt/iot-project3-/blob/main/index.html): `index.html`

### Other components

- **Operator**
- **Fan & LED Loads**

## Connections

- Operator → Web Dashboard: uses
- ESP32 Firmware → Measurement & Energy: samples
- Measurement & Energy → Load Management: provides readings
- Load Management → Fan & LED Loads: switches
- RTC & Offline Buffer → ESP32 Firmware: supplies time
- ESP32 Firmware → MQTT Broker: publishes telemetry
- MQTT Broker → ESP32 Firmware: dispatches commands
- ESP32 Firmware → RTC & Offline Buffer: buffers offline
- MQTT Broker → MQTT Ingest: delivers topics
- MQTT Ingest → Time-Series Database: writes records
- MQTT Ingest → MQTT Broker: publishes commands
- REST API → Time-Series Database: reads and writes
- Energy & History → Time-Series Database: queries history
- Data Assistant → Energy & History: uses queries
- Web Dashboard → MQTT Broker: subscribes live
- Web Dashboard → REST API: requests REST data
- Live Monitoring → Web Dashboard: renders live data
- History & Costs → Web Dashboard: renders history
- Commands & ACKs → MQTT Broker: publishes commands
- MQTT Broker → Commands & ACKs: delivers ACKs
- Assistant Interface → REST API: sends questions
- REST API → Assistant Interface: returns answers
