# bentheexpert/voltrack-esz architecture

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

- Interactive diagram: https://gitdiagram.com/bentheexpert/voltrack-esz
- Repository: https://github.com/bentheexpert/voltrack-esz

## Overview

1. **Repository shape**
   - This repo is a mix of a **production Streamlit dashboard** and a **shared analysis library**.
   - `app/` contains the user-facing app and persistence for interactive runs.
   - `src/` contains reusable computation, weather, scheduling, and export modules used by the app and by batch/automation paths.
   - `Portfolio/` holds static portfolio datasets and schema documentation; `Implementation Plans/` is design/documentation only.

2. **Primary user-facing system**
   - The main entrypoint is `app/app.py`, a **Streamlit** application that orchestrates the full flow: read configuration, fetch weather data, compute uncertainty scores, calculate risk, visualize results, and store the session.
   - `app/ui_config.py` provides the sidebar controls that define the analysis scope, such as hubs, model weights, and forecast horizon.
   - `app/viz.py` renders the main dashboard views, combining Matplotlib and Plotly.

3. **Authentication and deployment boundary**
   - `app/auth.py` handles login via `streamlit-authenticator`.
   - Credentials are read from local config for development and from Streamlit secrets in hosted deployment.
   - The repo is designed for **Streamlit Community Cloud** as well as local/Docker-based execution, with `.devcontainer/` and `Dockerfile` supporting reproducible development/runtime environments.

4. **Core analytical engine**
   - `app/nui_engine.py` is the main ESZ/uncertainty engine.
   - It computes forecast spread from **multiple weather models** and ensemble dispersion, then normalizes that into the 0–100 ESZ scale.
   - `app/misschedule.py` converts ESZ plus production KPI context into FMV, the probability of mis-scheduling/imbalance.
   - These two modules are the heart of the business logic and are the main boundary between raw weather data and operational risk output.

5. **Weather ingestion subsystem**
   - `src/weather/` is a dedicated weather integration package.
   - `src/weather/providers/` contains provider adapters for different forecast sources, including **Open-Meteo**, **ECMWF/CDS**, **Tomorrow**, and **Visual Crossing**.
   - The repo’s main dashboard path emphasizes Open-Meteo’s deterministic models plus ensemble spread, but the provider abstraction makes the weather source interchangeable.
   - `src/weather/forecast_cache.py` and `src/weather/loader.py` indicate caching/loading layers to avoid recomputing or refetching forecasts unnecessarily.

6. **Data flow through a run**
   - User input from the sidebar selects portfolio/hub parameters and forecast settings.
   - Weather data is fetched from the external provider API.
   - The engine calculates inter-model variance and intra-ensemble variance.
   - ESZ is derived from those variance components.
   - FMV is calculated from ESZ and historical/statistical context.
   - The visualization layer renders the result, and the persistence layer archives the run for later restoration.

7. **Persistence and replay**
   - `app/history.py` stores per-run artifacts and restores prior sessions.
   - The persistence model is two-tier: **Parquet + metadata** for run history, and **pickle snapshots** for full session restore.
   - The dashboard can therefore reopen the last analysis state and support historical comparison without re-entering inputs.
   - `app/backfill.py` supports re-running historical dates, which is important for calibration and retrospective analysis.

8. **Batch/export and offline outputs**
   - `app/excel_export.py` and `api_data_exporter/generate_nui_excel.py` provide branded spreadsheet exports.
   - `app/output/` is the implied artifact boundary for generated reports/history.
   - This makes the system not just interactive, but also able to produce operational outputs for offline review or sharing.

9. **Related analytical subsystems in `src/`**
   - `src/analysis_engine.py`, `src/pipeline.py`, `src/market_offers_pipeline.py`, `src/own_offers_loader.py`, and `src/own_activations_loader.py` suggest a broader analytics pipeline around offers, activations, and market behavior.
   - `src/weather_price_analysis.py` and `src/weather_activation_analysis.py` extend the weather/risk concept into market and activation analysis.
   - `src/scheduling/` contains strategy loading and a strategy engine, which indicates a separate scheduling-analysis boundary used by the overall domain model.

