# krishna99-tech/energymonitoringsoftware architecture

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

- Interactive diagram: https://gitdiagram.com/krishna99-tech/energymonitoringsoftware
- Repository: https://github.com/krishna99-tech/energymonitoringsoftware

## Overview

The primary product is a multi-device energy-monitoring application: meters send UDP snapshots, the FastAPI backend stores history and exposes live, summary, and export APIs, and a browser dashboard presents current readings and historical shift consumption. A separate New_EMS Flask application provides plant/meter-focused monitoring and analysis; sample_working_codes is an earlier standalone dashboard. The supplied excerpts do not show every route or frontend call, so links not established by the README or excerpts are omitted.

Main entry points: [`app_fastapi.py`](https://github.com/krishna99-tech/energymonitoringsoftware/blob/main/app_fastapi.py) (Energy history), [`static/dashboard.js`](https://github.com/krishna99-tech/energymonitoringsoftware/blob/main/static/dashboard.js) (Dashboard logic), [`dashboard.html`](https://github.com/krishna99-tech/energymonitoringsoftware/blob/main/dashboard.html) (Dashboard markup), [`New_EMS/app.py`](https://github.com/krishna99-tech/energymonitoringsoftware/blob/main/New_EMS/app.py) (Plant monitoring)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["Ingestion and storage"]
  node_udp["UDP receiver<br/>[app_fastapi.py]"]
  node_history[("Energy history<br/>[app_fastapi.py]")]
end

subgraph group_backend["Monitoring APIs"]
  node_fastapi["FastAPI service<br/>[app_fastapi.py]"]
  node_shiftcalc["Shift calculations<br/>[app_fastapi.py]"]
  node_deviceapi["Device APIs<br/>[app_fastapi.py]"]
  node_streamapi["Live stream<br/>[app_fastapi.py]"]
  node_reportapi["CSV reports<br/>[app_fastapi.py]"]
end

subgraph group_frontend["Dashboard experience"]
  node_dashboardhtml["Dashboard markup<br/>[dashboard.html]"]
  node_dashboardjs["Dashboard logic<br/>[dashboard.js]"]
  node_dashboardcss["Dashboard styles<br/>[styles_new.css]"]
end

subgraph group_legacy["Earlier applications"]
  node_plantapp["Plant monitoring<br/>[app.py]"]
  node_plantui["Plant dashboard logic<br/>[script.js]"]
  node_sampleapp["Standalone dashboard<br/>[main.py]"]
end

node_meters(("Meter devices"))
node_browser(("Dashboard user"))

node_meters -->|"sends snapshots"| node_udp
node_udp -->|"stores readings"| node_history
node_fastapi -->|"starts listener"| node_udp
node_fastapi -->|"initializes database"| node_history
node_deviceapi -->|"reads readings"| node_history
node_shiftcalc -->|"reads history"| node_history
node_deviceapi -->|"calculates summaries"| node_shiftcalc
node_streamapi -->|"reads snapshots"| node_history
node_reportapi -->|"queries history"| node_history
node_fastapi -->|"serves markup"| node_dashboardhtml
node_browser -->|"opens dashboard"| node_dashboardhtml
node_dashboardjs -->|"subscribes SSE"| node_streamapi
node_dashboardjs -->|"fetches summaries"| node_deviceapi
node_dashboardjs -->|"requests exports"| node_reportapi
node_dashboardhtml -->|"loads logic"| node_dashboardjs
node_dashboardhtml -->|"uses styling"| node_dashboardcss
node_meters -.->|"sends readings"| node_plantapp
node_plantui -.->|"requests plant data"| node_plantapp
node_meters -->|"sends UDP data"| node_sampleapp

click node_fastapi "https://github.com/krishna99-tech/energymonitoringsoftware/blob/main/app_fastapi.py"
click node_udp "https://github.com/krishna99-tech/energymonitoringsoftware/blob/main/app_fastapi.py"
click node_history "https://github.com/krishna99-tech/energymonitoringsoftware/blob/main/app_fastapi.py"
click node_shiftcalc "https://github.com/krishna99-tech/energymonitoringsoftware/blob/main/app_fastapi.py"
click node_deviceapi "https://github.com/krishna99-tech/energymonitoringsoftware/blob/main/app_fastapi.py"
click node_streamapi "https://github.com/krishna99-tech/energymonitoringsoftware/blob/main/app_fastapi.py"
click node_reportapi "https://github.com/krishna99-tech/energymonitoringsoftware/blob/main/app_fastapi.py"
click node_dashboardhtml "https://github.com/krishna99-tech/energymonitoringsoftware/blob/main/dashboard.html"
click node_dashboardjs "https://github.com/krishna99-tech/energymonitoringsoftware/blob/main/static/dashboard.js"
click node_dashboardcss "https://github.com/krishna99-tech/energymonitoringsoftware/blob/main/static/styles_new.css"
click node_plantapp "https://github.com/krishna99-tech/energymonitoringsoftware/blob/main/New_EMS/app.py"
click node_plantui "https://github.com/krishna99-tech/energymonitoringsoftware/blob/main/New_EMS/static/script.js"
click node_sampleapp "https://github.com/krishna99-tech/energymonitoringsoftware/blob/main/sample_working_codes/main.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_udp,node_history,node_browser toneBlue
class node_fastapi,node_shiftcalc,node_deviceapi,node_streamapi,node_reportapi toneAmber
class node_dashboardhtml,node_dashboardjs,node_dashboardcss toneMint
class node_plantapp,node_plantui,node_sampleapp toneRose
class node_meters toneIndigo
```

## Components

### Ingestion and storage

- [UDP receiver](https://github.com/krishna99-tech/energymonitoringsoftware/blob/main/app_fastapi.py): `app_fastapi.py`
- [Energy history](https://github.com/krishna99-tech/energymonitoringsoftware/blob/main/app_fastapi.py): `app_fastapi.py`

### Monitoring APIs

- [FastAPI service](https://github.com/krishna99-tech/energymonitoringsoftware/blob/main/app_fastapi.py): `app_fastapi.py`
- [Shift calculations](https://github.com/krishna99-tech/energymonitoringsoftware/blob/main/app_fastapi.py): `app_fastapi.py`
- [Device APIs](https://github.com/krishna99-tech/energymonitoringsoftware/blob/main/app_fastapi.py): `app_fastapi.py`
- [Live stream](https://github.com/krishna99-tech/energymonitoringsoftware/blob/main/app_fastapi.py): `app_fastapi.py`
- [CSV reports](https://github.com/krishna99-tech/energymonitoringsoftware/blob/main/app_fastapi.py): `app_fastapi.py`

### Dashboard experience

- [Dashboard markup](https://github.com/krishna99-tech/energymonitoringsoftware/blob/main/dashboard.html): `dashboard.html`
- [Dashboard logic](https://github.com/krishna99-tech/energymonitoringsoftware/blob/main/static/dashboard.js): `static/dashboard.js`
- [Dashboard styles](https://github.com/krishna99-tech/energymonitoringsoftware/blob/main/static/styles_new.css): `static/styles_new.css`

### Earlier applications

- [Plant monitoring](https://github.com/krishna99-tech/energymonitoringsoftware/blob/main/New_EMS/app.py): `New_EMS/app.py`
- [Plant dashboard logic](https://github.com/krishna99-tech/energymonitoringsoftware/blob/main/New_EMS/static/script.js): `New_EMS/static/script.js`
- [Standalone dashboard](https://github.com/krishna99-tech/energymonitoringsoftware/blob/main/sample_working_codes/main.py): `sample_working_codes/main.py`

### Other components

- **Meter devices**
- **Dashboard user**

## Connections

- Meter devices → UDP receiver: sends snapshots (evidence: `README.md`)
- UDP receiver → Energy history: stores readings (evidence: `app_fastapi.py`)
- FastAPI service → UDP receiver: starts listener (evidence: `app_fastapi.py`)
- FastAPI service → Energy history: initializes database (evidence: `app_fastapi.py`)
- Device APIs → Energy history: reads readings (evidence: `app_fastapi.py`)
- Shift calculations → Energy history: reads history (evidence: `README.md`)
- Device APIs → Shift calculations: calculates summaries (evidence: `app_fastapi.py`)
- Live stream → Energy history: reads snapshots (evidence: `app_fastapi.py`)
- CSV reports → Energy history: queries history (evidence: `app_fastapi.py`)
- FastAPI service → Dashboard markup: serves markup (evidence: `app_fastapi.py`)
- Dashboard user → Dashboard markup: opens dashboard (evidence: `README.md`)
- Dashboard logic → Live stream: subscribes SSE (evidence: `static/dashboard.js`)
- Dashboard logic → Device APIs: fetches summaries (evidence: `static/dashboard.js`)
- Dashboard logic → CSV reports: requests exports (evidence: `README.md`)
- Dashboard markup → Dashboard logic: loads logic (evidence: `README.md`)
- Dashboard markup → Dashboard styles: uses styling (evidence: `README.md`)
- Meter devices → Plant monitoring: sends readings
- Plant dashboard logic → Plant monitoring: requests plant data
- Meter devices → Standalone dashboard: sends UDP data (evidence: `sample_working_codes/main.py`)
