# raman0330/weather-load-analyzer architecture

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

- Interactive diagram: https://gitdiagram.com/raman0330/weather-load-analyzer
- Repository: https://github.com/raman0330/weather-load-analyzer

## Overview

#### Purpose and deployment shape
This repository is an electricity-load forecasting and decision-support system, centered on Haryana/Punjab forecasting, weather effects, accuracy correction, scenario simulation, and backtesting. It ships a React frontend plus two Python API surfaces: a forecasting service and a Django application. Container orchestration and reverse-proxy configuration are present in `docker-compose.yml`, `Dockerfile.fastapi`, `Dockerfile.django`, `Dockerfile.frontend`, and `nginx.conf`.

#### Entry points and application surfaces
- Forecasting/API service entry candidates: `api.py`, `backend/main.py`, and `backend/run.py`.
- Django service entry point: `django_api/manage.py`, with project routing in `django_api/django_api/urls.py`.
- Browser client entry: `frontend/src/main.jsx`, which initializes routing/providers around `frontend/src/App.jsx`.
- The frontend’s backend endpoint configuration is isolated in `frontend/src/apiConfig.ts` and `frontend/src/lib/api.ts`.

#### Forecasting engine and model artifacts
The main forecasting boundary is the Python backend. `backend/engine.py`, `backend/gridintel_engine.py`, and `backend/hybrid_ai_engine.py` appear to provide alternative or composed forecast engines; model structure is in `backend/hybrid_ai_model.py`. Region-specific learned assets are versioned locally under `backend/artifacts/haryana/model.weights.h5`, `backend/artifacts/haryana/scalers.pkl`, and `backend/artifacts/punjab/model.weights.h5`. This makes artifact loading and region selection a core runtime dependency rather than a remote model-serving boundary.

#### Short-term forecast pipeline and weather/load integration
`backend/short_term_pipeline.py` is the likely orchestration stage for operational forecasts, exposed through `backend/pipeline_router.py`. Weather and load processing are separated into `weatherData.py`, `loadProcessor.py`, `weather_load_processor.py`, and `weatherloadIntegrator.py`. The primary flow is weather/load inputs → feature preparation/integration → hybrid or grid-intelligence model inference → forecast payloads for API consumers.

#### Forecast-quality and operational correction layer
Post-model forecast adjustment is a distinct architecture layer under `backend/accuracy/`: `backend/accuracy/calibration_layer.py`, `backend/accuracy/bias_correction.py`, and `backend/accuracy/sldc_validator.py`. Additional specialized handling includes `backend/accuracy/ramp_weather.py` and `backend/weather_anomaly.py`. This boundary likely applies calibration, bias/ramp corrections, anomaly handling, and validation before results are surfaced or evaluated.

#### Evaluation, reporting, and scenario workflows
Offline evaluation is represented by `backend/backtester.py`, `backend/backtest_may_jun_2025.py`, and persisted reports such as `reports/backtest_may_jun_2025.xlsx`. Haryana-focused RCA/monsoon analysis is produced from scripts and report assets including `scripts/run_report.py`, `reports/haryana_monsoon_report.html`, and `exports/Haryana_RCA_OPEN_THIS.xlsx`. Scenario state is persisted locally in `exports/scenarios_store.json`; the frontend simulator consumes its own scenario/data services in `frontend/src/features/simulator/scenarioService.ts` and `frontend/src/features/simulator/simulatorDataService.ts`.

#### Frontend product domains and identity boundary
The Vite/React frontend organizes user workflows by feature: forecast presentation in `frontend/src/features/forecast/ForecastPage.tsx`, monitoring in `frontend/src/features/monitor/AccuracyMonitorPage.jsx`, backtesting in `frontend/src/features/backtest/BacktestPage.jsx`, and scenario simulation in `frontend/src/features/simulator/SimulatorPage.tsx`. Authentication is gated client-side by `frontend/src/app/AuthGate.tsx`, while Django owns account models/routes in `django_api/accounts/models.py` and `django_api/accounts/urls.py`. The repository does not identify third-party weather, identity, or database services; these integrations should be confirmed from environment variables and runtime code.