10. **External integrations**
   - Weather forecasts come from external weather APIs, primarily **Open-Meteo** through `openmeteo-requests` / `openmeteo-sdk`.
   - Market data integration is supported via **ENTSO-E** tooling (`entsoe-py`), which matters for price/activation-related analysis.
   - The app uses Streamlit as the UI/runtime layer and `streamlit-authenticator` for access control.

11. **Special integration surface**
   - `src/nui_mcp/server.py` exposes ESZ-related functionality through an MCP server, which is an integration boundary for AI/agent consumers.
   - This means the analytics core is not only consumed by the Streamlit UI; it can also be queried programmatically by external agent tooling.

12. **Domain data and documentation**
   - `Portfolio/` contains the portfolio-specific device/unit profiles and schema docs that ground the calculations in real assets.
   - `app/docs/white_paper_fmv.tex` documents the FMV methodology, signaling that the risk model is a formalized analytical process rather than an ad hoc formula.
   - The many `Implementation Plans/` files indicate an evolving architecture with planned extensions, but they are not runtime components.

13. **Architectural takeaway**
   - The repo is centered on a **data-to-risk pipeline**: portfolio and weather inputs flow into uncertainty scoring, then into mis-scheduling probability, then into visual and exportable operational outputs.
   - The main architectural boundary is between **external data acquisition** and **internal scoring/decision logic**, with Streamlit serving as the orchestration and presentation layer.

