# duyu09/powerload-classification-and-prediction-system architecture

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

- Interactive diagram: https://gitdiagram.com/duyu09/powerload-classification-and-prediction-system
- Repository: https://github.com/duyu09/powerload-classification-and-prediction-system

## Overview

This repository implements a non-intrusive power-load monitoring system: a client requests current measurements, appliance classifications, and short-term forecasts through backend services. The documented runtime combines a C++ HTTP server and SQLite storage with Python AI services; the README also describes a WeChat client, power-meter inputs, and classification/prediction stages. Source evidence is strongest for the C++ server, its database access, and Python prediction entry points. Some documented integrations and unsampled service wiring are therefore shown only as dashed, unverified links.

Main entry points: [`CPP_backend/src/server/webserver.cpp`](https://github.com/duyu09/powerload-classification-and-prediction-system/blob/main/CPP_backend/src/server/webserver.cpp) (Web server), [`CPP_backend/src/http/httpconnect.cpp`](https://github.com/duyu09/powerload-classification-and-prediction-system/blob/main/CPP_backend/src/http/httpconnect.cpp) (HTTP connection), [`Python_backend/prediction/prediction.py`](https://github.com/duyu09/powerload-classification-and-prediction-system/blob/main/Python_backend/prediction/prediction.py) (Load prediction), [`Python_backend/classify/Classification_Test_v6.3.py`](https://github.com/duyu09/powerload-classification-and-prediction-system/blob/main/Python_backend/classify/Classification_Test_v6.3.py) (Load classification)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cpp["C++ HTTP backend"]
  node_main["Server entry<br/>[main.cpp]"]
  node_server["Web server<br/>[webserver.cpp]"]
  node_connection["HTTP connection<br/>[httpconnect.cpp]"]
  node_request["Request parser<br/>[httprequest.cpp]"]
  node_response["API responses<br/>[httpresponse.h]"]
  node_buffer["I/O buffers<br/>[buffer.cpp]"]
  node_epoller["I/O multiplexer<br/>[epoller.cpp]"]
  node_threadpool["Worker pool<br/>[threadpool.cpp]"]
  node_timer["Connection timers<br/>[timer.h]"]
  node_logger["Async logging<br/>[log.cpp]"]
end

subgraph group_storage["Power data storage"]
  node_database[("SQLite access<br/>[database.cpp]")]
  node_storefile[("Power-load database<br/>[powerload.db]")]
end

subgraph group_ai["AI processing"]
  node_classification["Load classification"]
  node_prediction["Load prediction<br/>[prediction.py]"]
  node_arima["ARIMA comparison<br/>[arima.py]"]
end

subgraph group_service["Python services"]
  node_pythonapi["Python API services<br/>[app.py]"]
  node_backendapi["Backend service<br/>[app-backend.py]"]
  node_mqbackend["MQ backend service<br/>[app-backend-mq.py]"]
  node_aiapi["AI API services<br/>[app-ai.py]"]
  node_mqai["MQ AI service<br/>[app-ai-mq.py]"]
end

node_client(("WeChat client"))
node_meter(("Power meter"))

node_client -.->|"requests data"| node_main
node_meter -.->|"supplies readings"| node_classification
node_main -->|"starts"| node_server
node_server -->|"manages connections"| node_connection
node_server -->|"dispatches I/O"| node_epoller
node_server -->|"uses workers"| node_threadpool
node_server -->|"manages timeouts"| node_timer
node_connection -->|"parses requests"| node_request
node_connection -->|"builds responses"| node_response
node_connection -->|"buffers I/O"| node_buffer
node_response -->|"queries and registers"| node_database
node_database -->|"logs operations"| node_logger
node_aiapi -->|"uses forecaster"| node_prediction
node_mqai -->|"uses forecaster"| node_prediction
node_aiapi -.->|"runs classification"| node_classification
node_backendapi -.->|"persists readings"| node_storefile
node_mqbackend -.->|"persists readings"| node_storefile
node_mqbackend -.->|"coordinates AI jobs"| node_mqai
node_classification -.->|"provides appliance labels"| node_prediction
node_arima -.->|"compares forecasts"| node_prediction

click node_main "https://github.com/duyu09/powerload-classification-and-prediction-system/blob/main/CPP_backend/main.cpp"
click node_server "https://github.com/duyu09/powerload-classification-and-prediction-system/blob/main/CPP_backend/src/server/webserver.cpp"
click node_connection "https://github.com/duyu09/powerload-classification-and-prediction-system/blob/main/CPP_backend/src/http/httpconnect.cpp"
click node_request "https://github.com/duyu09/powerload-classification-and-prediction-system/blob/main/CPP_backend/src/http/httprequest.cpp"
click node_response "https://github.com/duyu09/powerload-classification-and-prediction-system/blob/main/CPP_backend/src/http/httpresponse.h"
click node_buffer "https://github.com/duyu09/powerload-classification-and-prediction-system/blob/main/CPP_backend/src/buffer/buffer.cpp"
click node_epoller "https://github.com/duyu09/powerload-classification-and-prediction-system/blob/main/CPP_backend/src/server/epoller.cpp"
click node_threadpool "https://github.com/duyu09/powerload-classification-and-prediction-system/blob/main/CPP_backend/src/pool/threadpool.cpp"
click node_timer "https://github.com/duyu09/powerload-classification-and-prediction-system/blob/main/CPP_backend/src/timer/timer.h"
click node_logger "https://github.com/duyu09/powerload-classification-and-prediction-system/blob/main/CPP_backend/src/log/log.cpp"
click node_database "https://github.com/duyu09/powerload-classification-and-prediction-system/blob/main/CPP_backend/src/database/database.cpp"
click node_pythonapi "https://github.com/duyu09/powerload-classification-and-prediction-system/blob/main/Python_backend/app.py"
click node_backendapi "https://github.com/duyu09/powerload-classification-and-prediction-system/blob/main/Python_backend/app-backend.py"
click node_mqbackend "https://github.com/duyu09/powerload-classification-and-prediction-system/blob/main/Python_backend/app-backend-mq.py"
click node_aiapi "https://github.com/duyu09/powerload-classification-and-prediction-system/blob/main/Python_backend/app-ai.py"
click node_mqai "https://github.com/duyu09/powerload-classification-and-prediction-system/blob/main/Python_backend/app-ai-mq.py"
click node_classification "https://github.com/duyu09/powerload-classification-and-prediction-system/blob/main/Python_backend/classify/Classification_Test_v6.3.py"
click node_prediction "https://github.com/duyu09/powerload-classification-and-prediction-system/blob/main/Python_backend/prediction/prediction.py"
click node_arima "https://github.com/duyu09/powerload-classification-and-prediction-system/blob/main/Python_backend/compare/arima.py"
click node_storefile "https://github.com/duyu09/powerload-classification-and-prediction-system/blob/main/Python_backend/powerload.db"

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_main,node_server,node_connection,node_request,node_response,node_buffer,node_epoller,node_threadpool,node_timer,node_logger,node_client toneBlue
class node_database,node_storefile toneAmber
class node_classification,node_prediction,node_arima toneMint
class node_pythonapi,node_backendapi,node_mqbackend,node_aiapi,node_mqai toneRose
class node_meter toneIndigo
```

## Components

### C++ HTTP backend

- [Server entry](https://github.com/duyu09/powerload-classification-and-prediction-system/blob/main/CPP_backend/main.cpp): `CPP_backend/main.cpp`
- [Web server](https://github.com/duyu09/powerload-classification-and-prediction-system/blob/main/CPP_backend/src/server/webserver.cpp): `CPP_backend/src/server/webserver.cpp`
- [HTTP connection](https://github.com/duyu09/powerload-classification-and-prediction-system/blob/main/CPP_backend/src/http/httpconnect.cpp): `CPP_backend/src/http/httpconnect.cpp`
- [Request parser](https://github.com/duyu09/powerload-classification-and-prediction-system/blob/main/CPP_backend/src/http/httprequest.cpp): `CPP_backend/src/http/httprequest.cpp`
- [API responses](https://github.com/duyu09/powerload-classification-and-prediction-system/blob/main/CPP_backend/src/http/httpresponse.h): `CPP_backend/src/http/httpresponse.h`
- [I/O buffers](https://github.com/duyu09/powerload-classification-and-prediction-system/blob/main/CPP_backend/src/buffer/buffer.cpp): `CPP_backend/src/buffer/buffer.cpp`
- [I/O multiplexer](https://github.com/duyu09/powerload-classification-and-prediction-system/blob/main/CPP_backend/src/server/epoller.cpp): `CPP_backend/src/server/epoller.cpp`
- [Worker pool](https://github.com/duyu09/powerload-classification-and-prediction-system/blob/main/CPP_backend/src/pool/threadpool.cpp): `CPP_backend/src/pool/threadpool.cpp`
- [Connection timers](https://github.com/duyu09/powerload-classification-and-prediction-system/blob/main/CPP_backend/src/timer/timer.h): `CPP_backend/src/timer/timer.h`
- [Async logging](https://github.com/duyu09/powerload-classification-and-prediction-system/blob/main/CPP_backend/src/log/log.cpp): `CPP_backend/src/log/log.cpp`

### Power data storage

- [SQLite access](https://github.com/duyu09/powerload-classification-and-prediction-system/blob/main/CPP_backend/src/database/database.cpp): `CPP_backend/src/database/database.cpp`
- [Power-load database](https://github.com/duyu09/powerload-classification-and-prediction-system/blob/main/Python_backend/powerload.db): `Python_backend/powerload.db`

### AI processing

- [Load classification](https://github.com/duyu09/powerload-classification-and-prediction-system/blob/main/Python_backend/classify/Classification_Test_v6.3.py): `Python_backend/classify/Classification_Test_v6.3.py`
- [Load prediction](https://github.com/duyu09/powerload-classification-and-prediction-system/blob/main/Python_backend/prediction/prediction.py): `Python_backend/prediction/prediction.py`
- [ARIMA comparison](https://github.com/duyu09/powerload-classification-and-prediction-system/blob/main/Python_backend/compare/arima.py): `Python_backend/compare/arima.py`

### Python services

- [Python API services](https://github.com/duyu09/powerload-classification-and-prediction-system/blob/main/Python_backend/app.py): `Python_backend/app.py`
- [Backend service](https://github.com/duyu09/powerload-classification-and-prediction-system/blob/main/Python_backend/app-backend.py): `Python_backend/app-backend.py`
- [MQ backend service](https://github.com/duyu09/powerload-classification-and-prediction-system/blob/main/Python_backend/app-backend-mq.py): `Python_backend/app-backend-mq.py`
- [AI API services](https://github.com/duyu09/powerload-classification-and-prediction-system/blob/main/Python_backend/app-ai.py): `Python_backend/app-ai.py`
- [MQ AI service](https://github.com/duyu09/powerload-classification-and-prediction-system/blob/main/Python_backend/app-ai-mq.py): `Python_backend/app-ai-mq.py`

### Other components

- **WeChat client**
- **Power meter**

## Connections

- WeChat client → Server entry: requests data (evidence: `README.md`)
- Power meter → Load classification: supplies readings (evidence: `README.md`)
- Server entry → Web server: starts (evidence: `CPP_backend/main.cpp`)
- Web server → HTTP connection: manages connections
- Web server → I/O multiplexer: dispatches I/O
- Web server → Worker pool: uses workers
- Web server → Connection timers: manages timeouts
- HTTP connection → Request parser: parses requests
- HTTP connection → API responses: builds responses
- HTTP connection → I/O buffers: buffers I/O
- API responses → SQLite access: queries and registers (evidence: `CPP_backend/src/http/httpresponse.h`)
- SQLite access → Async logging: logs operations
- AI API services → Load prediction: uses forecaster (evidence: `Python_backend/app-ai.py`)
- MQ AI service → Load prediction: uses forecaster (evidence: `Python_backend/app-ai-mq.py`)
- AI API services → Load classification: runs classification
- Backend service → Power-load database: persists readings
- MQ backend service → Power-load database: persists readings
- MQ backend service → MQ AI service: coordinates AI jobs
- Load classification → Load prediction: provides appliance labels (evidence: `README.md`)
- ARIMA comparison → Load prediction: compares forecasts (evidence: `README.md`)
