# rasmusab/swedish-election-night-prediction-2026 architecture

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

- Interactive diagram: https://gitdiagram.com/rasmusab/swedish-election-night-prediction-2026
- Repository: https://github.com/rasmusab/swedish-election-night-prediction-2026

## Overview

This repository produces Swedish 2026 election-night seat projections and an HTML report from official preliminary results. The main workflow is an on-demand update: collect and verify a feed snapshot, reconcile and align it with frozen election geography, forecast votes and seats, simulate uncertainty, then render and write the report. Separate branches refresh background inputs and check operational readiness. The README documents rehearsal and publication behavior; some subsystem links below are based on those docs because their implementations were not sampled.

Main entry points: [`val2026/election_report.py`](https://github.com/rasmusab/swedish-election-night-prediction-2026/blob/main/val2026/election_report.py) (Report update cycle), [`val2026/election_forecast.py`](https://github.com/rasmusab/swedish-election-night-prediction-2026/blob/main/val2026/election_forecast.py) (Vote forecast), [`val2026/readiness.py`](https://github.com/rasmusab/swedish-election-night-prediction-2026/blob/main/val2026/readiness.py) (Readiness checks), [`val2026/election_feed.py`](https://github.com/rasmusab/swedish-election-night-prediction-2026/blob/main/val2026/election_feed.py) (Feed collector)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_collection["Feed collection"]
  node_feed["Feed collector<br/>[election_feed.py]"]
  node_snapshots[("Verified snapshots")]
  node_reconciliation["Aggregate reconciliation<br/>[reconciliation.py]"]
end

subgraph group_forecast["Forecasting"]
  node_reference[("Frozen geography")]
  node_forecast["Vote forecast"]
  node_model["Forecast model<br/>[forecast_model.py]"]
  node_seats["Seat allocation<br/>[seats.py]"]
  node_simulation["Uncertainty simulation<br/>[uncertainty.py]"]
  node_uncertainty_config["Uncertainty settings"]
end

subgraph group_reporting["Report generation"]
  node_update["Update command<br/>[update-report.py]"]
  node_notebook["Election-night workflow<br/>[election-night.py]"]
  node_report_cycle["Report update cycle<br/>[election_report.py]"]
  node_report_html["Report presentation<br/>[election_report.py]"]
  node_homepage["Generated report<br/>[index.html]"]
end

subgraph group_operations["Preparation and checks"]
  node_input_refresh["Input refresh<br/>[refresh-inputs.py]"]
  node_readiness["Readiness checks<br/>[readiness.py]"]
  node_frozen_outputs[("Prepared inputs")]
end

node_operator(("Operator"))
node_authority(("Election authority"))

node_operator -->|"runs"| node_update
node_update -->|"executes"| node_notebook
node_notebook -->|"runs cycle"| node_report_cycle
node_report_cycle -->|"collects snapshot"| node_feed
node_feed -->|"fetches feed"| node_authority
node_feed -->|"stores verified data"| node_snapshots
node_report_cycle -->|"loads snapshot"| node_snapshots
node_report_cycle -->|"loads inputs"| node_reference
node_report_cycle -->|"reconciles totals"| node_reconciliation
node_report_cycle -->|"evaluates snapshot"| node_forecast
node_forecast -->|"predicts votes"| node_model
node_forecast -->|"allocates seats"| node_seats
node_forecast -->|"simulates ranges"| node_simulation
node_simulation -->|"uses settings"| node_uncertainty_config
node_report_cycle -->|"builds presentation"| node_report_html
node_report_html -->|"renders HTML"| node_homepage
node_operator -->|"refreshes inputs"| node_input_refresh
node_input_refresh -->|"retrieves sources"| node_authority
node_input_refresh -->|"writes prepared data"| node_frozen_outputs
node_operator -->|"checks readiness"| node_readiness
node_readiness -->|"checks feed access"| node_authority
node_readiness -->|"checks snapshot"| node_snapshots
node_readiness -->|"checks alignment"| node_reference

click node_update "https://github.com/rasmusab/swedish-election-night-prediction-2026/blob/main/update-report.py"
click node_notebook "https://github.com/rasmusab/swedish-election-night-prediction-2026/blob/main/election-night.py"
click node_report_cycle "https://github.com/rasmusab/swedish-election-night-prediction-2026/blob/main/val2026/election_report.py"
click node_feed "https://github.com/rasmusab/swedish-election-night-prediction-2026/blob/main/val2026/election_feed.py"
click node_snapshots "https://github.com/rasmusab/swedish-election-night-prediction-2026/tree/main/data"
click node_reconciliation "https://github.com/rasmusab/swedish-election-night-prediction-2026/blob/main/val2026/reconciliation.py"
click node_reference "https://github.com/rasmusab/swedish-election-night-prediction-2026/tree/main/reference-data"
click node_forecast "https://github.com/rasmusab/swedish-election-night-prediction-2026/blob/main/val2026/election_forecast.py"
click node_model "https://github.com/rasmusab/swedish-election-night-prediction-2026/blob/main/val2026/forecast_model.py"
click node_seats "https://github.com/rasmusab/swedish-election-night-prediction-2026/blob/main/val2026/seats.py"
click node_simulation "https://github.com/rasmusab/swedish-election-night-prediction-2026/blob/main/val2026/uncertainty.py"
click node_uncertainty_config "https://github.com/rasmusab/swedish-election-night-prediction-2026/blob/main/val2026/forecast_uncertainty.py"
click node_report_html "https://github.com/rasmusab/swedish-election-night-prediction-2026/blob/main/val2026/election_report.py"
click node_homepage "https://github.com/rasmusab/swedish-election-night-prediction-2026/blob/main/index.html"
click node_input_refresh "https://github.com/rasmusab/swedish-election-night-prediction-2026/blob/main/refresh-inputs.py"
click node_readiness "https://github.com/rasmusab/swedish-election-night-prediction-2026/blob/main/val2026/readiness.py"
click node_frozen_outputs "https://github.com/rasmusab/swedish-election-night-prediction-2026/tree/main/reference-data"

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_feed,node_snapshots,node_reconciliation toneBlue
class node_reference,node_forecast,node_model,node_seats,node_simulation,node_uncertainty_config toneAmber
class node_update,node_notebook,node_report_cycle,node_report_html,node_homepage toneMint
class node_input_refresh,node_readiness,node_frozen_outputs toneRose
class node_operator,node_authority toneIndigo
```

## Components

### Feed collection

- [Feed collector](https://github.com/rasmusab/swedish-election-night-prediction-2026/blob/main/val2026/election_feed.py): `val2026/election_feed.py`
- [Verified snapshots](https://github.com/rasmusab/swedish-election-night-prediction-2026/tree/main/data): `data`
- [Aggregate reconciliation](https://github.com/rasmusab/swedish-election-night-prediction-2026/blob/main/val2026/reconciliation.py): `val2026/reconciliation.py`

### Forecasting

- [Frozen geography](https://github.com/rasmusab/swedish-election-night-prediction-2026/tree/main/reference-data): `reference-data`
- [Vote forecast](https://github.com/rasmusab/swedish-election-night-prediction-2026/blob/main/val2026/election_forecast.py): `val2026/election_forecast.py`
- [Forecast model](https://github.com/rasmusab/swedish-election-night-prediction-2026/blob/main/val2026/forecast_model.py): `val2026/forecast_model.py`
- [Seat allocation](https://github.com/rasmusab/swedish-election-night-prediction-2026/blob/main/val2026/seats.py): `val2026/seats.py`
- [Uncertainty simulation](https://github.com/rasmusab/swedish-election-night-prediction-2026/blob/main/val2026/uncertainty.py): `val2026/uncertainty.py`
- [Uncertainty settings](https://github.com/rasmusab/swedish-election-night-prediction-2026/blob/main/val2026/forecast_uncertainty.py): `val2026/forecast_uncertainty.py`

### Report generation

- [Update command](https://github.com/rasmusab/swedish-election-night-prediction-2026/blob/main/update-report.py): `update-report.py`
- [Election-night workflow](https://github.com/rasmusab/swedish-election-night-prediction-2026/blob/main/election-night.py): `election-night.py`
- [Report update cycle](https://github.com/rasmusab/swedish-election-night-prediction-2026/blob/main/val2026/election_report.py): `val2026/election_report.py`
- [Report presentation](https://github.com/rasmusab/swedish-election-night-prediction-2026/blob/main/val2026/election_report.py): `val2026/election_report.py`
- [Generated report](https://github.com/rasmusab/swedish-election-night-prediction-2026/blob/main/index.html): `index.html`

### Preparation and checks

- [Input refresh](https://github.com/rasmusab/swedish-election-night-prediction-2026/blob/main/refresh-inputs.py): `refresh-inputs.py`
- [Readiness checks](https://github.com/rasmusab/swedish-election-night-prediction-2026/blob/main/val2026/readiness.py): `val2026/readiness.py`
- [Prepared inputs](https://github.com/rasmusab/swedish-election-night-prediction-2026/tree/main/reference-data): `reference-data`

### Other components

- **Operator**
- **Election authority**

## Connections

- Operator → Update command: runs
- Update command → Election-night workflow: executes
- Election-night workflow → Report update cycle: runs cycle
- Report update cycle → Feed collector: collects snapshot
- Feed collector → Election authority: fetches feed
- Feed collector → Verified snapshots: stores verified data
- Report update cycle → Verified snapshots: loads snapshot
- Report update cycle → Frozen geography: loads inputs
- Report update cycle → Aggregate reconciliation: reconciles totals
- Report update cycle → Vote forecast: evaluates snapshot
- Vote forecast → Forecast model: predicts votes
- Vote forecast → Seat allocation: allocates seats
- Vote forecast → Uncertainty simulation: simulates ranges
- Uncertainty simulation → Uncertainty settings: uses settings
- Report update cycle → Report presentation: builds presentation
- Report presentation → Generated report: renders HTML
- Operator → Input refresh: refreshes inputs
- Input refresh → Election authority: retrieves sources
- Input refresh → Prepared inputs: writes prepared data
- Operator → Readiness checks: checks readiness
- Readiness checks → Election authority: checks feed access
- Readiness checks → Verified snapshots: checks snapshot
- Readiness checks → Frozen geography: checks alignment
