# arjunbalaji123/campus-energy-consumption-and-anomaly-detection-system- architecture

> Architecture diagram of the GitHub repository arjunbalaji123/campus-energy-consumption-and-anomaly-detection-system-, 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/arjunbalaji123/campus-energy-consumption-and-anomaly-detection-system-
- Repository: https://github.com/arjunbalaji123/campus-energy-consumption-and-anomaly-detection-system-

## Overview

Campus Energy Intelligence is a dashboard-backed service for exploring campus energy, predicting expected loads, and investigating anomalies. The main workflow runs from a user-selected dashboard view through frontend API requests to FastAPI endpoints, which query persisted readings or invoke prediction and anomaly analysis; results return to the dashboard. The README documents preprocessing, feature engineering, model evaluation, severity classification, contextual explanations, and the major analytics, exploration, and settings capabilities. Some endpoint and frontend relationships are documented in the source index or API paths; unsampled implementation details are not inferred.

Main entry points: [`frontend/src/services/api.ts`](https://github.com/arjunbalaji123/campus-energy-consumption-and-anomaly-detection-system-/blob/main/frontend/src/services/api.ts) (API client), [`frontend/src/App.tsx`](https://github.com/arjunbalaji123/campus-energy-consumption-and-anomaly-detection-system-/blob/main/frontend/src/App.tsx) (Dashboard router), [`backend/app/main.py`](https://github.com/arjunbalaji123/campus-energy-consumption-and-anomaly-detection-system-/blob/main/backend/app/main.py) (FastAPI application), [`backend/app/api/endpoints/campus.py`](https://github.com/arjunbalaji123/campus-energy-consumption-and-anomaly-detection-system-/blob/main/backend/app/api/endpoints/campus.py) (Campus prediction)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Dashboard"]
  node_app["Dashboard router<br/>[App.tsx]"]
  node_overview["Overview<br/>[Overview.tsx]"]
  node_analytics["Energy analytics"]
  node_building_ui["Building intelligence"]
  node_predict_ui["Facility predictor"]
  node_prediction_ui["Prediction analysis"]
  node_anomaly_ui["Anomaly center<br/>[AnomalyCenter.tsx]"]
  node_investigation_ui["Anomaly investigation"]
  node_model_ui["Model performance"]
  node_explorer_ui["Data explorer<br/>[DataExplorer.tsx]"]
  node_settings_ui["Settings<br/>[SettingsPage.tsx]"]
  node_api_client["API client<br/>[api.ts]"]
end

subgraph group_api["API"]
  node_server["FastAPI application<br/>[main.py]"]
  node_campus_api["Campus prediction<br/>[campus.py]"]
  node_analytics_api["Energy analytics API<br/>[analytics.py]"]
  node_buildings_api["Building API<br/>[buildings.py]"]
  node_overview_api["Overview API<br/>[overview.py]"]
  node_predictions_api["Prediction API<br/>[predictions.py]"]
  node_anomalies_api["Anomaly API<br/>[anomalies.py]"]
  node_model_api["Model metrics API<br/>[model_info.py]"]
  node_explorer_api["Telemetry explorer API<br/>[data_explorer.py]"]
  node_pipeline_api["Pipeline control<br/>[pipeline.py]"]
  node_schemas["API schemas<br/>[api_schemas.py]"]
end

subgraph group_ml["Energy intelligence"]
  node_pipeline["Telemetry preprocessing<br/>[data_pipeline.py]"]
  node_predictor["Load predictor<br/>[predictor.py]"]
  node_anomaly_engine["Anomaly analysis<br/>[anomaly_engine.py]"]
  node_seeder["Dataset and training seeder<br/>[seeder.py]"]
end

subgraph group_data["Persistence"]
  node_config["Runtime settings<br/>[config.py]"]
  node_database[("Database sessions<br/>[database.py]")]
  node_models[("Energy records<br/>[db_models.py]")]
end

node_user(("Campus user"))

node_user -->|"uses"| node_app
node_app -->|"routes to"| node_overview
node_app -->|"routes to"| node_analytics
node_app -->|"routes to"| node_building_ui
node_app -->|"routes to"| node_predict_ui
node_app -->|"routes to"| node_prediction_ui
node_app -->|"routes to"| node_anomaly_ui
node_app -->|"routes to"| node_investigation_ui
node_app -->|"routes to"| node_model_ui
node_app -->|"routes to"| node_explorer_ui
node_app -->|"routes to"| node_settings_ui
node_overview -->|"requests data"| node_api_client
node_analytics -->|"requests data"| node_api_client
node_building_ui -->|"requests data"| node_api_client
node_predict_ui -->|"requests prediction"| node_api_client
node_prediction_ui -->|"requests data"| node_api_client
node_anomaly_ui -->|"requests anomalies"| node_api_client
node_investigation_ui -->|"requests detail"| node_api_client
node_model_ui -->|"requests metrics"| node_api_client
node_explorer_ui -->|"requests readings"| node_api_client
node_settings_ui -->|"runs pipeline"| node_api_client
node_api_client -->|"calls campus routes"| node_campus_api
node_api_client -->|"calls summary"| node_overview_api
node_api_client -->|"calls trends"| node_analytics_api
node_api_client -->|"calls building routes"| node_buildings_api
node_api_client -->|"calls analysis"| node_predictions_api
node_api_client -->|"calls anomaly routes"| node_anomalies_api
node_api_client -->|"calls metrics"| node_model_api
node_api_client -->|"calls explorer routes"| node_explorer_api
node_api_client -->|"calls pipeline"| node_pipeline_api
node_server -->|"registers routes"| node_campus_api
node_server -->|"registers routes"| node_overview_api
node_server -->|"registers routes"| node_analytics_api
node_server -->|"registers routes"| node_buildings_api
node_server -->|"registers routes"| node_predictions_api
node_server -->|"registers routes"| node_anomalies_api
node_server -->|"registers routes"| node_model_api
node_server -->|"registers routes"| node_explorer_api
node_server -->|"registers routes"| node_pipeline_api
node_campus_api -->|"invokes prediction"| node_predictor
node_campus_api -->|"invokes analysis"| node_anomaly_engine
node_campus_api -->|"uses features"| node_pipeline
node_pipeline_api -->|"runs seeding"| node_seeder
node_seeder -->|"generates features"| node_pipeline
node_seeder -->|"trains model"| node_predictor
node_seeder -->|"trains detector"| node_anomaly_engine
node_analytics_api -->|"queries readings"| node_database
node_overview_api -->|"queries summary"| node_database

click node_app "https://github.com/arjunbalaji123/campus-energy-consumption-and-anomaly-detection-system-/blob/main/frontend/src/App.tsx"
click node_overview "https://github.com/arjunbalaji123/campus-energy-consumption-and-anomaly-detection-system-/blob/main/frontend/src/pages/Overview.tsx"
click node_analytics "https://github.com/arjunbalaji123/campus-energy-consumption-and-anomaly-detection-system-/blob/main/frontend/src/pages/EnergyAnalytics.tsx"
click node_building_ui "https://github.com/arjunbalaji123/campus-energy-consumption-and-anomaly-detection-system-/blob/main/frontend/src/pages/BuildingIntelligence.tsx"
click node_predict_ui "https://github.com/arjunbalaji123/campus-energy-consumption-and-anomaly-detection-system-/blob/main/frontend/src/pages/FacilityPredictor.tsx"
click node_prediction_ui "https://github.com/arjunbalaji123/campus-energy-consumption-and-anomaly-detection-system-/blob/main/frontend/src/pages/PredictionAnalysis.tsx"
click node_anomaly_ui "https://github.com/arjunbalaji123/campus-energy-consumption-and-anomaly-detection-system-/blob/main/frontend/src/pages/AnomalyCenter.tsx"
click node_investigation_ui "https://github.com/arjunbalaji123/campus-energy-consumption-and-anomaly-detection-system-/blob/main/frontend/src/pages/AnomalyInvestigation.tsx"
click node_model_ui "https://github.com/arjunbalaji123/campus-energy-consumption-and-anomaly-detection-system-/blob/main/frontend/src/pages/ModelPerformance.tsx"
click node_explorer_ui "https://github.com/arjunbalaji123/campus-energy-consumption-and-anomaly-detection-system-/blob/main/frontend/src/pages/DataExplorer.tsx"
click node_settings_ui "https://github.com/arjunbalaji123/campus-energy-consumption-and-anomaly-detection-system-/blob/main/frontend/src/pages/SettingsPage.tsx"
click node_api_client "https://github.com/arjunbalaji123/campus-energy-consumption-and-anomaly-detection-system-/blob/main/frontend/src/services/api.ts"
click node_server "https://github.com/arjunbalaji123/campus-energy-consumption-and-anomaly-detection-system-/blob/main/backend/app/main.py"
click node_campus_api "https://github.com/arjunbalaji123/campus-energy-consumption-and-anomaly-detection-system-/blob/main/backend/app/api/endpoints/campus.py"
click node_analytics_api "https://github.com/arjunbalaji123/campus-energy-consumption-and-anomaly-detection-system-/blob/main/backend/app/api/endpoints/analytics.py"
click node_buildings_api "https://github.com/arjunbalaji123/campus-energy-consumption-and-anomaly-detection-system-/blob/main/backend/app/api/endpoints/buildings.py"
click node_overview_api "https://github.com/arjunbalaji123/campus-energy-consumption-and-anomaly-detection-system-/blob/main/backend/app/api/endpoints/overview.py"
click node_predictions_api "https://github.com/arjunbalaji123/campus-energy-consumption-and-anomaly-detection-system-/blob/main/backend/app/api/endpoints/predictions.py"
click node_anomalies_api "https://github.com/arjunbalaji123/campus-energy-consumption-and-anomaly-detection-system-/blob/main/backend/app/api/endpoints/anomalies.py"
click node_model_api "https://github.com/arjunbalaji123/campus-energy-consumption-and-anomaly-detection-system-/blob/main/backend/app/api/endpoints/model_info.py"
click node_explorer_api "https://github.com/arjunbalaji123/campus-energy-consumption-and-anomaly-detection-system-/blob/main/backend/app/api/endpoints/data_explorer.py"
click node_pipeline_api "https://github.com/arjunbalaji123/campus-energy-consumption-and-anomaly-detection-system-/blob/main/backend/app/api/endpoints/pipeline.py"
click node_schemas "https://github.com/arjunbalaji123/campus-energy-consumption-and-anomaly-detection-system-/blob/main/backend/app/schemas/api_schemas.py"
click node_pipeline "https://github.com/arjunbalaji123/campus-energy-consumption-and-anomaly-detection-system-/blob/main/backend/app/ml/data_pipeline.py"
click node_predictor "https://github.com/arjunbalaji123/campus-energy-consumption-and-anomaly-detection-system-/blob/main/backend/app/ml/predictor.py"
click node_anomaly_engine "https://github.com/arjunbalaji123/campus-energy-consumption-and-anomaly-detection-system-/blob/main/backend/app/ml/anomaly_engine.py"
click node_seeder "https://github.com/arjunbalaji123/campus-energy-consumption-and-anomaly-detection-system-/blob/main/backend/app/ml/seeder.py"
click node_config "https://github.com/arjunbalaji123/campus-energy-consumption-and-anomaly-detection-system-/blob/main/backend/app/core/config.py"
click node_database "https://github.com/arjunbalaji123/campus-energy-consumption-and-anomaly-detection-system-/blob/main/backend/app/core/database.py"
click node_models "https://github.com/arjunbalaji123/campus-energy-consumption-and-anomaly-detection-system-/blob/main/backend/app/models/db_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_app,node_overview,node_analytics,node_building_ui,node_predict_ui,node_prediction_ui,node_anomaly_ui,node_investigation_ui,node_model_ui,node_explorer_ui,node_settings_ui,node_api_client,node_user toneBlue
class node_server,node_campus_api,node_analytics_api,node_buildings_api,node_overview_api,node_predictions_api,node_anomalies_api,node_model_api,node_explorer_api,node_pipeline_api,node_schemas toneAmber
class node_pipeline,node_predictor,node_anomaly_engine,node_seeder toneMint
class node_config,node_database,node_models toneRose
```

## Components

### Dashboard

- [Dashboard router](https://github.com/arjunbalaji123/campus-energy-consumption-and-anomaly-detection-system-/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Overview](https://github.com/arjunbalaji123/campus-energy-consumption-and-anomaly-detection-system-/blob/main/frontend/src/pages/Overview.tsx): `frontend/src/pages/Overview.tsx`
- [Energy analytics](https://github.com/arjunbalaji123/campus-energy-consumption-and-anomaly-detection-system-/blob/main/frontend/src/pages/EnergyAnalytics.tsx): `frontend/src/pages/EnergyAnalytics.tsx`
- [Building intelligence](https://github.com/arjunbalaji123/campus-energy-consumption-and-anomaly-detection-system-/blob/main/frontend/src/pages/BuildingIntelligence.tsx): `frontend/src/pages/BuildingIntelligence.tsx`
- [Facility predictor](https://github.com/arjunbalaji123/campus-energy-consumption-and-anomaly-detection-system-/blob/main/frontend/src/pages/FacilityPredictor.tsx): `frontend/src/pages/FacilityPredictor.tsx`
- [Prediction analysis](https://github.com/arjunbalaji123/campus-energy-consumption-and-anomaly-detection-system-/blob/main/frontend/src/pages/PredictionAnalysis.tsx): `frontend/src/pages/PredictionAnalysis.tsx`
- [Anomaly center](https://github.com/arjunbalaji123/campus-energy-consumption-and-anomaly-detection-system-/blob/main/frontend/src/pages/AnomalyCenter.tsx): `frontend/src/pages/AnomalyCenter.tsx`
- [Anomaly investigation](https://github.com/arjunbalaji123/campus-energy-consumption-and-anomaly-detection-system-/blob/main/frontend/src/pages/AnomalyInvestigation.tsx): `frontend/src/pages/AnomalyInvestigation.tsx`
- [Model performance](https://github.com/arjunbalaji123/campus-energy-consumption-and-anomaly-detection-system-/blob/main/frontend/src/pages/ModelPerformance.tsx): `frontend/src/pages/ModelPerformance.tsx`
- [Data explorer](https://github.com/arjunbalaji123/campus-energy-consumption-and-anomaly-detection-system-/blob/main/frontend/src/pages/DataExplorer.tsx): `frontend/src/pages/DataExplorer.tsx`
- [Settings](https://github.com/arjunbalaji123/campus-energy-consumption-and-anomaly-detection-system-/blob/main/frontend/src/pages/SettingsPage.tsx): `frontend/src/pages/SettingsPage.tsx`
- [API client](https://github.com/arjunbalaji123/campus-energy-consumption-and-anomaly-detection-system-/blob/main/frontend/src/services/api.ts): `frontend/src/services/api.ts`

### API

- [FastAPI application](https://github.com/arjunbalaji123/campus-energy-consumption-and-anomaly-detection-system-/blob/main/backend/app/main.py): `backend/app/main.py`
- [Campus prediction](https://github.com/arjunbalaji123/campus-energy-consumption-and-anomaly-detection-system-/blob/main/backend/app/api/endpoints/campus.py): `backend/app/api/endpoints/campus.py`
- [Energy analytics API](https://github.com/arjunbalaji123/campus-energy-consumption-and-anomaly-detection-system-/blob/main/backend/app/api/endpoints/analytics.py): `backend/app/api/endpoints/analytics.py`
- [Building API](https://github.com/arjunbalaji123/campus-energy-consumption-and-anomaly-detection-system-/blob/main/backend/app/api/endpoints/buildings.py): `backend/app/api/endpoints/buildings.py`
- [Overview API](https://github.com/arjunbalaji123/campus-energy-consumption-and-anomaly-detection-system-/blob/main/backend/app/api/endpoints/overview.py): `backend/app/api/endpoints/overview.py`
- [Prediction API](https://github.com/arjunbalaji123/campus-energy-consumption-and-anomaly-detection-system-/blob/main/backend/app/api/endpoints/predictions.py): `backend/app/api/endpoints/predictions.py`
- [Anomaly API](https://github.com/arjunbalaji123/campus-energy-consumption-and-anomaly-detection-system-/blob/main/backend/app/api/endpoints/anomalies.py): `backend/app/api/endpoints/anomalies.py`
- [Model metrics API](https://github.com/arjunbalaji123/campus-energy-consumption-and-anomaly-detection-system-/blob/main/backend/app/api/endpoints/model_info.py): `backend/app/api/endpoints/model_info.py`
- [Telemetry explorer API](https://github.com/arjunbalaji123/campus-energy-consumption-and-anomaly-detection-system-/blob/main/backend/app/api/endpoints/data_explorer.py): `backend/app/api/endpoints/data_explorer.py`
- [Pipeline control](https://github.com/arjunbalaji123/campus-energy-consumption-and-anomaly-detection-system-/blob/main/backend/app/api/endpoints/pipeline.py): `backend/app/api/endpoints/pipeline.py`
- [API schemas](https://github.com/arjunbalaji123/campus-energy-consumption-and-anomaly-detection-system-/blob/main/backend/app/schemas/api_schemas.py): `backend/app/schemas/api_schemas.py`

### Energy intelligence

- [Telemetry preprocessing](https://github.com/arjunbalaji123/campus-energy-consumption-and-anomaly-detection-system-/blob/main/backend/app/ml/data_pipeline.py): `backend/app/ml/data_pipeline.py`
- [Load predictor](https://github.com/arjunbalaji123/campus-energy-consumption-and-anomaly-detection-system-/blob/main/backend/app/ml/predictor.py): `backend/app/ml/predictor.py`
- [Anomaly analysis](https://github.com/arjunbalaji123/campus-energy-consumption-and-anomaly-detection-system-/blob/main/backend/app/ml/anomaly_engine.py): `backend/app/ml/anomaly_engine.py`
- [Dataset and training seeder](https://github.com/arjunbalaji123/campus-energy-consumption-and-anomaly-detection-system-/blob/main/backend/app/ml/seeder.py): `backend/app/ml/seeder.py`

### Persistence

- [Runtime settings](https://github.com/arjunbalaji123/campus-energy-consumption-and-anomaly-detection-system-/blob/main/backend/app/core/config.py): `backend/app/core/config.py`
- [Database sessions](https://github.com/arjunbalaji123/campus-energy-consumption-and-anomaly-detection-system-/blob/main/backend/app/core/database.py): `backend/app/core/database.py`
- [Energy records](https://github.com/arjunbalaji123/campus-energy-consumption-and-anomaly-detection-system-/blob/main/backend/app/models/db_models.py): `backend/app/models/db_models.py`

### Other components

- **Campus user**

## Connections

- Campus user → Dashboard router: uses (evidence: `README.md`)
- Dashboard router → Overview: routes to (evidence: `frontend/src/App.tsx`)
- Dashboard router → Energy analytics: routes to (evidence: `frontend/src/App.tsx`)
- Dashboard router → Building intelligence: routes to (evidence: `frontend/src/App.tsx`)
- Dashboard router → Facility predictor: routes to (evidence: `frontend/src/App.tsx`)
- Dashboard router → Prediction analysis: routes to (evidence: `frontend/src/App.tsx`)
- Dashboard router → Anomaly center: routes to (evidence: `frontend/src/App.tsx`)
- Dashboard router → Anomaly investigation: routes to (evidence: `frontend/src/App.tsx`)
- Dashboard router → Model performance: routes to (evidence: `frontend/src/App.tsx`)
- Dashboard router → Data explorer: routes to (evidence: `frontend/src/App.tsx`)
- Dashboard router → Settings: routes to (evidence: `frontend/src/App.tsx`)
- Overview → API client: requests data (evidence: `frontend/src/pages/Overview.tsx`)
- Energy analytics → API client: requests data (evidence: `frontend/src/pages/EnergyAnalytics.tsx`)
- Building intelligence → API client: requests data (evidence: `frontend/src/pages/BuildingIntelligence.tsx`)
- Facility predictor → API client: requests prediction (evidence: `frontend/src/pages/FacilityPredictor.tsx`)
- Prediction analysis → API client: requests data (evidence: `frontend/src/pages/PredictionAnalysis.tsx`)
- Anomaly center → API client: requests anomalies (evidence: `frontend/src/pages/AnomalyCenter.tsx`)
- Anomaly investigation → API client: requests detail (evidence: `frontend/src/pages/AnomalyInvestigation.tsx`)
- Model performance → API client: requests metrics (evidence: `frontend/src/pages/ModelPerformance.tsx`)
- Data explorer → API client: requests readings (evidence: `frontend/src/pages/DataExplorer.tsx`)
- Settings → API client: runs pipeline (evidence: `frontend/src/pages/SettingsPage.tsx`)
- API client → Campus prediction: calls campus routes (evidence: `frontend/src/services/api.ts`)
- API client → Overview API: calls summary (evidence: `frontend/src/services/api.ts`)
- API client → Energy analytics API: calls trends (evidence: `frontend/src/services/api.ts`)
- API client → Building API: calls building routes (evidence: `frontend/src/services/api.ts`)
- API client → Prediction API: calls analysis (evidence: `frontend/src/services/api.ts`)
- API client → Anomaly API: calls anomaly routes (evidence: `frontend/src/services/api.ts`)
- API client → Model metrics API: calls metrics (evidence: `frontend/src/services/api.ts`)
- API client → Telemetry explorer API: calls explorer routes (evidence: `frontend/src/services/api.ts`)
- API client → Pipeline control: calls pipeline (evidence: `frontend/src/services/api.ts`)
- FastAPI application → Campus prediction: registers routes (evidence: `backend/app/main.py`)
- FastAPI application → Overview API: registers routes (evidence: `backend/app/main.py`)
- FastAPI application → Energy analytics API: registers routes (evidence: `backend/app/main.py`)
- FastAPI application → Building API: registers routes (evidence: `backend/app/main.py`)
- FastAPI application → Prediction API: registers routes (evidence: `backend/app/main.py`)
- FastAPI application → Anomaly API: registers routes (evidence: `backend/app/main.py`)
- FastAPI application → Model metrics API: registers routes (evidence: `backend/app/main.py`)
- FastAPI application → Telemetry explorer API: registers routes (evidence: `backend/app/main.py`)
- FastAPI application → Pipeline control: registers routes (evidence: `backend/app/main.py`)
- Campus prediction → Load predictor: invokes prediction (evidence: `backend/app/api/endpoints/campus.py`)
- Campus prediction → Anomaly analysis: invokes analysis (evidence: `backend/app/api/endpoints/campus.py`)
- Campus prediction → Telemetry preprocessing: uses features (evidence: `backend/app/api/endpoints/campus.py`)
- Pipeline control → Dataset and training seeder: runs seeding (evidence: `backend/app/api/endpoints/pipeline.py`)
- Dataset and training seeder → Telemetry preprocessing: generates features (evidence: `backend/app/ml/seeder.py`)
- Dataset and training seeder → Load predictor: trains model (evidence: `backend/app/ml/seeder.py`)
- Dataset and training seeder → Anomaly analysis: trains detector (evidence: `backend/app/ml/seeder.py`)
- Energy analytics API → Database sessions: queries readings (evidence: `backend/app/api/endpoints/analytics.py`)
- Overview API → Database sessions: queries summary (evidence: `backend/app/api/endpoints/overview.py`)
