# nitish-singh123/electricity-consumption-analyzer architecture

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

- Interactive diagram: https://gitdiagram.com/nitish-singh123/electricity-consumption-analyzer
- Repository: https://github.com/nitish-singh123/electricity-consumption-analyzer

## Overview

The product is a local TCP electricity-consumption analyzer. Its main workflow loads CSV records in the client, sends JSON to the server, validates and enriches readings, then computes per-customer FSM paths, bills, trends, rankings, and budget advice for a printed report. SymPy calculations and functional transformations are internal server layers. README capabilities supplement the sampled source; edges below are limited to relationships shown in excerpts or documented there.

Main entry points: [`server.py`](https://github.com/nitish-singh123/electricity-consumption-analyzer/blob/master/server.py) (Analysis pipeline), [`client.py`](https://github.com/nitish-singh123/electricity-consumption-analyzer/blob/master/client.py) (TCP sender), [`dataset.csv`](https://github.com/nitish-singh123/electricity-consumption-analyzer/blob/master/dataset.csv) (CSV datasets)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client workflow"]
  node_loader["CSV loader<br/>[client.py]"]
  node_sender["TCP sender<br/>[client.py]"]
  node_report["Report printer<br/>[client.py]"]
end

subgraph group_analysis["Server analysis"]
  node_validation["Record validation<br/>[server.py]"]
  node_enrichment["Record enrichment<br/>[server.py]"]
  node_pipeline["Analysis pipeline<br/>[server.py]"]
  node_customer["Customer summaries<br/>[server.py]"]
  node_fsm["Consumption FSM<br/>[server.py]"]
  node_ranking["Customer ranking<br/>[server.py]"]
  node_billing["TOU billing<br/>[server.py]"]
end

subgraph group_symbolic["Symbolic calculations"]
  node_tariff["Slab tariff<br/>[server.py]"]
  node_trend["Trend prediction<br/>[server.py]"]
  node_budget["Budget break-even<br/>[server.py]"]
end

subgraph group_network["TCP service"]
  node_listener["TCP listener<br/>[server.py]"]
  node_handler["Request handler<br/>[server.py]"]
  node_client_socket["TCP client socket<br/>[client.py]"]
end

node_user(("Analyst"))
node_csv["CSV datasets<br/>[dataset.csv]"]
node_sympy["SymPy"]

node_user -->|"selects dataset"| node_loader
node_csv -->|"reads records"| node_loader
node_loader -->|"passes records"| node_sender
node_sender -->|"sends JSON"| node_client_socket
node_client_socket -->|"connects to"| node_listener
node_listener -->|"dispatches connection"| node_handler
node_handler -->|"analyzes records"| node_pipeline
node_pipeline -->|"filters records"| node_validation
node_pipeline -->|"enriches valid records"| node_enrichment
node_enrichment -->|"calculates TOU bill"| node_billing
node_pipeline -->|"builds summaries"| node_customer
node_customer -->|"walks daily usage"| node_fsm
node_customer -->|"fits and predicts"| node_trend
node_customer -->|"computes slab bill"| node_tariff
node_pipeline -->|"ranks customers"| node_ranking
node_pipeline -->|"solves budget limit"| node_budget
node_tariff -->|"uses symbolic math"| node_sympy
node_trend -->|"solves fit equations"| node_sympy
node_budget -->|"solves tariff branches"| node_sympy
node_handler -->|"returns JSON"| node_client_socket
node_sender -->|"prints analysis"| node_report
node_report -->|"presents report"| node_user

click node_csv "https://github.com/nitish-singh123/electricity-consumption-analyzer/blob/master/dataset.csv"
click node_loader "https://github.com/nitish-singh123/electricity-consumption-analyzer/blob/master/client.py"
click node_sender "https://github.com/nitish-singh123/electricity-consumption-analyzer/blob/master/client.py"
click node_report "https://github.com/nitish-singh123/electricity-consumption-analyzer/blob/master/client.py"
click node_listener "https://github.com/nitish-singh123/electricity-consumption-analyzer/blob/master/server.py"
click node_handler "https://github.com/nitish-singh123/electricity-consumption-analyzer/blob/master/server.py"
click node_validation "https://github.com/nitish-singh123/electricity-consumption-analyzer/blob/master/server.py"
click node_enrichment "https://github.com/nitish-singh123/electricity-consumption-analyzer/blob/master/server.py"
click node_pipeline "https://github.com/nitish-singh123/electricity-consumption-analyzer/blob/master/server.py"
click node_customer "https://github.com/nitish-singh123/electricity-consumption-analyzer/blob/master/server.py"
click node_fsm "https://github.com/nitish-singh123/electricity-consumption-analyzer/blob/master/server.py"
click node_ranking "https://github.com/nitish-singh123/electricity-consumption-analyzer/blob/master/server.py"
click node_billing "https://github.com/nitish-singh123/electricity-consumption-analyzer/blob/master/server.py"
click node_tariff "https://github.com/nitish-singh123/electricity-consumption-analyzer/blob/master/server.py"
click node_trend "https://github.com/nitish-singh123/electricity-consumption-analyzer/blob/master/server.py"
click node_budget "https://github.com/nitish-singh123/electricity-consumption-analyzer/blob/master/server.py"
click node_client_socket "https://github.com/nitish-singh123/electricity-consumption-analyzer/blob/master/client.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_loader,node_sender,node_report toneBlue
class node_validation,node_enrichment,node_pipeline,node_customer,node_fsm,node_ranking,node_billing toneAmber
class node_tariff,node_trend,node_budget toneMint
class node_listener,node_handler,node_client_socket toneRose
class node_user,node_sympy toneIndigo
class node_csv toneTeal
```

## Components

### Client workflow

- [CSV loader](https://github.com/nitish-singh123/electricity-consumption-analyzer/blob/master/client.py): `client.py`
- [TCP sender](https://github.com/nitish-singh123/electricity-consumption-analyzer/blob/master/client.py): `client.py`
- [Report printer](https://github.com/nitish-singh123/electricity-consumption-analyzer/blob/master/client.py): `client.py`

### Server analysis

- [Record validation](https://github.com/nitish-singh123/electricity-consumption-analyzer/blob/master/server.py): `server.py`
- [Record enrichment](https://github.com/nitish-singh123/electricity-consumption-analyzer/blob/master/server.py): `server.py`
- [Analysis pipeline](https://github.com/nitish-singh123/electricity-consumption-analyzer/blob/master/server.py): `server.py`
- [Customer summaries](https://github.com/nitish-singh123/electricity-consumption-analyzer/blob/master/server.py): `server.py`
- [Consumption FSM](https://github.com/nitish-singh123/electricity-consumption-analyzer/blob/master/server.py): `server.py`
- [Customer ranking](https://github.com/nitish-singh123/electricity-consumption-analyzer/blob/master/server.py): `server.py`
- [TOU billing](https://github.com/nitish-singh123/electricity-consumption-analyzer/blob/master/server.py): `server.py`

### Symbolic calculations

- [Slab tariff](https://github.com/nitish-singh123/electricity-consumption-analyzer/blob/master/server.py): `server.py`
- [Trend prediction](https://github.com/nitish-singh123/electricity-consumption-analyzer/blob/master/server.py): `server.py`
- [Budget break-even](https://github.com/nitish-singh123/electricity-consumption-analyzer/blob/master/server.py): `server.py`

### TCP service

- [TCP listener](https://github.com/nitish-singh123/electricity-consumption-analyzer/blob/master/server.py): `server.py`
- [Request handler](https://github.com/nitish-singh123/electricity-consumption-analyzer/blob/master/server.py): `server.py`
- [TCP client socket](https://github.com/nitish-singh123/electricity-consumption-analyzer/blob/master/client.py): `client.py`

### Other components

- **Analyst**
- [CSV datasets](https://github.com/nitish-singh123/electricity-consumption-analyzer/blob/master/dataset.csv): `dataset.csv`
- **SymPy**

## Connections

- Analyst → CSV loader: selects dataset (evidence: `client.py`)
- CSV datasets → CSV loader: reads records (evidence: `client.py`)
- CSV loader → TCP sender: passes records (evidence: `client.py`)
- TCP sender → TCP client socket: sends JSON (evidence: `client.py`)
- TCP client socket → TCP listener: connects to (evidence: `README.md`)
- TCP listener → Request handler: dispatches connection (evidence: `server.py`)
- Request handler → Analysis pipeline: analyzes records (evidence: `server.py`)
- Analysis pipeline → Record validation: filters records (evidence: `server.py`)
- Analysis pipeline → Record enrichment: enriches valid records (evidence: `server.py`)
- Record enrichment → TOU billing: calculates TOU bill (evidence: `server.py`)
- Analysis pipeline → Customer summaries: builds summaries (evidence: `server.py`)
- Customer summaries → Consumption FSM: walks daily usage (evidence: `README.md`)
- Customer summaries → Trend prediction: fits and predicts (evidence: `README.md`)
- Customer summaries → Slab tariff: computes slab bill (evidence: `README.md`)
- Analysis pipeline → Customer ranking: ranks customers (evidence: `README.md`)
- Analysis pipeline → Budget break-even: solves budget limit (evidence: `README.md`)
- Slab tariff → SymPy: uses symbolic math (evidence: `README.md`)
- Trend prediction → SymPy: solves fit equations (evidence: `README.md`)
- Budget break-even → SymPy: solves tariff branches (evidence: `README.md`)
- Request handler → TCP client socket: returns JSON (evidence: `README.md`)
- TCP sender → Report printer: prints analysis (evidence: `client.py`)
- Report printer → Analyst: presents report (evidence: `client.py`)
