# nidhishshanmuganathan-cmd/electricity-proj architecture

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

- Interactive diagram: https://gitdiagram.com/nidhishshanmuganathan-cmd/electricity-proj
- Repository: https://github.com/nidhishshanmuganathan-cmd/electricity-proj

## Overview

WattWatcher is an energy-monitoring product: users authenticate, register or select a meter, and view readings, usage summaries, forecasts, estimated bills, history, and alerts. The frontend presents these workflows and calls a FastAPI backend; the backend authenticates requests, stores meter and usage data, aggregates readings, predicts usage, and sends notifications. The graph includes documented UI, API, and service relationships; unsampled integrations and components are not assigned speculative call paths.

Main entry points: [`frontend/src/App.jsx`](https://github.com/nidhishshanmuganathan-cmd/electricity-proj/blob/main/frontend/src/App.jsx) (App routing), [`backend/app/routes/readings.py`](https://github.com/nidhishshanmuganathan-cmd/electricity-proj/blob/main/backend/app/routes/readings.py) (Reading endpoints), [`frontend/src/api.js`](https://github.com/nidhishshanmuganathan-cmd/electricity-proj/blob/main/frontend/src/api.js) (API client), [`backend/app/routes/users.py`](https://github.com/nidhishshanmuganathan-cmd/electricity-proj/blob/main/backend/app/routes/users.py) (User endpoints)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web application"]
  node_app["App routing<br/>[App.jsx]"]
  node_authcontext["Client auth state<br/>[AuthContext.jsx]"]
  node_api_client["API client<br/>[api.js]"]
  node_signin["Sign-in and signup<br/>[SignIn.jsx]"]
  node_signup["Account creation<br/>[CreateAccount.jsx]"]
  node_dashboard["Usage dashboard<br/>[HomeDashboard.jsx]"]
  node_analysis["Usage analysis<br/>[Analysis.jsx]"]
  node_billing["Bill estimation<br/>[BillEstimation.jsx]"]
  node_history["Usage history<br/>[History.jsx]"]
  node_profile["Profile settings<br/>[Profile.jsx]"]
  node_payment["UPI payment<br/>[UpiPayment.jsx]"]
  node_translations["Language and units<br/>[translate.js]"]
  node_push_client["Push client<br/>[notifications.js]"]
end

subgraph group_api["Backend API"]
  node_user_routes["User endpoints<br/>[users.py]"]
  node_device_routes["Device endpoints<br/>[devices.py]"]
  node_reading_routes["Reading endpoints<br/>[readings.py]"]
  node_simulation_routes["Simulation endpoints<br/>[simulation.py]"]
end

subgraph group_domain["Energy services"]
  node_aggregation["Usage aggregation<br/>[aggregation.py]"]
  node_prediction["Usage prediction<br/>[prediction.py]"]
  node_alerts["Usage alerts<br/>[alerts.py]"]
  node_notifications["Notification service<br/>[notifications.py]"]
  node_fcm["FCM delivery<br/>[fcm.py]"]
end

subgraph group_state["Identity and storage"]
  node_auth["Token verification<br/>[auth.py]"]
  node_user_model["User records<br/>[user.py]"]
  node_device_model["Device records<br/>[device.py]"]
  node_reading_model["Meter readings<br/>[reading.py]"]
  node_usage_model["Usage records<br/>[usage.py]"]
  node_database[("SQL database<br/>[database.py]")]
end

node_user(("Energy user"))
node_meter(("Energy meter"))
node_firebase_admin["Firebase Admin<br/>[firebase.py]"]
node_firebase["Firebase services"]

node_user -->|"uses"| node_app
node_app -->|"provides auth"| node_authcontext
node_app -->|"routes to"| node_signin
node_app -->|"routes to"| node_signup
node_app -->|"routes to"| node_dashboard
node_app -->|"routes to"| node_analysis
node_app -->|"routes to"| node_billing
node_app -->|"routes to"| node_history
node_app -->|"routes to"| node_profile
node_app -->|"routes to"| node_payment
node_authcontext -->|"syncs user"| node_api_client
node_authcontext -->|"observes sign-in"| node_firebase
node_signin -->|"authenticates with"| node_firebase
node_signup -->|"calls"| node_api_client
node_dashboard -->|"loads usage"| node_api_client
node_dashboard -->|"localizes"| node_translations
node_analysis -->|"loads analysis"| node_api_client
node_analysis -->|"localizes"| node_translations
node_history -->|"loads history"| node_api_client
node_profile -->|"updates profile"| node_api_client
node_profile -->|"configures push"| node_push_client
node_api_client -->|"requests user data"| node_user_routes
node_api_client -->|"requests devices"| node_device_routes
node_api_client -->|"requests readings"| node_reading_routes
node_meter -->|"posts readings"| node_reading_routes
node_reading_routes -->|"verifies user"| node_auth
node_user_routes -->|"verifies user"| node_auth
node_device_routes -->|"verifies user"| node_auth
node_simulation_routes -->|"verifies user"| node_auth
node_auth -->|"verifies token"| node_firebase_admin
node_user_routes -->|"reads and writes"| node_user_model
node_device_routes -->|"reads and writes"| node_device_model
node_reading_routes -->|"checks ownership"| node_device_model
node_reading_routes -->|"reads and writes"| node_reading_model
node_reading_routes -->|"reads usage"| node_usage_model
node_reading_routes -->|"aggregates data"| node_aggregation
node_reading_routes -->|"predicts usage"| node_prediction
node_reading_routes -->|"checks alerts"| node_notifications
node_user_routes -->|"gets alert status"| node_alerts
node_user_routes -->|"requests notification"| node_notifications
node_simulation_routes -->|"checks usage"| node_notifications
node_aggregation -->|"updates aggregates"| node_usage_model
node_aggregation -->|"reads readings"| node_reading_model
node_alerts -->|"uses forecasts"| node_prediction
node_notifications -->|"checks alert state"| node_alerts
node_notifications -->|"sends push"| node_fcm
node_push_client -->|"uses messaging"| node_firebase
node_user_model -->|"persists in"| node_database

click node_app "https://github.com/nidhishshanmuganathan-cmd/electricity-proj/blob/main/frontend/src/App.jsx"
click node_authcontext "https://github.com/nidhishshanmuganathan-cmd/electricity-proj/blob/main/frontend/src/AuthContext.jsx"
click node_api_client "https://github.com/nidhishshanmuganathan-cmd/electricity-proj/blob/main/frontend/src/api.js"
click node_signin "https://github.com/nidhishshanmuganathan-cmd/electricity-proj/blob/main/frontend/src/components/SignIn.jsx"
click node_signup "https://github.com/nidhishshanmuganathan-cmd/electricity-proj/blob/main/frontend/src/components/CreateAccount.jsx"
click node_dashboard "https://github.com/nidhishshanmuganathan-cmd/electricity-proj/blob/main/frontend/src/components/HomeDashboard.jsx"
click node_analysis "https://github.com/nidhishshanmuganathan-cmd/electricity-proj/blob/main/frontend/src/components/Analysis.jsx"
click node_billing "https://github.com/nidhishshanmuganathan-cmd/electricity-proj/blob/main/frontend/src/components/BillEstimation.jsx"
click node_history "https://github.com/nidhishshanmuganathan-cmd/electricity-proj/blob/main/frontend/src/components/History.jsx"
click node_profile "https://github.com/nidhishshanmuganathan-cmd/electricity-proj/blob/main/frontend/src/components/Profile.jsx"
click node_payment "https://github.com/nidhishshanmuganathan-cmd/electricity-proj/blob/main/frontend/src/components/UpiPayment.jsx"
click node_translations "https://github.com/nidhishshanmuganathan-cmd/electricity-proj/blob/main/frontend/src/utils/translate.js"
click node_push_client "https://github.com/nidhishshanmuganathan-cmd/electricity-proj/blob/main/frontend/src/notifications.js"
click node_user_routes "https://github.com/nidhishshanmuganathan-cmd/electricity-proj/blob/main/backend/app/routes/users.py"
click node_device_routes "https://github.com/nidhishshanmuganathan-cmd/electricity-proj/blob/main/backend/app/routes/devices.py"
click node_reading_routes "https://github.com/nidhishshanmuganathan-cmd/electricity-proj/blob/main/backend/app/routes/readings.py"
click node_simulation_routes "https://github.com/nidhishshanmuganathan-cmd/electricity-proj/blob/main/backend/app/routes/simulation.py"
click node_auth "https://github.com/nidhishshanmuganathan-cmd/electricity-proj/blob/main/backend/app/auth.py"
click node_firebase_admin "https://github.com/nidhishshanmuganathan-cmd/electricity-proj/blob/main/backend/app/firebase.py"
click node_user_model "https://github.com/nidhishshanmuganathan-cmd/electricity-proj/blob/main/backend/app/models/user.py"
click node_device_model "https://github.com/nidhishshanmuganathan-cmd/electricity-proj/blob/main/backend/app/models/device.py"
click node_reading_model "https://github.com/nidhishshanmuganathan-cmd/electricity-proj/blob/main/backend/app/models/reading.py"
click node_usage_model "https://github.com/nidhishshanmuganathan-cmd/electricity-proj/blob/main/backend/app/models/usage.py"
click node_database "https://github.com/nidhishshanmuganathan-cmd/electricity-proj/blob/main/backend/app/database.py"
click node_aggregation "https://github.com/nidhishshanmuganathan-cmd/electricity-proj/blob/main/backend/app/services/aggregation.py"
click node_prediction "https://github.com/nidhishshanmuganathan-cmd/electricity-proj/blob/main/backend/app/services/prediction.py"
click node_alerts "https://github.com/nidhishshanmuganathan-cmd/electricity-proj/blob/main/backend/app/services/alerts.py"
click node_notifications "https://github.com/nidhishshanmuganathan-cmd/electricity-proj/blob/main/backend/app/services/notifications.py"
click node_fcm "https://github.com/nidhishshanmuganathan-cmd/electricity-proj/blob/main/backend/app/services/fcm.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_app,node_authcontext,node_api_client,node_signin,node_signup,node_dashboard,node_analysis,node_billing,node_history,node_profile,node_payment,node_translations,node_push_client,node_user toneBlue
class node_user_routes,node_device_routes,node_reading_routes,node_simulation_routes toneAmber
class node_aggregation,node_prediction,node_alerts,node_notifications,node_fcm toneMint
class node_auth,node_user_model,node_device_model,node_reading_model,node_usage_model,node_database toneRose
class node_meter,node_firebase toneIndigo
class node_firebase_admin toneTeal
```

## Components

### Web application

- [App routing](https://github.com/nidhishshanmuganathan-cmd/electricity-proj/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Client auth state](https://github.com/nidhishshanmuganathan-cmd/electricity-proj/blob/main/frontend/src/AuthContext.jsx): `frontend/src/AuthContext.jsx`
- [API client](https://github.com/nidhishshanmuganathan-cmd/electricity-proj/blob/main/frontend/src/api.js): `frontend/src/api.js`
- [Sign-in and signup](https://github.com/nidhishshanmuganathan-cmd/electricity-proj/blob/main/frontend/src/components/SignIn.jsx): `frontend/src/components/SignIn.jsx`
- [Account creation](https://github.com/nidhishshanmuganathan-cmd/electricity-proj/blob/main/frontend/src/components/CreateAccount.jsx): `frontend/src/components/CreateAccount.jsx`
- [Usage dashboard](https://github.com/nidhishshanmuganathan-cmd/electricity-proj/blob/main/frontend/src/components/HomeDashboard.jsx): `frontend/src/components/HomeDashboard.jsx`
- [Usage analysis](https://github.com/nidhishshanmuganathan-cmd/electricity-proj/blob/main/frontend/src/components/Analysis.jsx): `frontend/src/components/Analysis.jsx`
- [Bill estimation](https://github.com/nidhishshanmuganathan-cmd/electricity-proj/blob/main/frontend/src/components/BillEstimation.jsx): `frontend/src/components/BillEstimation.jsx`
- [Usage history](https://github.com/nidhishshanmuganathan-cmd/electricity-proj/blob/main/frontend/src/components/History.jsx): `frontend/src/components/History.jsx`
- [Profile settings](https://github.com/nidhishshanmuganathan-cmd/electricity-proj/blob/main/frontend/src/components/Profile.jsx): `frontend/src/components/Profile.jsx`
- [UPI payment](https://github.com/nidhishshanmuganathan-cmd/electricity-proj/blob/main/frontend/src/components/UpiPayment.jsx): `frontend/src/components/UpiPayment.jsx`
- [Language and units](https://github.com/nidhishshanmuganathan-cmd/electricity-proj/blob/main/frontend/src/utils/translate.js): `frontend/src/utils/translate.js`
- [Push client](https://github.com/nidhishshanmuganathan-cmd/electricity-proj/blob/main/frontend/src/notifications.js): `frontend/src/notifications.js`

### Backend API

- [User endpoints](https://github.com/nidhishshanmuganathan-cmd/electricity-proj/blob/main/backend/app/routes/users.py): `backend/app/routes/users.py`
- [Device endpoints](https://github.com/nidhishshanmuganathan-cmd/electricity-proj/blob/main/backend/app/routes/devices.py): `backend/app/routes/devices.py`
- [Reading endpoints](https://github.com/nidhishshanmuganathan-cmd/electricity-proj/blob/main/backend/app/routes/readings.py): `backend/app/routes/readings.py`
- [Simulation endpoints](https://github.com/nidhishshanmuganathan-cmd/electricity-proj/blob/main/backend/app/routes/simulation.py): `backend/app/routes/simulation.py`

### Energy services

- [Usage aggregation](https://github.com/nidhishshanmuganathan-cmd/electricity-proj/blob/main/backend/app/services/aggregation.py): `backend/app/services/aggregation.py`
- [Usage prediction](https://github.com/nidhishshanmuganathan-cmd/electricity-proj/blob/main/backend/app/services/prediction.py): `backend/app/services/prediction.py`
- [Usage alerts](https://github.com/nidhishshanmuganathan-cmd/electricity-proj/blob/main/backend/app/services/alerts.py): `backend/app/services/alerts.py`
- [Notification service](https://github.com/nidhishshanmuganathan-cmd/electricity-proj/blob/main/backend/app/services/notifications.py): `backend/app/services/notifications.py`
- [FCM delivery](https://github.com/nidhishshanmuganathan-cmd/electricity-proj/blob/main/backend/app/services/fcm.py): `backend/app/services/fcm.py`

### Identity and storage

- [Token verification](https://github.com/nidhishshanmuganathan-cmd/electricity-proj/blob/main/backend/app/auth.py): `backend/app/auth.py`
- [User records](https://github.com/nidhishshanmuganathan-cmd/electricity-proj/blob/main/backend/app/models/user.py): `backend/app/models/user.py`
- [Device records](https://github.com/nidhishshanmuganathan-cmd/electricity-proj/blob/main/backend/app/models/device.py): `backend/app/models/device.py`
- [Meter readings](https://github.com/nidhishshanmuganathan-cmd/electricity-proj/blob/main/backend/app/models/reading.py): `backend/app/models/reading.py`
- [Usage records](https://github.com/nidhishshanmuganathan-cmd/electricity-proj/blob/main/backend/app/models/usage.py): `backend/app/models/usage.py`
- [SQL database](https://github.com/nidhishshanmuganathan-cmd/electricity-proj/blob/main/backend/app/database.py): `backend/app/database.py`

### Other components

- **Energy user**
- **Energy meter**
- [Firebase Admin](https://github.com/nidhishshanmuganathan-cmd/electricity-proj/blob/main/backend/app/firebase.py): `backend/app/firebase.py`
- **Firebase services**

## Connections

- Energy user → App routing: uses (evidence: `frontend/src/App.jsx`)
- App routing → Client auth state: provides auth (evidence: `frontend/src/App.jsx`)
- App routing → Sign-in and signup: routes to (evidence: `frontend/src/App.jsx`)
- App routing → Account creation: routes to (evidence: `frontend/src/App.jsx`)
- App routing → Usage dashboard: routes to (evidence: `frontend/src/App.jsx`)
- App routing → Usage analysis: routes to (evidence: `frontend/src/App.jsx`)
- App routing → Bill estimation: routes to (evidence: `frontend/src/App.jsx`)
- App routing → Usage history: routes to (evidence: `frontend/src/App.jsx`)
- App routing → Profile settings: routes to (evidence: `frontend/src/App.jsx`)
- App routing → UPI payment: routes to (evidence: `frontend/src/App.jsx`)
- Client auth state → API client: syncs user (evidence: `frontend/src/AuthContext.jsx`)
- Client auth state → Firebase services: observes sign-in (evidence: `frontend/src/AuthContext.jsx`)
- Sign-in and signup → Firebase services: authenticates with
- Account creation → API client: calls (evidence: `frontend/src/components/CreateAccount.jsx`)
- Usage dashboard → API client: loads usage (evidence: `frontend/src/components/HomeDashboard.jsx`)
- Usage dashboard → Language and units: localizes (evidence: `frontend/src/components/HomeDashboard.jsx`)
- Usage analysis → API client: loads analysis (evidence: `frontend/src/components/Analysis.jsx`)
- Usage analysis → Language and units: localizes (evidence: `frontend/src/components/Analysis.jsx`)
- Usage history → API client: loads history (evidence: `frontend/src/components/History.jsx`)
- Profile settings → API client: updates profile (evidence: `frontend/src/components/Profile.jsx`)
- Profile settings → Push client: configures push (evidence: `frontend/src/components/Profile.jsx`)
- API client → User endpoints: requests user data (evidence: `frontend/src/api.js`)
- API client → Device endpoints: requests devices (evidence: `frontend/src/api.js`)
- API client → Reading endpoints: requests readings (evidence: `frontend/src/api.js`)
- Energy meter → Reading endpoints: posts readings (evidence: `backend/app/routes/readings.py`)
- Reading endpoints → Token verification: verifies user (evidence: `backend/app/routes/readings.py`)
- User endpoints → Token verification: verifies user (evidence: `backend/app/routes/users.py`)
- Device endpoints → Token verification: verifies user (evidence: `backend/app/routes/devices.py`)
- Simulation endpoints → Token verification: verifies user (evidence: `backend/app/routes/simulation.py`)
- Token verification → Firebase Admin: verifies token (evidence: `backend/app/auth.py`)
- User endpoints → User records: reads and writes (evidence: `backend/app/routes/users.py`)
- Device endpoints → Device records: reads and writes (evidence: `backend/app/routes/devices.py`)
- Reading endpoints → Device records: checks ownership (evidence: `backend/app/routes/readings.py`)
- Reading endpoints → Meter readings: reads and writes (evidence: `backend/app/routes/readings.py`)
- Reading endpoints → Usage records: reads usage (evidence: `backend/app/routes/readings.py`)
- Reading endpoints → Usage aggregation: aggregates data (evidence: `backend/app/routes/readings.py`)
- Reading endpoints → Usage prediction: predicts usage (evidence: `backend/app/routes/readings.py`)
- Reading endpoints → Notification service: checks alerts (evidence: `backend/app/routes/readings.py`)
- User endpoints → Usage alerts: gets alert status (evidence: `backend/app/routes/users.py`)
- User endpoints → Notification service: requests notification (evidence: `backend/app/routes/users.py`)
- Simulation endpoints → Notification service: checks usage (evidence: `backend/app/routes/simulation.py`)
- Usage aggregation → Usage records: updates aggregates (evidence: `backend/app/services/aggregation.py`)
- Usage aggregation → Meter readings: reads readings (evidence: `backend/app/services/aggregation.py`)
- Usage alerts → Usage prediction: uses forecasts (evidence: `backend/app/services/alerts.py`)
- Notification service → Usage alerts: checks alert state (evidence: `backend/app/services/notifications.py`)
- Notification service → FCM delivery: sends push (evidence: `backend/app/services/notifications.py`)
- Push client → Firebase services: uses messaging (evidence: `frontend/src/notifications.js`)
- User records → SQL database: persists in (evidence: `backend/app/models/user.py`)
