# buddhaakash/eco-energy architecture

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

- Interactive diagram: https://gitdiagram.com/buddhaakash/eco-energy
- Repository: https://github.com/buddhaakash/eco-energy

## Overview

EcoEnergy is a dashboard for turning household or small-office meter readings into ranked, estimated-savings actions. The main workflow is selecting or uploading a dataset, running statistical leak detection and savings analysis, then reviewing findings; separate dashboard features check bills, answer questions, and export reports. The Streamlit UI calls a FastAPI backend, with SQLAlchemy models and a configured database for persisted data. Source excerpts show the analysis pipeline and bill-check flow; some route and tab internals are represented only by indexed references, so their internal links are limited accordingly.

Main entry points: [`frontend/app.py`](https://github.com/buddhaakash/eco-energy/blob/main/frontend/app.py) (Streamlit app), [`backend/main.py`](https://github.com/buddhaakash/eco-energy/blob/main/backend/main.py) (FastAPI app), [`backend/services/pipeline_service.py`](https://github.com/buddhaakash/eco-energy/blob/main/backend/services/pipeline_service.py) (Analysis pipeline), [`frontend/api_client.py`](https://github.com/buddhaakash/eco-energy/blob/main/frontend/api_client.py) (HTTP client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_dashboard["Dashboard"]
  node_ui["Streamlit app<br/>[app.py]"]
  node_data_tab["Data upload<br/>[tab_data.py]"]
  node_anomaly_tab["Anomaly review<br/>[tab_anomalies.py]"]
  node_savings_tab["Savings plan<br/>[tab_savings.py]"]
  node_bill_tab["Bill check UI<br/>[tab_bill_check.py]"]
  node_chat_tab["AI chat<br/>[tab_chat.py]"]
  node_api_client["HTTP client<br/>[api_client.py]"]
end

subgraph group_api["API"]
  node_fastapi["FastAPI app<br/>[main.py]"]
  node_dataset_routes["Dataset routes<br/>[datasets.py]"]
  node_analysis_routes["Analysis routes<br/>[analysis.py]"]
  node_other_routes["Other API routes"]
end

subgraph group_analysis["Leak Analysis"]
  node_pipeline["Analysis pipeline"]
  node_detector["Anomaly detection<br/>[anomaly_service.py]"]
  node_savings["Savings actions<br/>[savings_service.py]"]
  node_advisor["Anomaly explanations<br/>[advisor_service.py]"]
end

subgraph group_bill["Bill Checks"]
  node_bill_routes["Bill-check routes<br/>[bill.py]"]
  node_bill_service["Bill comparison<br/>[bill_service.py]"]
  node_bill_extract["Bill extraction"]
end

subgraph group_data["Persistence &amp; AI"]
  node_csv_parser["CSV parser<br/>[ingest_service.py]"]
  node_database[("SQL database<br/>[database.py]")]
  node_models["Stored records<br/>[models.py]"]
  node_llm["Gemini API"]
end

node_user(("Energy user"))

node_user -->|"uses dashboard"| node_ui
node_ui -->|"renders"| node_data_tab
node_ui -->|"renders"| node_anomaly_tab
node_ui -->|"renders"| node_savings_tab
node_ui -->|"renders"| node_bill_tab
node_ui -->|"renders"| node_chat_tab
node_data_tab -->|"calls"| node_api_client
node_anomaly_tab -->|"calls"| node_api_client
node_savings_tab -->|"calls"| node_api_client
node_bill_tab -->|"calls"| node_api_client
node_chat_tab -->|"calls"| node_api_client
node_api_client -->|"HTTP requests"| node_fastapi
node_fastapi -->|"registers"| node_dataset_routes
node_fastapi -->|"registers"| node_analysis_routes
node_fastapi -->|"registers"| node_other_routes
node_fastapi -->|"registers"| node_bill_routes
node_dataset_routes -->|"parses upload"| node_csv_parser
node_dataset_routes -->|"runs analysis"| node_pipeline
node_analysis_routes -->|"runs analysis"| node_pipeline
node_pipeline -->|"detects events"| node_detector
node_pipeline -->|"requests explanations"| node_advisor
node_pipeline -->|"builds actions"| node_savings
node_advisor -->|"requests narration"| node_llm
node_bill_routes -->|"extracts bill fields"| node_bill_extract
node_bill_routes -->|"compares readings"| node_bill_service
node_bill_routes -.->|"requests bill narration"| node_llm
node_fastapi -->|"initializes"| node_database
node_database -->|"registers tables"| node_models
node_pipeline -->|"reads and writes"| node_models
node_bill_routes -->|"reads and writes"| node_models
node_bill_extract -->|"extracts with AI"| node_llm

click node_ui "https://github.com/buddhaakash/eco-energy/blob/main/frontend/app.py"
click node_data_tab "https://github.com/buddhaakash/eco-energy/blob/main/frontend/components/tab_data.py"
click node_anomaly_tab "https://github.com/buddhaakash/eco-energy/blob/main/frontend/components/tab_anomalies.py"
click node_savings_tab "https://github.com/buddhaakash/eco-energy/blob/main/frontend/components/tab_savings.py"
click node_bill_tab "https://github.com/buddhaakash/eco-energy/blob/main/frontend/components/tab_bill_check.py"
click node_chat_tab "https://github.com/buddhaakash/eco-energy/blob/main/frontend/components/tab_chat.py"
click node_api_client "https://github.com/buddhaakash/eco-energy/blob/main/frontend/api_client.py"
click node_fastapi "https://github.com/buddhaakash/eco-energy/blob/main/backend/main.py"
click node_dataset_routes "https://github.com/buddhaakash/eco-energy/blob/main/backend/routers/datasets.py"
click node_analysis_routes "https://github.com/buddhaakash/eco-energy/blob/main/backend/routers/analysis.py"
click node_other_routes "https://github.com/buddhaakash/eco-energy/tree/main/backend/routers"
click node_csv_parser "https://github.com/buddhaakash/eco-energy/blob/main/backend/services/ingest_service.py"
click node_pipeline "https://github.com/buddhaakash/eco-energy/blob/main/backend/services/pipeline_service.py"
click node_detector "https://github.com/buddhaakash/eco-energy/blob/main/backend/services/anomaly_service.py"
click node_savings "https://github.com/buddhaakash/eco-energy/blob/main/backend/services/savings_service.py"
click node_advisor "https://github.com/buddhaakash/eco-energy/blob/main/backend/services/advisor_service.py"
click node_bill_routes "https://github.com/buddhaakash/eco-energy/blob/main/backend/routers/bill.py"
click node_bill_service "https://github.com/buddhaakash/eco-energy/blob/main/backend/services/bill_service.py"
click node_bill_extract "https://github.com/buddhaakash/eco-energy/blob/main/backend/services/bill_extraction_service.py"
click node_database "https://github.com/buddhaakash/eco-energy/blob/main/backend/database.py"
click node_models "https://github.com/buddhaakash/eco-energy/blob/main/backend/models.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_ui,node_data_tab,node_anomaly_tab,node_savings_tab,node_bill_tab,node_chat_tab,node_api_client,node_user toneBlue
class node_fastapi,node_dataset_routes,node_analysis_routes,node_other_routes toneAmber
class node_pipeline,node_detector,node_savings,node_advisor toneMint
class node_bill_routes,node_bill_service,node_bill_extract toneRose
class node_csv_parser,node_database,node_models,node_llm toneIndigo
```

## Components

### Dashboard

- [Streamlit app](https://github.com/buddhaakash/eco-energy/blob/main/frontend/app.py): `frontend/app.py`
- [Data upload](https://github.com/buddhaakash/eco-energy/blob/main/frontend/components/tab_data.py): `frontend/components/tab_data.py`
- [Anomaly review](https://github.com/buddhaakash/eco-energy/blob/main/frontend/components/tab_anomalies.py): `frontend/components/tab_anomalies.py`
- [Savings plan](https://github.com/buddhaakash/eco-energy/blob/main/frontend/components/tab_savings.py): `frontend/components/tab_savings.py`
- [Bill check UI](https://github.com/buddhaakash/eco-energy/blob/main/frontend/components/tab_bill_check.py): `frontend/components/tab_bill_check.py`
- [AI chat](https://github.com/buddhaakash/eco-energy/blob/main/frontend/components/tab_chat.py): `frontend/components/tab_chat.py`
- [HTTP client](https://github.com/buddhaakash/eco-energy/blob/main/frontend/api_client.py): `frontend/api_client.py`

### API

- [FastAPI app](https://github.com/buddhaakash/eco-energy/blob/main/backend/main.py): `backend/main.py`
- [Dataset routes](https://github.com/buddhaakash/eco-energy/blob/main/backend/routers/datasets.py): `backend/routers/datasets.py`
- [Analysis routes](https://github.com/buddhaakash/eco-energy/blob/main/backend/routers/analysis.py): `backend/routers/analysis.py`
- [Other API routes](https://github.com/buddhaakash/eco-energy/tree/main/backend/routers): `backend/routers`

### Leak Analysis

- [Analysis pipeline](https://github.com/buddhaakash/eco-energy/blob/main/backend/services/pipeline_service.py): `backend/services/pipeline_service.py`
- [Anomaly detection](https://github.com/buddhaakash/eco-energy/blob/main/backend/services/anomaly_service.py): `backend/services/anomaly_service.py`
- [Savings actions](https://github.com/buddhaakash/eco-energy/blob/main/backend/services/savings_service.py): `backend/services/savings_service.py`
- [Anomaly explanations](https://github.com/buddhaakash/eco-energy/blob/main/backend/services/advisor_service.py): `backend/services/advisor_service.py`

### Bill Checks

- [Bill-check routes](https://github.com/buddhaakash/eco-energy/blob/main/backend/routers/bill.py): `backend/routers/bill.py`
- [Bill comparison](https://github.com/buddhaakash/eco-energy/blob/main/backend/services/bill_service.py): `backend/services/bill_service.py`
- [Bill extraction](https://github.com/buddhaakash/eco-energy/blob/main/backend/services/bill_extraction_service.py): `backend/services/bill_extraction_service.py`

### Persistence & AI

- [CSV parser](https://github.com/buddhaakash/eco-energy/blob/main/backend/services/ingest_service.py): `backend/services/ingest_service.py`
- [SQL database](https://github.com/buddhaakash/eco-energy/blob/main/backend/database.py): `backend/database.py`
- [Stored records](https://github.com/buddhaakash/eco-energy/blob/main/backend/models.py): `backend/models.py`
- **Gemini API**

### Other components

- **Energy user**

## Connections

- Energy user → Streamlit app: uses dashboard (evidence: `README.md`)
- Streamlit app → Data upload: renders (evidence: `frontend/app.py`)
- Streamlit app → Anomaly review: renders (evidence: `frontend/app.py`)
- Streamlit app → Savings plan: renders (evidence: `frontend/app.py`)
- Streamlit app → Bill check UI: renders (evidence: `frontend/app.py`)
- Streamlit app → AI chat: renders (evidence: `frontend/app.py`)
- Data upload → HTTP client: calls (evidence: `frontend/components/tab_data.py`)
- Anomaly review → HTTP client: calls (evidence: `frontend/components/tab_anomalies.py`)
- Savings plan → HTTP client: calls (evidence: `frontend/components/tab_savings.py`)
- Bill check UI → HTTP client: calls (evidence: `frontend/components/tab_bill_check.py`)
- AI chat → HTTP client: calls (evidence: `frontend/components/tab_chat.py`)
- HTTP client → FastAPI app: HTTP requests (evidence: `frontend/api_client.py`)
- FastAPI app → Dataset routes: registers (evidence: `backend/main.py`)
- FastAPI app → Analysis routes: registers (evidence: `backend/main.py`)
- FastAPI app → Other API routes: registers (evidence: `backend/main.py`)
- FastAPI app → Bill-check routes: registers (evidence: `backend/main.py`)
- Dataset routes → CSV parser: parses upload (evidence: `backend/routers/datasets.py`)
- Dataset routes → Analysis pipeline: runs analysis (evidence: `backend/routers/datasets.py`)
- Analysis routes → Analysis pipeline: runs analysis (evidence: `backend/routers/analysis.py`)
- Analysis pipeline → Anomaly detection: detects events (evidence: `backend/services/pipeline_service.py`)
- Analysis pipeline → Anomaly explanations: requests explanations (evidence: `backend/services/pipeline_service.py`)
- Analysis pipeline → Savings actions: builds actions (evidence: `backend/services/pipeline_service.py`)
- Anomaly explanations → Gemini API: requests narration (evidence: `backend/services/advisor_service.py`)
- Bill-check routes → Bill extraction: extracts bill fields (evidence: `backend/routers/bill.py`)
- Bill-check routes → Bill comparison: compares readings (evidence: `backend/routers/bill.py`)
- Bill-check routes → Gemini API: requests bill narration
- FastAPI app → SQL database: initializes (evidence: `backend/main.py`)
- SQL database → Stored records: registers tables (evidence: `backend/database.py`)
- Analysis pipeline → Stored records: reads and writes (evidence: `backend/services/pipeline_service.py`)
- Bill-check routes → Stored records: reads and writes (evidence: `backend/routers/bill.py`)
- Bill extraction → Gemini API: extracts with AI (evidence: `backend/services/bill_extraction_service.py`)