Main entry points: [`frontend/src/App.jsx`](https://github.com/raman0330/weather-load-analyzer/blob/master/frontend/src/App.jsx) (Product routes), [`nginx.conf`](https://github.com/raman0330/weather-load-analyzer/blob/master/nginx.conf) (Reverse proxy), [`api.py`](https://github.com/raman0330/weather-load-analyzer/blob/master/api.py) (Forecast API), [`backend/hybrid_ai_engine.py`](https://github.com/raman0330/weather-load-analyzer/blob/master/backend/hybrid_ai_engine.py) (Hybrid forecast engine)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["React client"]
  node_frontend_entry["Client bootstrap<br/>React entry<br/>[main.jsx]"]
  node_frontend_app["Product routes<br/>React app<br/>[App.jsx]"]
  node_client_api["Backend API client<br/>endpoint config<br/>[apiConfig.ts]"]
  node_forecast_ui["Forecast UI<br/>feature page<br/>[ForecastPage.tsx]"]
  node_monitor_ui["Accuracy monitor<br/>feature page"]
  node_backtest_ui["Backtest UI<br/>feature page<br/>[BacktestPage.jsx]"]
  node_simulator_ui["Scenario simulator<br/>feature page<br/>[SimulatorPage.tsx]"]
  node_auth_gate["Client auth gate<br/>access boundary<br/>[AuthGate.tsx]"]
end

subgraph group_forecast["Forecast backend"]
  node_forecast_api{{"Forecast API<br/>Python API<br/>[api.py]"}}
  node_pipeline_api["Pipeline routes<br/>API router<br/>[pipeline_router.py]"]
  node_short_term["Short-term pipeline<br/>forecast orchestration"]
  node_integration["Weather-load integration<br/>feature preparation"]
  node_hybrid_engine["Hybrid forecast engine<br/>model inference"]
  node_artifacts[("Regional model artifacts<br/>local model assets<br/>[model.weights.h5]")]
  node_accuracy["Forecast correction<br/>quality layer"]
end

subgraph group_django["Django identity"]
  node_django_entry{{"Django service<br/>Django entry<br/>[manage.py]"}}
  node_django_routes["Django routes<br/>project router<br/>[urls.py]"]
  node_accounts["Accounts domain<br/>Django models/routes<br/>[models.py]"]
end

subgraph group_offline["Evaluation &amp; reports"]
  node_backtester["Backtesting<br/>offline evaluator<br/>[backtester.py]"]
  node_scenario_store[("Scenario store<br/>local state")]
  node_reports["Analysis reports<br/>report output"]
end

node_proxy{{"Reverse proxy<br/>Nginx<br/>[nginx.conf]"}}
node_compose["Container stack<br/>Docker Compose<br/>[docker-compose.yml]"]

node_compose -->|"deploys"| node_proxy
node_proxy -->|"serves"| node_frontend_entry
node_proxy -->|"routes to"| node_forecast_api
node_proxy -->|"routes to"| node_django_entry
node_frontend_entry -->|"initializes"| node_frontend_app
node_frontend_app -->|"guards"| node_auth_gate
node_frontend_app -->|"renders"| node_forecast_ui
node_frontend_app -->|"renders"| node_monitor_ui
node_frontend_app -->|"renders"| node_backtest_ui
node_frontend_app -->|"renders"| node_simulator_ui
node_frontend_app -->|"uses"| node_client_api
node_client_api -->|"calls"| node_forecast_api
node_auth_gate -.->|"accesses identity API"| node_django_entry
node_django_entry -->|"loads"| node_django_routes
node_django_routes -->|"includes"| node_accounts
node_forecast_api -->|"exposes"| node_pipeline_api
node_pipeline_api -->|"starts"| node_short_term
node_short_term -->|"prepares features"| node_integration
node_integration -->|"supplies inputs"| node_hybrid_engine
node_hybrid_engine -->|"loads region assets"| node_artifacts
node_hybrid_engine -->|"produces forecast"| node_accuracy
node_accuracy -->|"returns corrected output"| node_forecast_api
node_backtester -->|"produces"| node_reports
node_simulator_ui -.->|"uses scenario state"| node_scenario_store

click node_proxy "https://github.com/raman0330/weather-load-analyzer/blob/master/nginx.conf"
click node_compose "https://github.com/raman0330/weather-load-analyzer/blob/master/docker-compose.yml"
click node_frontend_entry "https://github.com/raman0330/weather-load-analyzer/blob/master/frontend/src/main.jsx"
click node_frontend_app "https://github.com/raman0330/weather-load-analyzer/blob/master/frontend/src/App.jsx"
click node_client_api "https://github.com/raman0330/weather-load-analyzer/blob/master/frontend/src/apiConfig.ts"
click node_forecast_ui "https://github.com/raman0330/weather-load-analyzer/blob/master/frontend/src/features/forecast/ForecastPage.tsx"
click node_monitor_ui "https://github.com/raman0330/weather-load-analyzer/blob/master/frontend/src/features/monitor/AccuracyMonitorPage.jsx"
click node_backtest_ui "https://github.com/raman0330/weather-load-analyzer/blob/master/frontend/src/features/backtest/BacktestPage.jsx"
click node_simulator_ui "https://github.com/raman0330/weather-load-analyzer/blob/master/frontend/src/features/simulator/SimulatorPage.tsx"
click node_auth_gate "https://github.com/raman0330/weather-load-analyzer/blob/master/frontend/src/app/AuthGate.tsx"
click node_forecast_api "https://github.com/raman0330/weather-load-analyzer/blob/master/api.py"
click node_pipeline_api "https://github.com/raman0330/weather-load-analyzer/blob/master/backend/pipeline_router.py"
click node_short_term "https://github.com/raman0330/weather-load-analyzer/blob/master/backend/short_term_pipeline.py"
click node_integration "https://github.com/raman0330/weather-load-analyzer/blob/master/weatherloadIntegrator.py"
click node_hybrid_engine "https://github.com/raman0330/weather-load-analyzer/blob/master/backend/hybrid_ai_engine.py"
click node_artifacts "https://github.com/raman0330/weather-load-analyzer/blob/master/backend/artifacts/haryana/model.weights.h5"
click node_accuracy "https://github.com/raman0330/weather-load-analyzer/blob/master/backend/accuracy/calibration_layer.py"
click node_django_entry "https://github.com/raman0330/weather-load-analyzer/blob/master/django_api/manage.py"
click node_django_routes "https://github.com/raman0330/weather-load-analyzer/blob/master/django_api/django_api/urls.py"
click node_accounts "https://github.com/raman0330/weather-load-analyzer/blob/master/django_api/accounts/models.py"
click node_backtester "https://github.com/raman0330/weather-load-analyzer/blob/master/backend/backtester.py"
click node_scenario_store "https://github.com/raman0330/weather-load-analyzer/blob/master/exports/scenarios_store.json"
click node_reports "https://github.com/raman0330/weather-load-analyzer/blob/master/reports/haryana_monsoon_report.html"

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_frontend_entry,node_frontend_app,node_client_api,node_forecast_ui,node_monitor_ui,node_backtest_ui,node_simulator_ui,node_auth_gate toneBlue
class node_forecast_api,node_pipeline_api,node_short_term,node_integration,node_hybrid_engine,node_artifacts,node_accuracy toneAmber
class node_django_entry,node_django_routes,node_accounts toneMint
class node_backtester,node_scenario_store,node_reports toneRose
class node_proxy,node_compose toneNeutral
```

## Components

### React client

- [Client bootstrap](https://github.com/raman0330/weather-load-analyzer/blob/master/frontend/src/main.jsx): React entry · `frontend/src/main.jsx`
- [Product routes](https://github.com/raman0330/weather-load-analyzer/blob/master/frontend/src/App.jsx): React app · `frontend/src/App.jsx`
- [Backend API client](https://github.com/raman0330/weather-load-analyzer/blob/master/frontend/src/apiConfig.ts): endpoint config · `frontend/src/apiConfig.ts`
- [Forecast UI](https://github.com/raman0330/weather-load-analyzer/blob/master/frontend/src/features/forecast/ForecastPage.tsx): feature page · `frontend/src/features/forecast/ForecastPage.tsx`
- [Accuracy monitor](https://github.com/raman0330/weather-load-analyzer/blob/master/frontend/src/features/monitor/AccuracyMonitorPage.jsx): feature page · `frontend/src/features/monitor/AccuracyMonitorPage.jsx`
- [Backtest UI](https://github.com/raman0330/weather-load-analyzer/blob/master/frontend/src/features/backtest/BacktestPage.jsx): feature page · `frontend/src/features/backtest/BacktestPage.jsx`
- [Scenario simulator](https://github.com/raman0330/weather-load-analyzer/blob/master/frontend/src/features/simulator/SimulatorPage.tsx): feature page · `frontend/src/features/simulator/SimulatorPage.tsx`
- [Client auth gate](https://github.com/raman0330/weather-load-analyzer/blob/master/frontend/src/app/AuthGate.tsx): access boundary · `frontend/src/app/AuthGate.tsx`

### Forecast backend

- [Forecast API](https://github.com/raman0330/weather-load-analyzer/blob/master/api.py): Python API · `api.py`
- [Pipeline routes](https://github.com/raman0330/weather-load-analyzer/blob/master/backend/pipeline_router.py): API router · `backend/pipeline_router.py`
- [Short-term pipeline](https://github.com/raman0330/weather-load-analyzer/blob/master/backend/short_term_pipeline.py): forecast orchestration · `backend/short_term_pipeline.py`
- [Weather-load integration](https://github.com/raman0330/weather-load-analyzer/blob/master/weatherloadIntegrator.py): feature preparation · `weatherloadIntegrator.py`
- [Hybrid forecast engine](https://github.com/raman0330/weather-load-analyzer/blob/master/backend/hybrid_ai_engine.py): model inference · `backend/hybrid_ai_engine.py`
- [Regional model artifacts](https://github.com/raman0330/weather-load-analyzer/blob/master/backend/artifacts/haryana/model.weights.h5): local model assets · Haryana and Punjab weights and scalers are loaded locally. · `backend/artifacts/haryana/model.weights.h5`
- [Forecast correction](https://github.com/raman0330/weather-load-analyzer/blob/master/backend/accuracy/calibration_layer.py): quality layer · Calibrates, corrects, and validates forecast outputs. · `backend/accuracy/calibration_layer.py`

### Django identity

- [Django service](https://github.com/raman0330/weather-load-analyzer/blob/master/django_api/manage.py): Django entry · `django_api/manage.py`
- [Django routes](https://github.com/raman0330/weather-load-analyzer/blob/master/django_api/django_api/urls.py): project router · `django_api/django_api/urls.py`
- [Accounts domain](https://github.com/raman0330/weather-load-analyzer/blob/master/django_api/accounts/models.py): Django models/routes · `django_api/accounts/models.py`

### Evaluation & reports

- [Backtesting](https://github.com/raman0330/weather-load-analyzer/blob/master/backend/backtester.py): offline evaluator · `backend/backtester.py`
- [Scenario store](https://github.com/raman0330/weather-load-analyzer/blob/master/exports/scenarios_store.json): local state · `exports/scenarios_store.json`
- [Analysis reports](https://github.com/raman0330/weather-load-analyzer/blob/master/reports/haryana_monsoon_report.html): report output · `reports/haryana_monsoon_report.html`

### Other components

- [Reverse proxy](https://github.com/raman0330/weather-load-analyzer/blob/master/nginx.conf): Nginx · Routes containerized application traffic. · `nginx.conf`
- [Container stack](https://github.com/raman0330/weather-load-analyzer/blob/master/docker-compose.yml): Docker Compose · Defines the deployed service set. · `docker-compose.yml`

## Connections

- Container stack → Reverse proxy: deploys
- Reverse proxy → Client bootstrap: serves
- Reverse proxy → Forecast API: routes to
- Reverse proxy → Django service: routes to
- Client bootstrap → Product routes: initializes
- Product routes → Client auth gate: guards
- Product routes → Forecast UI: renders
- Product routes → Accuracy monitor: renders
- Product routes → Backtest UI: renders
- Product routes → Scenario simulator: renders
- Product routes → Backend API client: uses
- Backend API client → Forecast API: calls
- Client auth gate → Django service: accesses identity API
- Django service → Django routes: loads
- Django routes → Accounts domain: includes
- Forecast API → Pipeline routes: exposes
- Pipeline routes → Short-term pipeline: starts
- Short-term pipeline → Weather-load integration: prepares features
- Weather-load integration → Hybrid forecast engine: supplies inputs
- Hybrid forecast engine → Regional model artifacts: loads region assets
- Hybrid forecast engine → Forecast correction: produces forecast
- Forecast correction → Forecast API: returns corrected output
- Backtesting → Analysis reports: produces
- Scenario simulator → Scenario store: uses scenario state
