# adityaph-17/electricity_consumption_anomaly_detection_system architecture

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

- Interactive diagram: https://gitdiagram.com/adityaph-17/electricity_consumption_anomaly_detection_system
- Repository: https://github.com/adityaph-17/electricity_consumption_anomaly_detection_system

## Overview

WattWatch is a Flask web application for analyzing uploaded electricity-consumption CSVs. A browser submits a file and detector settings; Flask orchestrates column mapping, cleaning, baseline statistics, three detection methods, consensus voting, optional label-based evaluation, and CSV export, then returns analysis for dashboard visualization. The README also documents a sample-CSV download route. The pipeline and UI links are supported by the shown Flask and JavaScript excerpts; dashboard visualization details are partly documented in the README.

Main entry points: [`app.py`](https://github.com/adityaph-17/electricity_consumption_anomaly_detection_system/blob/main/app.py) (Flask API), [`static/script.js`](https://github.com/adityaph-17/electricity_consumption_anomaly_detection_system/blob/main/static/script.js) (Upload and dashboard), [`step8_export.py`](https://github.com/adityaph-17/electricity_consumption_anomaly_detection_system/blob/main/step8_export.py) (CSV export), [`templates/index.html`](https://github.com/adityaph-17/electricity_consumption_anomaly_detection_system/blob/main/templates/index.html) (Dashboard page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web interface"]
  node_client_ui["Upload and dashboard<br/>[script.js]"]
  node_dashboard_template["Dashboard page<br/>[index.html]"]
end

subgraph group_orchestration["Pipeline orchestration"]
  node_flask_app["Flask API<br/>[app.py]"]
end

subgraph group_analysis["Consumption analysis"]
  node_csv_upload["CSV mapping<br/>[step1_upload.py]"]
  node_data_cleaning["Data cleaning"]
  node_baseline_stats["Baseline statistics"]
  node_detectors["Anomaly detectors<br/>[step4_detection.py]"]
  node_consensus["Consensus voting<br/>[step5_compare.py]"]
end

subgraph group_outputs["Results and reporting"]
  node_evaluation["Label evaluation<br/>[step7_evaluate.py]"]
  node_csv_export["CSV export<br/>[step8_export.py]"]
  node_result_csv["Exported results"]
  node_sample_csv["Sample CSV download"]
end

node_browser_user(("Browser user"))

node_browser_user -->|"uses"| node_client_ui
node_client_ui -->|"posts analysis"| node_flask_app
node_flask_app -->|"renders"| node_dashboard_template
node_flask_app -->|"loads CSV"| node_csv_upload
node_flask_app -->|"cleans records"| node_data_cleaning
node_flask_app -->|"calculates baseline"| node_baseline_stats
node_flask_app -->|"detects anomalies"| node_detectors
node_flask_app -->|"compares methods"| node_consensus
node_flask_app -->|"evaluates labels"| node_evaluation
node_flask_app -->|"exports results"| node_csv_export
node_csv_export -->|"writes CSV"| node_result_csv
node_client_ui -.->|"requests download"| node_flask_app
node_flask_app -->|"serves download"| node_result_csv
node_flask_app -->|"serves sample"| node_sample_csv
node_flask_app -->|"returns analysis"| node_client_ui

click node_client_ui "https://github.com/adityaph-17/electricity_consumption_anomaly_detection_system/blob/main/static/script.js"
click node_dashboard_template "https://github.com/adityaph-17/electricity_consumption_anomaly_detection_system/blob/main/templates/index.html"
click node_flask_app "https://github.com/adityaph-17/electricity_consumption_anomaly_detection_system/blob/main/app.py"
click node_csv_upload "https://github.com/adityaph-17/electricity_consumption_anomaly_detection_system/blob/main/step1_upload.py"
click node_data_cleaning "https://github.com/adityaph-17/electricity_consumption_anomaly_detection_system/blob/main/step2_preprocess.py"
click node_baseline_stats "https://github.com/adityaph-17/electricity_consumption_anomaly_detection_system/blob/main/step3_statistics.py"
click node_detectors "https://github.com/adityaph-17/electricity_consumption_anomaly_detection_system/blob/main/step4_detection.py"
click node_consensus "https://github.com/adityaph-17/electricity_consumption_anomaly_detection_system/blob/main/step5_compare.py"
click node_evaluation "https://github.com/adityaph-17/electricity_consumption_anomaly_detection_system/blob/main/step7_evaluate.py"
click node_csv_export "https://github.com/adityaph-17/electricity_consumption_anomaly_detection_system/blob/main/step8_export.py"

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_client_ui,node_dashboard_template,node_browser_user toneBlue
class node_flask_app toneAmber
class node_csv_upload,node_data_cleaning,node_baseline_stats,node_detectors,node_consensus toneMint
class node_evaluation,node_csv_export,node_result_csv,node_sample_csv toneRose
```

## Components

### Web interface

- [Upload and dashboard](https://github.com/adityaph-17/electricity_consumption_anomaly_detection_system/blob/main/static/script.js): `static/script.js`
- [Dashboard page](https://github.com/adityaph-17/electricity_consumption_anomaly_detection_system/blob/main/templates/index.html): `templates/index.html`

### Pipeline orchestration

- [Flask API](https://github.com/adityaph-17/electricity_consumption_anomaly_detection_system/blob/main/app.py): `app.py`

### Consumption analysis

- [CSV mapping](https://github.com/adityaph-17/electricity_consumption_anomaly_detection_system/blob/main/step1_upload.py): `step1_upload.py`
- [Data cleaning](https://github.com/adityaph-17/electricity_consumption_anomaly_detection_system/blob/main/step2_preprocess.py): `step2_preprocess.py`
- [Baseline statistics](https://github.com/adityaph-17/electricity_consumption_anomaly_detection_system/blob/main/step3_statistics.py): `step3_statistics.py`
- [Anomaly detectors](https://github.com/adityaph-17/electricity_consumption_anomaly_detection_system/blob/main/step4_detection.py): `step4_detection.py`
- [Consensus voting](https://github.com/adityaph-17/electricity_consumption_anomaly_detection_system/blob/main/step5_compare.py): `step5_compare.py`

### Results and reporting

- [Label evaluation](https://github.com/adityaph-17/electricity_consumption_anomaly_detection_system/blob/main/step7_evaluate.py): `step7_evaluate.py`
- [CSV export](https://github.com/adityaph-17/electricity_consumption_anomaly_detection_system/blob/main/step8_export.py): `step8_export.py`
- **Exported results**
- **Sample CSV download**

### Other components

- **Browser user**

## Connections

- Browser user → Upload and dashboard: uses (evidence: `README.md`)
- Upload and dashboard → Flask API: posts analysis (evidence: `static/script.js`)
- Flask API → Dashboard page: renders (evidence: `app.py`)
- Flask API → CSV mapping: loads CSV (evidence: `app.py`)
- Flask API → Data cleaning: cleans records (evidence: `app.py`)
- Flask API → Baseline statistics: calculates baseline (evidence: `app.py`)
- Flask API → Anomaly detectors: detects anomalies (evidence: `app.py`)
- Flask API → Consensus voting: compares methods (evidence: `app.py`)
- Flask API → Label evaluation: evaluates labels (evidence: `app.py`)
- Flask API → CSV export: exports results (evidence: `app.py`)
- CSV export → Exported results: writes CSV (evidence: `step8_export.py`)
- Upload and dashboard → Flask API: requests download
- Flask API → Exported results: serves download (evidence: `app.py`)
- Flask API → Sample CSV download: serves sample (evidence: `app.py`)
- Flask API → Upload and dashboard: returns analysis (evidence: `app.py`)
