# acdeena1994/smart-energy-management-system-using-yolov8-and-iot architecture

> Architecture diagram of the GitHub repository acdeena1994/smart-energy-management-system-using-yolov8-and-iot, 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/smart-energy-management-system-using-yolov8-and-iot
- Repository: https://github.com/acdeena1994/smart-energy-management-system-using-yolov8-and-iot

## Overview

This is an intelligent-building occupancy and appliance-control system. Its main workflow acquires an IP-camera stream, uses YOLOv8 to count people, applies automatic thresholds, and sends appliance commands to an ESP32; counts are also persisted. The Flask application exposes count, stream, device, and network functions, with Socket.IO updates visible in the sampled source. README-described capabilities include delayed switching and relay control, but the excerpts do not establish their precise implementation or the template’s client-side wiring.

Main entry points: [`main.py`](https://github.com/acdeena1994/smart-energy-management-system-using-yolov8-and-iot/blob/main/main.py) (Occupancy Count), [`templates/index.html`](https://github.com/acdeena1994/smart-energy-management-system-using-yolov8-and-iot/blob/main/templates/index.html) (Web Interface), [`human_count/human_count.ino`](https://github.com/acdeena1994/smart-energy-management-system-using-yolov8-and-iot/blob/main/human_count/human_count.ino) (ESP32 Firmware), [`headcount.db`](https://github.com/acdeena1994/smart-energy-management-system-using-yolov8-and-iot/blob/main/headcount.db) (Count Database)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_vision["Occupancy Detection"]
  node_vision_worker["Stream and YOLO<br/>[main.py]"]
  node_occupancy["Occupancy Count<br/>[main.py]"]
end

subgraph group_control["Building Control"]
  node_automation["Automatic Decisions<br/>[main.py]"]
  node_device_state["Device State<br/>[main.py]"]
end

subgraph group_app["Application Services"]
  node_count_store[("Count Database<br/>[headcount.db]")]
  node_web_services["Flask and Socket.IO<br/>[main.py]"]
  node_web_template["Web Interface<br/>[index.html]"]
end

subgraph group_hardware["Controller Hardware"]
  node_appliances["Lights and Fans"]
  node_esp_firmware["ESP32 Firmware<br/>[human_count.ino]"]
  node_esp_controller["ESP32 Controller"]
end

node_camera(("IP Camera"))
node_operator(("Building Operator"))

node_camera -->|"streams video"| node_vision_worker
node_vision_worker -->|"counts people"| node_occupancy
node_occupancy -->|"emits updates"| node_web_services
node_occupancy -->|"writes counts"| node_count_store
node_occupancy -->|"supplies count"| node_automation
node_automation -->|"updates state"| node_device_state
node_automation -->|"sends commands"| node_esp_controller
node_esp_controller -->|"controls remotely"| node_esp_firmware
node_esp_firmware -->|"switches relays"| node_appliances
node_operator -.->|"uses interface"| node_web_template
node_web_template -.->|"requests services"| node_web_services

click node_vision_worker "https://github.com/acdeena1994/smart-energy-management-system-using-yolov8-and-iot/blob/main/main.py"
click node_occupancy "https://github.com/acdeena1994/smart-energy-management-system-using-yolov8-and-iot/blob/main/main.py"
click node_automation "https://github.com/acdeena1994/smart-energy-management-system-using-yolov8-and-iot/blob/main/main.py"
click node_device_state "https://github.com/acdeena1994/smart-energy-management-system-using-yolov8-and-iot/blob/main/main.py"
click node_esp_firmware "https://github.com/acdeena1994/smart-energy-management-system-using-yolov8-and-iot/blob/main/human_count/human_count.ino"
click node_count_store "https://github.com/acdeena1994/smart-energy-management-system-using-yolov8-and-iot/blob/main/headcount.db"
click node_web_services "https://github.com/acdeena1994/smart-energy-management-system-using-yolov8-and-iot/blob/main/main.py"
click node_web_template "https://github.com/acdeena1994/smart-energy-management-system-using-yolov8-and-iot/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_vision_worker,node_occupancy toneBlue
class node_automation,node_device_state toneAmber
class node_count_store,node_web_services,node_web_template toneMint
class node_appliances,node_esp_firmware,node_esp_controller toneRose
class node_camera,node_operator toneIndigo
```

## Components

### Occupancy Detection

- [Stream and YOLO](https://github.com/acdeena1994/smart-energy-management-system-using-yolov8-and-iot/blob/main/main.py): `main.py`
- [Occupancy Count](https://github.com/acdeena1994/smart-energy-management-system-using-yolov8-and-iot/blob/main/main.py): `main.py`

### Building Control

- [Automatic Decisions](https://github.com/acdeena1994/smart-energy-management-system-using-yolov8-and-iot/blob/main/main.py): `main.py`
- [Device State](https://github.com/acdeena1994/smart-energy-management-system-using-yolov8-and-iot/blob/main/main.py): `main.py`

### Application Services

- [Count Database](https://github.com/acdeena1994/smart-energy-management-system-using-yolov8-and-iot/blob/main/headcount.db): `headcount.db`
- [Flask and Socket.IO](https://github.com/acdeena1994/smart-energy-management-system-using-yolov8-and-iot/blob/main/main.py): `main.py`
- [Web Interface](https://github.com/acdeena1994/smart-energy-management-system-using-yolov8-and-iot/blob/main/templates/index.html): `templates/index.html`

### Controller Hardware

- **Lights and Fans**
- [ESP32 Firmware](https://github.com/acdeena1994/smart-energy-management-system-using-yolov8-and-iot/blob/main/human_count/human_count.ino): `human_count/human_count.ino`
- **ESP32 Controller**

### Other components

- **IP Camera**
- **Building Operator**

## Connections

- IP Camera → Stream and YOLO: streams video (evidence: `README.md`)
- Stream and YOLO → Occupancy Count: counts people (evidence: `main.py`)
- Occupancy Count → Flask and Socket.IO: emits updates (evidence: `main.py`)
- Occupancy Count → Count Database: writes counts (evidence: `main.py`)
- Occupancy Count → Automatic Decisions: supplies count (evidence: `main.py`)
- Automatic Decisions → Device State: updates state (evidence: `main.py`)
- Automatic Decisions → ESP32 Controller: sends commands (evidence: `main.py`)
- ESP32 Controller → ESP32 Firmware: controls remotely (evidence: `README.md`)
- ESP32 Firmware → Lights and Fans: switches relays (evidence: `README.md`)
- Building Operator → Web Interface: uses interface
- Web Interface → Flask and Socket.IO: requests services
