# zineb550/energy-dispatch architecture

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

- Interactive diagram: https://gitdiagram.com/zineb550/energy-dispatch
- Repository: https://github.com/zineb550/energy-dispatch

## Overview

This is a Spain electricity-demand forecasting and dispatch decision-analysis application. Its principal workflow ingests and cleans OPSD demand, generation and weather data; builds leakage-safe features; forecasts next-day demand; plans generation and storage; then settles that plan against actual demand to measure realized cost. Separate planning, sensitivity and diagnostics branches examine decision value, while the Streamlit dashboard presents stored results and supports a one-day what-if. The README documents several capabilities whose implementation was not sampled; those branches are included at the documented subsystem level.

Main entry points: [`src/energy_dispatch/pipeline.py`](https://github.com/zineb550/energy-dispatch/blob/main/src/energy_dispatch/pipeline.py) (Workflow runner), [`src/energy_dispatch/evaluate.py`](https://github.com/zineb550/energy-dispatch/blob/main/src/energy_dispatch/evaluate.py) (Realized-cost evaluation), [`data/processed`](https://github.com/zineb550/energy-dispatch/tree/main/data/processed) (Forecast results), [`src/energy_dispatch/forecast.py`](https://github.com/zineb550/energy-dispatch/blob/main/src/energy_dispatch/forecast.py) (Forecast and backtest)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["Data preparation"]
  node_data["Ingest and clean<br/>[data.py]"]
  node_processed[("Clean hourly data")]
end

subgraph group_forecasting["Forecasting"]
  node_features["Leak-safe features<br/>[features.py]"]
  node_forecast["Forecast and backtest<br/>[forecast.py]"]
  node_forecast_results[("Forecast results")]
end

subgraph group_decisions["Dispatch and analysis"]
  node_optimize["Dispatch optimizer<br/>[optimize.py]"]
  node_evaluate["Realized-cost evaluation<br/>[evaluate.py]"]
  node_evaluation_results[("Evaluation results")]
  node_planning["Quantile planning<br/>[planning.py]"]
  node_sensitivity["Storage sensitivity<br/>[sensitivity.py]"]
  node_diagnostics["Forecast diagnostics<br/>[diagnostics.py]"]
  node_pipeline["Workflow runner<br/>[pipeline.py]"]
end

subgraph group_presentation["Results and dashboard"]
  node_dashboard_data["Dashboard data layer<br/>[dashboard.py]"]
  node_dashboard_app["Streamlit dashboard<br/>[streamlit_app.py]"]
  node_demo_results[("Demo result files")]
end

node_operator(("Grid operator"))
node_opsd[("OPSD data")]

node_operator -->|"views results"| node_dashboard_app
node_data -->|"downloads"| node_opsd
node_data -->|"writes cleaned data"| node_processed
node_processed -->|"provides inputs"| node_forecast
node_forecast -->|"builds features"| node_features
node_forecast -->|"writes forecasts"| node_forecast_results
node_forecast_results -->|"provides forecasts"| node_evaluate
node_evaluate -->|"plans dispatch"| node_optimize
node_evaluate -->|"writes evaluation"| node_evaluation_results
node_forecast_results -->|"provides forecast intervals"| node_planning
node_planning -->|"evaluates plans"| node_evaluate
node_forecast_results -->|"provides scenarios"| node_sensitivity
node_sensitivity -->|"evaluates variants"| node_evaluate
node_forecast_results -->|"provides forecasts"| node_diagnostics
node_evaluation_results -->|"provides costs"| node_diagnostics
node_diagnostics -->|"tests plans"| node_planning
node_pipeline -->|"runs stage"| node_data
node_pipeline -->|"runs stage"| node_forecast
node_pipeline -->|"runs stage"| node_evaluate
node_pipeline -->|"runs stage"| node_sensitivity
node_pipeline -->|"runs stage"| node_planning
node_pipeline -->|"runs stage"| node_diagnostics
node_dashboard_app -->|"loads result views"| node_dashboard_data
node_dashboard_data -->|"reads results"| node_forecast_results
node_dashboard_data -->|"reads results"| node_evaluation_results
node_dashboard_app -->|"replans one day"| node_evaluate
node_pipeline -->|"exports demo results"| node_demo_results

click node_data "https://github.com/zineb550/energy-dispatch/blob/main/src/energy_dispatch/data.py"
click node_processed "https://github.com/zineb550/energy-dispatch/tree/main/data/processed"
click node_features "https://github.com/zineb550/energy-dispatch/blob/main/src/energy_dispatch/features.py"
click node_forecast "https://github.com/zineb550/energy-dispatch/blob/main/src/energy_dispatch/forecast.py"
click node_forecast_results "https://github.com/zineb550/energy-dispatch/tree/main/data/processed"
click node_optimize "https://github.com/zineb550/energy-dispatch/blob/main/src/energy_dispatch/optimize.py"
click node_evaluate "https://github.com/zineb550/energy-dispatch/blob/main/src/energy_dispatch/evaluate.py"
click node_evaluation_results "https://github.com/zineb550/energy-dispatch/tree/main/data/processed"
click node_planning "https://github.com/zineb550/energy-dispatch/blob/main/src/energy_dispatch/planning.py"
click node_sensitivity "https://github.com/zineb550/energy-dispatch/blob/main/src/energy_dispatch/sensitivity.py"
click node_diagnostics "https://github.com/zineb550/energy-dispatch/blob/main/src/energy_dispatch/diagnostics.py"
click node_pipeline "https://github.com/zineb550/energy-dispatch/blob/main/src/energy_dispatch/pipeline.py"
click node_dashboard_data "https://github.com/zineb550/energy-dispatch/blob/main/src/energy_dispatch/dashboard.py"
click node_dashboard_app "https://github.com/zineb550/energy-dispatch/blob/main/app/streamlit_app.py"
click node_demo_results "https://github.com/zineb550/energy-dispatch/tree/main/app/demo_results"

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_data,node_processed toneBlue
class node_features,node_forecast,node_forecast_results,node_opsd toneAmber
class node_optimize,node_evaluate,node_evaluation_results,node_planning,node_sensitivity,node_diagnostics,node_pipeline toneMint
class node_dashboard_data,node_dashboard_app,node_demo_results toneRose
class node_operator toneIndigo
```

## Components

### Data preparation

- [Ingest and clean](https://github.com/zineb550/energy-dispatch/blob/main/src/energy_dispatch/data.py): `src/energy_dispatch/data.py`
- [Clean hourly data](https://github.com/zineb550/energy-dispatch/tree/main/data/processed): `data/processed`

### Forecasting

- [Leak-safe features](https://github.com/zineb550/energy-dispatch/blob/main/src/energy_dispatch/features.py): `src/energy_dispatch/features.py`
- [Forecast and backtest](https://github.com/zineb550/energy-dispatch/blob/main/src/energy_dispatch/forecast.py): `src/energy_dispatch/forecast.py`
- [Forecast results](https://github.com/zineb550/energy-dispatch/tree/main/data/processed): `data/processed`

### Dispatch and analysis

- [Dispatch optimizer](https://github.com/zineb550/energy-dispatch/blob/main/src/energy_dispatch/optimize.py): `src/energy_dispatch/optimize.py`
- [Realized-cost evaluation](https://github.com/zineb550/energy-dispatch/blob/main/src/energy_dispatch/evaluate.py): `src/energy_dispatch/evaluate.py`
- [Evaluation results](https://github.com/zineb550/energy-dispatch/tree/main/data/processed): `data/processed`
- [Quantile planning](https://github.com/zineb550/energy-dispatch/blob/main/src/energy_dispatch/planning.py): `src/energy_dispatch/planning.py`
- [Storage sensitivity](https://github.com/zineb550/energy-dispatch/blob/main/src/energy_dispatch/sensitivity.py): `src/energy_dispatch/sensitivity.py`
- [Forecast diagnostics](https://github.com/zineb550/energy-dispatch/blob/main/src/energy_dispatch/diagnostics.py): `src/energy_dispatch/diagnostics.py`
- [Workflow runner](https://github.com/zineb550/energy-dispatch/blob/main/src/energy_dispatch/pipeline.py): `src/energy_dispatch/pipeline.py`

### Results and dashboard

- [Dashboard data layer](https://github.com/zineb550/energy-dispatch/blob/main/src/energy_dispatch/dashboard.py): `src/energy_dispatch/dashboard.py`
- [Streamlit dashboard](https://github.com/zineb550/energy-dispatch/blob/main/app/streamlit_app.py): `app/streamlit_app.py`
- [Demo result files](https://github.com/zineb550/energy-dispatch/tree/main/app/demo_results): `app/demo_results`

### Other components

- **Grid operator**
- **OPSD data**

## Connections

- Grid operator → Streamlit dashboard: views results
- Ingest and clean → OPSD data: downloads
- Ingest and clean → Clean hourly data: writes cleaned data
- Clean hourly data → Forecast and backtest: provides inputs
- Forecast and backtest → Leak-safe features: builds features
- Forecast and backtest → Forecast results: writes forecasts
- Forecast results → Realized-cost evaluation: provides forecasts
- Realized-cost evaluation → Dispatch optimizer: plans dispatch
- Realized-cost evaluation → Evaluation results: writes evaluation
- Forecast results → Quantile planning: provides forecast intervals
- Quantile planning → Realized-cost evaluation: evaluates plans
- Forecast results → Storage sensitivity: provides scenarios
- Storage sensitivity → Realized-cost evaluation: evaluates variants
- Forecast results → Forecast diagnostics: provides forecasts
- Evaluation results → Forecast diagnostics: provides costs
- Forecast diagnostics → Quantile planning: tests plans
- Workflow runner → Ingest and clean: runs stage
- Workflow runner → Forecast and backtest: runs stage
- Workflow runner → Realized-cost evaluation: runs stage
- Workflow runner → Storage sensitivity: runs stage
- Workflow runner → Quantile planning: runs stage
- Workflow runner → Forecast diagnostics: runs stage
- Streamlit dashboard → Dashboard data layer: loads result views
- Dashboard data layer → Forecast results: reads results
- Dashboard data layer → Evaluation results: reads results
- Streamlit dashboard → Realized-cost evaluation: replans one day
- Workflow runner → Demo result files: exports demo results
