# acdeena1994/adaptive-nilm-with-human-in-the-loop-machine-learning architecture

> Architecture diagram of the GitHub repository acdeena1994/adaptive-nilm-with-human-in-the-loop-machine-learning, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/acdeena1994/adaptive-nilm-with-human-in-the-loop-machine-learning
- Repository: https://github.com/acdeena1994/adaptive-nilm-with-human-in-the-loop-machine-learning

## Overview

This repository implements a single-point NILM system: ESP32 firmware sends electrical measurements to a Flask backend, which detects events and identifies appliances; results are persisted and surfaced in a dashboard where users can label events. The README describes the overall stages and feedback loop. The sampled backend excerpt confirms database setup, event detection, appliance matching, and feedback storage, but omitted sections limit verification of specific routes and runtime call relationships.

Main entry points: [`main.py`](https://github.com/acdeena1994/adaptive-nilm-with-human-in-the-loop-machine-learning/blob/main/main.py) (Flask Ingestion), [`templates/index.html`](https://github.com/acdeena1994/adaptive-nilm-with-human-in-the-loop-machine-learning/blob/main/templates/index.html) (Web Dashboard), [`esp32_code.ino`](https://github.com/acdeena1994/adaptive-nilm-with-human-in-the-loop-machine-learning/blob/main/esp32_code.ino) (ESP32 Sensing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_edge["Sensing"]
  node_esp32_firmware["ESP32 Sensing<br/>[esp32_code.ino]"]
end

subgraph group_backend["Backend Analytics"]
  node_flask_api["Flask Ingestion<br/>[main.py]"]
  node_validation["Validation Controls<br/>[main.py]"]
  node_event_detection["Event Detection<br/>[main.py]"]
  node_appliance_identification["Appliance Matching<br/>[main.py]"]
end

subgraph group_state["Storage and Learning"]
  node_event_store[("Event and Data Store<br/>[main.py]")]
  node_signature_store[("Appliance Signatures<br/>[main.py]")]
  node_feedback_store[("User Feedback<br/>[main.py]")]
  node_adaptive_learning["Adaptive Learning<br/>[main.py]"]
end

subgraph group_ui["Dashboard"]
  node_dashboard["Web Dashboard<br/>[index.html]"]
end

node_electrical_load(("Electrical Load"))
node_web_user(("Dashboard User"))

node_electrical_load -->|"measures power"| node_esp32_firmware
node_esp32_firmware -->|"posts readings"| node_flask_api
node_flask_api -->|"validates requests"| node_validation
node_flask_api -->|"detects events"| node_event_detection
node_event_detection -->|"analyzes events"| node_appliance_identification
node_appliance_identification -->|"matches signatures"| node_signature_store
node_flask_api -->|"stores results"| node_event_store
node_appliance_identification -->|"stores predictions"| node_event_store
node_event_store -->|"visualizes results"| node_dashboard
node_web_user -->|"views and labels"| node_dashboard
node_dashboard -->|"submits labels"| node_flask_api
node_flask_api -->|"stores labels"| node_feedback_store
node_feedback_store -->|"updates signatures"| node_adaptive_learning
node_adaptive_learning -->|"improves matching"| node_signature_store

click node_esp32_firmware "https://github.com/acdeena1994/adaptive-nilm-with-human-in-the-loop-machine-learning/blob/main/esp32_code.ino"
click node_flask_api "https://github.com/acdeena1994/adaptive-nilm-with-human-in-the-loop-machine-learning/blob/main/main.py"
click node_validation "https://github.com/acdeena1994/adaptive-nilm-with-human-in-the-loop-machine-learning/blob/main/main.py"
click node_event_detection "https://github.com/acdeena1994/adaptive-nilm-with-human-in-the-loop-machine-learning/blob/main/main.py"
click node_appliance_identification "https://github.com/acdeena1994/adaptive-nilm-with-human-in-the-loop-machine-learning/blob/main/main.py"
click node_event_store "https://github.com/acdeena1994/adaptive-nilm-with-human-in-the-loop-machine-learning/blob/main/main.py"
click node_signature_store "https://github.com/acdeena1994/adaptive-nilm-with-human-in-the-loop-machine-learning/blob/main/main.py"
click node_feedback_store "https://github.com/acdeena1994/adaptive-nilm-with-human-in-the-loop-machine-learning/blob/main/main.py"
click node_adaptive_learning "https://github.com/acdeena1994/adaptive-nilm-with-human-in-the-loop-machine-learning/blob/main/main.py"
click node_dashboard "https://github.com/acdeena1994/adaptive-nilm-with-human-in-the-loop-machine-learning/blob/main/templates/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_esp32_firmware,node_web_user toneBlue
class node_flask_api,node_validation,node_event_detection,node_appliance_identification toneAmber
class node_event_store,node_signature_store,node_feedback_store,node_adaptive_learning toneMint
class node_dashboard toneRose
class node_electrical_load toneIndigo
```

## Components

### Sensing

- [ESP32 Sensing](https://github.com/acdeena1994/adaptive-nilm-with-human-in-the-loop-machine-learning/blob/main/esp32_code.ino): `esp32_code.ino`

### Backend Analytics

- [Flask Ingestion](https://github.com/acdeena1994/adaptive-nilm-with-human-in-the-loop-machine-learning/blob/main/main.py): `main.py`
- [Validation Controls](https://github.com/acdeena1994/adaptive-nilm-with-human-in-the-loop-machine-learning/blob/main/main.py): `main.py`
- [Event Detection](https://github.com/acdeena1994/adaptive-nilm-with-human-in-the-loop-machine-learning/blob/main/main.py): `main.py`
- [Appliance Matching](https://github.com/acdeena1994/adaptive-nilm-with-human-in-the-loop-machine-learning/blob/main/main.py): `main.py`

### Storage and Learning

- [Event and Data Store](https://github.com/acdeena1994/adaptive-nilm-with-human-in-the-loop-machine-learning/blob/main/main.py): `main.py`
- [Appliance Signatures](https://github.com/acdeena1994/adaptive-nilm-with-human-in-the-loop-machine-learning/blob/main/main.py): `main.py`
- [User Feedback](https://github.com/acdeena1994/adaptive-nilm-with-human-in-the-loop-machine-learning/blob/main/main.py): `main.py`
- [Adaptive Learning](https://github.com/acdeena1994/adaptive-nilm-with-human-in-the-loop-machine-learning/blob/main/main.py): `main.py`

### Dashboard

- [Web Dashboard](https://github.com/acdeena1994/adaptive-nilm-with-human-in-the-loop-machine-learning/blob/main/templates/index.html): `templates/index.html`

### Other components

- **Electrical Load**
- **Dashboard User**

## Connections

- Electrical Load → ESP32 Sensing: measures power (evidence: `README.md`)
- ESP32 Sensing → Flask Ingestion: posts readings (evidence: `README.md`)
- Flask Ingestion → Validation Controls: validates requests (evidence: `README.md`)
- Flask Ingestion → Event Detection: detects events (evidence: `README.md`)
- Event Detection → Appliance Matching: analyzes events (evidence: `README.md`)
- Appliance Matching → Appliance Signatures: matches signatures (evidence: `README.md`)
- Flask Ingestion → Event and Data Store: stores results (evidence: `README.md`)
- Appliance Matching → Event and Data Store: stores predictions (evidence: `README.md`)
- Event and Data Store → Web Dashboard: visualizes results (evidence: `README.md`)
- Dashboard User → Web Dashboard: views and labels (evidence: `README.md`)
- Web Dashboard → Flask Ingestion: submits labels (evidence: `README.md`)
- Flask Ingestion → User Feedback: stores labels (evidence: `README.md`)
- User Feedback → Adaptive Learning: updates signatures (evidence: `README.md`)
- Adaptive Learning → Appliance Signatures: improves matching (evidence: `README.md`)