Main entry points: [`app/app.py`](https://github.com/bentheexpert/voltrack-esz/blob/main/app/app.py) (App entry), [`src/weather`](https://github.com/bentheexpert/voltrack-esz/tree/main/src/weather) (Weather package), [`src/pipeline.py`](https://github.com/bentheexpert/voltrack-esz/blob/main/src/pipeline.py) (Pipeline), [`src/analysis_engine.py`](https://github.com/bentheexpert/voltrack-esz/blob/main/src/analysis_engine.py) (Analysis core)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Streamlit app"]
  node_app_entry["App entry<br/>Streamlit entrypoint<br/>[app.py]"]
  node_ui_config["Controls<br/>UI config<br/>[ui_config.py]"]
  node_auth["Auth<br/>access control<br/>[auth.py]"]
  node_viz["Dashboard<br/>visualization<br/>[viz.py]"]
  node_nui_engine{{"ESZ engine<br/>risk scoring<br/>[nui_engine.py]"}}
  node_misschedule{{"FMV model<br/>risk model<br/>[misschedule.py]"}}
  node_history[("History store<br/>session persistence<br/>[history.py]")]
  node_backfill["Backfill<br/>historical rerun<br/>[backfill.py]"]
  node_excel_export["Excel export<br/>report export<br/>[excel_export.py]"]
end

subgraph group_src["Shared analytics"]
  node_analysis_engine{{"Analysis core<br/>analysis engine<br/>[analysis_engine.py]"}}
  node_pipeline["Pipeline<br/>orchestration<br/>[pipeline.py]"]
  node_scheduling{{"Scheduling<br/>strategy engine<br/>[strategy_engine.py]"}}
  node_market_offers["Market offers<br/>market pipeline"]
  node_nui_mcp["MCP server<br/>agent integration<br/>[server.py]"]
end

subgraph group_weather["Weather stack"]
  node_weather_pkg[("Weather package<br/>weather integration")]
  node_openmeteo["Open-Meteo<br/>forecast provider<br/>[openmeteo.py]"]
  node_cds["CDS/ECMWF<br/>forecast provider<br/>[cds.py]"]
  node_tomorrow["Tomorrow<br/>forecast provider<br/>[tomorrow.py]"]
  node_visualcrossing["Visual Crossing<br/>forecast provider<br/>[visualcrossing.py]"]
  node_forecast_cache["Forecast cache<br/>cache layer<br/>[forecast_cache.py]"]
end

subgraph group_data["Domain data"]
  node_portfolio[("Portfolio data<br/>domain datasets")]
  node_fmv_docs["FMV docs<br/>methodology docs"]
end

node_auth -->|"protects"| node_app_entry
node_ui_config -->|"configures"| node_app_entry
node_app_entry -->|"fetches"| node_weather_pkg
node_weather_pkg -->|"uses"| node_openmeteo
node_weather_pkg -.->|"uses"| node_cds
node_weather_pkg -.->|"uses"| node_tomorrow
node_weather_pkg -.->|"uses"| node_visualcrossing
node_weather_pkg -->|"caches"| node_forecast_cache
node_app_entry -->|"scores"| node_nui_engine
node_nui_engine -->|"feeds"| node_misschedule
node_app_entry -->|"renders"| node_viz
node_app_entry -->|"stores"| node_history
node_history -.->|"supports"| node_backfill
node_app_entry -->|"exports"| node_excel_export
node_pipeline -->|"orchestrates"| node_analysis_engine
node_pipeline -->|"loads"| node_market_offers
node_pipeline -->|"applies"| node_scheduling
node_analysis_engine -->|"consumes"| node_weather_pkg
node_analysis_engine -->|"analyzes"| node_portfolio
node_nui_mcp -->|"exposes"| node_nui_engine
node_nui_mcp -->|"exposes"| node_misschedule
node_fmv_docs -.->|"documents"| node_misschedule
node_portfolio -.->|"grounds"| node_app_entry

click node_app_entry "https://github.com/bentheexpert/voltrack-esz/blob/main/app/app.py"
click node_ui_config "https://github.com/bentheexpert/voltrack-esz/blob/main/app/ui_config.py"
click node_auth "https://github.com/bentheexpert/voltrack-esz/blob/main/app/auth.py"
click node_viz "https://github.com/bentheexpert/voltrack-esz/blob/main/app/viz.py"
click node_nui_engine "https://github.com/bentheexpert/voltrack-esz/blob/main/app/nui_engine.py"
click node_misschedule "https://github.com/bentheexpert/voltrack-esz/blob/main/app/misschedule.py"
click node_history "https://github.com/bentheexpert/voltrack-esz/blob/main/app/history.py"
click node_backfill "https://github.com/bentheexpert/voltrack-esz/blob/main/app/backfill.py"
click node_excel_export "https://github.com/bentheexpert/voltrack-esz/blob/main/app/excel_export.py"
click node_analysis_engine "https://github.com/bentheexpert/voltrack-esz/blob/main/src/analysis_engine.py"
click node_pipeline "https://github.com/bentheexpert/voltrack-esz/blob/main/src/pipeline.py"
click node_scheduling "https://github.com/bentheexpert/voltrack-esz/blob/main/src/scheduling/strategy_engine.py"
click node_market_offers "https://github.com/bentheexpert/voltrack-esz/blob/main/src/market_offers_pipeline.py"
click node_weather_pkg "https://github.com/bentheexpert/voltrack-esz/tree/main/src/weather"
click node_openmeteo "https://github.com/bentheexpert/voltrack-esz/blob/main/src/weather/providers/openmeteo.py"
click node_cds "https://github.com/bentheexpert/voltrack-esz/blob/main/src/weather/providers/cds.py"
click node_tomorrow "https://github.com/bentheexpert/voltrack-esz/blob/main/src/weather/providers/tomorrow.py"
click node_visualcrossing "https://github.com/bentheexpert/voltrack-esz/blob/main/src/weather/providers/visualcrossing.py"
click node_forecast_cache "https://github.com/bentheexpert/voltrack-esz/blob/main/src/weather/forecast_cache.py"
click node_nui_mcp "https://github.com/bentheexpert/voltrack-esz/blob/main/src/nui_mcp/server.py"
click node_portfolio "https://github.com/bentheexpert/voltrack-esz/tree/main/Portfolio"
click node_fmv_docs "https://github.com/bentheexpert/voltrack-esz/blob/main/app/docs/white_paper_fmv.tex"

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_entry,node_ui_config,node_auth,node_viz,node_nui_engine,node_misschedule,node_history,node_backfill,node_excel_export toneBlue
class node_analysis_engine,node_pipeline,node_scheduling,node_market_offers,node_nui_mcp toneAmber
class node_weather_pkg,node_openmeteo,node_cds,node_tomorrow,node_visualcrossing,node_forecast_cache toneMint
class node_portfolio,node_fmv_docs toneRose
```

## Components

### Streamlit app

User-facing dashboard, orchestration, persistence, and exports.

- [App entry](https://github.com/bentheexpert/voltrack-esz/blob/main/app/app.py): Streamlit entrypoint · Main dashboard flow that orchestrates configuration, weather fetches, scoring, visualization, and storage. · `app/app.py`
- [Controls](https://github.com/bentheexpert/voltrack-esz/blob/main/app/ui_config.py): UI config · Sidebar controls for hubs, weights, horizons, and analysis scope. · `app/ui_config.py`
- [Auth](https://github.com/bentheexpert/voltrack-esz/blob/main/app/auth.py): access control · Login boundary using streamlit-authenticator with local config or hosted secrets. · `app/auth.py`
- [Dashboard](https://github.com/bentheexpert/voltrack-esz/blob/main/app/viz.py): visualization · Renders the main result views using plotting libraries. · `app/viz.py`
- [ESZ engine](https://github.com/bentheexpert/voltrack-esz/blob/main/app/nui_engine.py): risk scoring · Computes forecast spread and normalizes it into the ESZ uncertainty scale. · `app/nui_engine.py`
- [FMV model](https://github.com/bentheexpert/voltrack-esz/blob/main/app/misschedule.py): risk model · Converts ESZ and production context into mis-scheduling probability. · `app/misschedule.py`
- [History store](https://github.com/bentheexpert/voltrack-esz/blob/main/app/history.py): session persistence · Stores run artifacts and restores prior sessions for replay and comparison. · `app/history.py`
- [Backfill](https://github.com/bentheexpert/voltrack-esz/blob/main/app/backfill.py): historical rerun · Replays historical dates for calibration and retrospective analysis. · `app/backfill.py`
- [Excel export](https://github.com/bentheexpert/voltrack-esz/blob/main/app/excel_export.py): report export · Builds branded spreadsheet outputs for offline review and sharing. · `app/excel_export.py`

### Shared analytics

Reusable computation, scheduling, weather, and integration modules.

- [Analysis core](https://github.com/bentheexpert/voltrack-esz/blob/main/src/analysis_engine.py): analysis engine · Broader analytics layer for portfolio, market, and weather-driven analysis. · `src/analysis_engine.py`
- [Pipeline](https://github.com/bentheexpert/voltrack-esz/blob/main/src/pipeline.py): orchestration · Coordinates the shared analytical workflow across loaders and downstream analysis. · `src/pipeline.py`
- [Scheduling](https://github.com/bentheexpert/voltrack-esz/blob/main/src/scheduling/strategy_engine.py): strategy engine · Loads and executes scheduling strategies used by the domain model. · `src/scheduling/strategy_engine.py`
- [Market offers](https://github.com/bentheexpert/voltrack-esz/blob/main/src/market_offers_pipeline.py): market pipeline · Processes market offers and related operational inputs. · `src/market_offers_pipeline.py`
- [MCP server](https://github.com/bentheexpert/voltrack-esz/blob/main/src/nui_mcp/server.py): agent integration · Exposes ESZ-related functionality for programmatic agent consumers. · `src/nui_mcp/server.py`

### Weather stack

Forecast ingestion, caching, and provider adapters.

- [Weather package](https://github.com/bentheexpert/voltrack-esz/tree/main/src/weather): weather integration · Shared weather integration package with loading, caching, and provider abstraction. · `src/weather`
- [Open-Meteo](https://github.com/bentheexpert/voltrack-esz/blob/main/src/weather/providers/openmeteo.py): forecast provider · Primary deterministic and ensemble weather source used by the dashboard path. · `src/weather/providers/openmeteo.py`
- [CDS/ECMWF](https://github.com/bentheexpert/voltrack-esz/blob/main/src/weather/providers/cds.py): forecast provider · Forecast provider adapter for ECMWF/CDS-based data sources. · `src/weather/providers/cds.py`
- [Tomorrow](https://github.com/bentheexpert/voltrack-esz/blob/main/src/weather/providers/tomorrow.py): forecast provider · Forecast provider adapter for Tomorrow.io data. · `src/weather/providers/tomorrow.py`
- [Visual Crossing](https://github.com/bentheexpert/voltrack-esz/blob/main/src/weather/providers/visualcrossing.py): forecast provider · Forecast provider adapter for Visual Crossing data. · `src/weather/providers/visualcrossing.py`
- [Forecast cache](https://github.com/bentheexpert/voltrack-esz/blob/main/src/weather/forecast_cache.py): cache layer · Caches forecasts to avoid unnecessary refetches and recomputation. · `src/weather/forecast_cache.py`

### Domain data

Portfolio datasets and methodology documentation.

- [Portfolio data](https://github.com/bentheexpert/voltrack-esz/tree/main/Portfolio): domain datasets · Device, unit, and schema assets that ground calculations in real portfolios. · `Portfolio`
- [FMV docs](https://github.com/bentheexpert/voltrack-esz/blob/main/app/docs/white_paper_fmv.tex): methodology docs · White paper and design docs describing the FMV methodology and system design. · `app/docs/white_paper_fmv.tex`

## Connections

- Auth → App entry: protects · Authenticates access before the dashboard runs.
- Controls → App entry: configures · Defines the analysis scope and scenario inputs.
- App entry → Weather package: fetches · Pulls forecast data for the selected scope.
- Weather package → Open-Meteo: uses · Primary forecast source for the main dashboard path.
- Weather package → CDS/ECMWF: uses · Alternate weather source adapter.
- Weather package → Tomorrow: uses · Alternate weather source adapter.
- Weather package → Visual Crossing: uses · Alternate weather source adapter.
- Weather package → Forecast cache: caches · Stores and reuses forecast results.
- App entry → ESZ engine: scores · Computes ESZ from weather spread and ensemble dispersion.
- ESZ engine → FMV model: feeds · ESZ and context are converted into FMV risk.
- App entry → Dashboard: renders · Displays the dashboard outputs and charts.
- App entry → History store: stores · Persists run artifacts and session state.
- History store → Backfill: supports · Enables historical reruns and comparison workflows.
- App entry → Excel export: exports · Generates spreadsheet reports from the analysis run.
- Pipeline → Analysis core: orchestrates · Coordinates shared analytical execution.
- Pipeline → Market offers: loads · Processes market offer inputs in the broader workflow.
- Pipeline → Scheduling: applies · Uses scheduling strategies during analysis.
- Analysis core → Weather package: consumes · Weather-driven analysis reuses the shared forecast stack.
- Analysis core → Portfolio data: analyzes · Uses portfolio context and asset profiles.
- MCP server → ESZ engine: exposes · Makes ESZ functionality available to external agents.
- MCP server → FMV model: exposes · Makes FMV-related functionality available to external agents.
- FMV docs → FMV model: documents · Captures the formal FMV methodology.
- Portfolio data → App entry: grounds · Provides asset and unit context for the dashboard.
