# yukunai/football-predictor architecture

> Architecture diagram of the GitHub repository yukunai/football-predictor, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/yukunai/football-predictor
- Repository: https://github.com/yukunai/football-predictor

## Overview

football-predictor serves match predictions through a CLI, FastAPI, and a single-page web UI. Its domain flow is public/imported match data, normalization and persistence, team-level Dixon–Coles prediction with Elo correction, and quality/calibration evaluation; separate capabilities include World Cup simulation, league coverage, and optional odds processing. The updater’s source dispatch and model/backtest dependencies are supported by excerpts or the source index. The README documents user-facing capabilities, but the large `predict.py` excerpt is absent, so detailed routing and prediction-call edges are not asserted.

Main entry points: [`scrape/update.py`](https://github.com/yukunai/football-predictor/blob/main/scrape/update.py) (Incremental updater), [`predict.py`](https://github.com/yukunai/football-predictor/blob/main/predict.py) (CLI, API, UI), [`models/dixon_coles.py`](https://github.com/yukunai/football-predictor/blob/main/models/dixon_coles.py) (Dixon-Coles model), [`data/database.py`](https://github.com/yukunai/football-predictor/blob/main/data/database.py) (Match and prediction store)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["User surfaces"]
  node_cli_api_ui["CLI, API, UI<br/>[predict.py]"]
  node_web_client["Single-page UI<br/>[app.js]"]
end

subgraph group_ingest["Data acquisition"]
  node_updater["Incremental updater<br/>[update.py]"]
  node_league_registry["League registry<br/>[registry.py]"]
  node_free_sources["Public result sources<br/>[football_data.py]"]
  node_api_football["API-Football<br/>[api_football.py]"]
  node_football_data_org["football-data.org"]
  node_xg_source["FBref xG<br/>[fbref.py]"]
  node_clubelo["Club Elo<br/>[clubelo.py]"]
  node_national_elo["National-team Elo<br/>[eloratings.py]"]
  node_csv_import["CSV importer<br/>[importers.py]"]
end

subgraph group_store["Data foundation"]
  node_names["Team name resolution<br/>[team_names.py]"]
  node_entity_resolution["Entity resolution"]
  node_database[("Match and prediction store<br/>[database.py]")]
  node_coverage["League coverage plan<br/>[coverage.py]"]
end

subgraph group_model["Prediction and evaluation"]
  node_dixon_coles["Dixon-Coles model<br/>[dixon_coles.py]"]
  node_elo_model["Elo prior<br/>[elo.py]"]
  node_team_form["Team form features<br/>[team_form.py]"]
  node_worldcup["World Cup simulation<br/>[worldcup.py]"]
end

subgraph group_ops["Quality and analytics"]
  node_backtest["Backtesting<br/>[backtest.py]"]
  node_calibration["Calibration<br/>[calibration.py]"]
  node_model_profiles["League model profiles<br/>[profiles.py]"]
  node_quality["Data quality checks<br/>[quality.py]"]
  node_odds[("Odds cache and rollup<br/>[odds_rollup.py]")]
end

node_user(("User"))
node_external_sources(("Public data providers"))

node_user -->|"requests prediction"| node_cli_api_ui
node_cli_api_ui -->|"serves UI"| node_web_client
node_cli_api_ui -->|"runs updates"| node_updater
node_updater -->|"selects leagues"| node_league_registry
node_updater -->|"fetches results"| node_free_sources
node_updater -->|"fetches optionally"| node_api_football
node_updater -->|"fetches optionally"| node_football_data_org
node_updater -.->|"fetches optionally"| node_xg_source
node_updater -.->|"fetches ratings"| node_clubelo
node_updater -.->|"fetches ratings"| node_national_elo
node_external_sources -->|"provides results"| node_free_sources
node_external_sources -->|"provides optional data"| node_api_football
node_external_sources -->|"provides optional data"| node_football_data_org
node_csv_import -->|"imports matches"| node_database
node_names -->|"canonicalizes teams"| node_database
node_entity_resolution -->|"resolves aliases"| node_names
node_updater -->|"stores results"| node_database
node_coverage -->|"builds provider plans"| node_league_registry
node_backtest -->|"fits and predicts"| node_dixon_coles
node_backtest -->|"attaches Elo"| node_elo_model
node_calibration -->|"evaluates predictions"| node_backtest
node_dixon_coles -.->|"uses Elo correction"| node_elo_model
node_dixon_coles -.->|"uses features"| node_team_form
node_quality -->|"checks stored data"| node_database
node_worldcup -->|"uses team ratings"| node_national_elo
node_odds -.->|"ingests market odds"| node_external_sources
node_cli_api_ui -.->|"produces predictions"| node_dixon_coles
node_cli_api_ui -->|"offers simulation"| node_worldcup
node_cli_api_ui -->|"exposes coverage"| node_coverage
node_cli_api_ui -->|"runs checks"| node_quality
node_model_profiles -.->|"configures model"| node_dixon_coles

click node_cli_api_ui "https://github.com/yukunai/football-predictor/blob/main/predict.py"
click node_web_client "https://github.com/yukunai/football-predictor/blob/main/static/app.js"
click node_updater "https://github.com/yukunai/football-predictor/blob/main/scrape/update.py"
click node_league_registry "https://github.com/yukunai/football-predictor/blob/main/scrape/registry.py"
click node_free_sources "https://github.com/yukunai/football-predictor/blob/main/scrape/football_data.py"
click node_api_football "https://github.com/yukunai/football-predictor/blob/main/scrape/api_football.py"
click node_football_data_org "https://github.com/yukunai/football-predictor/blob/main/scrape/football_data_org.py"
click node_xg_source "https://github.com/yukunai/football-predictor/blob/main/scrape/fbref.py"
click node_clubelo "https://github.com/yukunai/football-predictor/blob/main/scrape/clubelo.py"
click node_national_elo "https://github.com/yukunai/football-predictor/blob/main/scrape/eloratings.py"
click node_csv_import "https://github.com/yukunai/football-predictor/blob/main/data/importers.py"
click node_names "https://github.com/yukunai/football-predictor/blob/main/data/team_names.py"
click node_entity_resolution "https://github.com/yukunai/football-predictor/blob/main/data/entity_resolution.py"
click node_database "https://github.com/yukunai/football-predictor/blob/main/data/database.py"
click node_coverage "https://github.com/yukunai/football-predictor/blob/main/data/coverage.py"
click node_dixon_coles "https://github.com/yukunai/football-predictor/blob/main/models/dixon_coles.py"
click node_elo_model "https://github.com/yukunai/football-predictor/blob/main/models/elo.py"
click node_team_form "https://github.com/yukunai/football-predictor/blob/main/features/team_form.py"
click node_backtest "https://github.com/yukunai/football-predictor/blob/main/models/backtest.py"
click node_calibration "https://github.com/yukunai/football-predictor/blob/main/models/calibration.py"
click node_model_profiles "https://github.com/yukunai/football-predictor/blob/main/models/profiles.py"
click node_quality "https://github.com/yukunai/football-predictor/blob/main/data/quality.py"
click node_worldcup "https://github.com/yukunai/football-predictor/blob/main/worldcup.py"
click node_odds "https://github.com/yukunai/football-predictor/blob/main/data/odds_rollup.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_cli_api_ui,node_web_client,node_user toneBlue
class node_updater,node_league_registry,node_free_sources,node_api_football,node_football_data_org,node_xg_source,node_clubelo,node_national_elo,node_csv_import toneAmber
class node_names,node_entity_resolution,node_database,node_coverage toneMint
class node_dixon_coles,node_elo_model,node_team_form,node_worldcup toneRose
class node_backtest,node_calibration,node_model_profiles,node_quality,node_odds,node_external_sources toneIndigo
```

## Components

### User surfaces

- [CLI, API, UI](https://github.com/yukunai/football-predictor/blob/main/predict.py): `predict.py`
- [Single-page UI](https://github.com/yukunai/football-predictor/blob/main/static/app.js): `static/app.js`

### Data acquisition

- [Incremental updater](https://github.com/yukunai/football-predictor/blob/main/scrape/update.py): `scrape/update.py`
- [League registry](https://github.com/yukunai/football-predictor/blob/main/scrape/registry.py): `scrape/registry.py`
- [Public result sources](https://github.com/yukunai/football-predictor/blob/main/scrape/football_data.py): `scrape/football_data.py`
- [API-Football](https://github.com/yukunai/football-predictor/blob/main/scrape/api_football.py): `scrape/api_football.py`
- [football-data.org](https://github.com/yukunai/football-predictor/blob/main/scrape/football_data_org.py): `scrape/football_data_org.py`
- [FBref xG](https://github.com/yukunai/football-predictor/blob/main/scrape/fbref.py): `scrape/fbref.py`
- [Club Elo](https://github.com/yukunai/football-predictor/blob/main/scrape/clubelo.py): `scrape/clubelo.py`
- [National-team Elo](https://github.com/yukunai/football-predictor/blob/main/scrape/eloratings.py): `scrape/eloratings.py`
- [CSV importer](https://github.com/yukunai/football-predictor/blob/main/data/importers.py): `data/importers.py`

### Data foundation

- [Team name resolution](https://github.com/yukunai/football-predictor/blob/main/data/team_names.py): `data/team_names.py`
- [Entity resolution](https://github.com/yukunai/football-predictor/blob/main/data/entity_resolution.py): `data/entity_resolution.py`
- [Match and prediction store](https://github.com/yukunai/football-predictor/blob/main/data/database.py): `data/database.py`
- [League coverage plan](https://github.com/yukunai/football-predictor/blob/main/data/coverage.py): `data/coverage.py`

### Prediction and evaluation

- [Dixon-Coles model](https://github.com/yukunai/football-predictor/blob/main/models/dixon_coles.py): `models/dixon_coles.py`
- [Elo prior](https://github.com/yukunai/football-predictor/blob/main/models/elo.py): `models/elo.py`
- [Team form features](https://github.com/yukunai/football-predictor/blob/main/features/team_form.py): `features/team_form.py`
- [World Cup simulation](https://github.com/yukunai/football-predictor/blob/main/worldcup.py): `worldcup.py`

### Quality and analytics

- [Backtesting](https://github.com/yukunai/football-predictor/blob/main/models/backtest.py): `models/backtest.py`
- [Calibration](https://github.com/yukunai/football-predictor/blob/main/models/calibration.py): `models/calibration.py`
- [League model profiles](https://github.com/yukunai/football-predictor/blob/main/models/profiles.py): `models/profiles.py`
- [Data quality checks](https://github.com/yukunai/football-predictor/blob/main/data/quality.py): `data/quality.py`
- [Odds cache and rollup](https://github.com/yukunai/football-predictor/blob/main/data/odds_rollup.py): `data/odds_rollup.py`

### Other components

- **User**
- **Public data providers**

## Connections

- User → CLI, API, UI: requests prediction (evidence: `README.md`)
- CLI, API, UI → Single-page UI: serves UI (evidence: `README.md`)
- CLI, API, UI → Incremental updater: runs updates (evidence: `README.md`)
- Incremental updater → League registry: selects leagues (evidence: `scrape/update.py`)
- Incremental updater → Public result sources: fetches results (evidence: `scrape/update.py`)
- Incremental updater → API-Football: fetches optionally (evidence: `scrape/update.py`)
- Incremental updater → football-data.org: fetches optionally (evidence: `scrape/update.py`)
- Incremental updater → FBref xG: fetches optionally (evidence: `scrape/update.py`)
- Incremental updater → Club Elo: fetches ratings (evidence: `scrape/update.py`)
- Incremental updater → National-team Elo: fetches ratings (evidence: `scrape/update.py`)
- Public data providers → Public result sources: provides results (evidence: `README.md`)
- Public data providers → API-Football: provides optional data (evidence: `README.md`)
- Public data providers → football-data.org: provides optional data (evidence: `README.md`)
- CSV importer → Match and prediction store: imports matches (evidence: `README.md`)
- Team name resolution → Match and prediction store: canonicalizes teams (evidence: `data/database.py`)
- Entity resolution → Team name resolution: resolves aliases (evidence: `data/entity_resolution.py`)
- Incremental updater → Match and prediction store: stores results (evidence: `scrape/update.py`)
- League coverage plan → League registry: builds provider plans (evidence: `data/coverage.py`)
- Backtesting → Dixon-Coles model: fits and predicts (evidence: `models/backtest.py`)
- Backtesting → Elo prior: attaches Elo (evidence: `models/backtest.py`)
- Calibration → Backtesting: evaluates predictions (evidence: `models/calibration.py`)
- Dixon-Coles model → Elo prior: uses Elo correction
- Dixon-Coles model → Team form features: uses features
- Data quality checks → Match and prediction store: checks stored data (evidence: `data/quality.py`)
- World Cup simulation → National-team Elo: uses team ratings (evidence: `README.md`)
- Odds cache and rollup → Public data providers: ingests market odds
- CLI, API, UI → Dixon-Coles model: produces predictions (evidence: `predict.py`)
- CLI, API, UI → World Cup simulation: offers simulation (evidence: `README.md`)
- CLI, API, UI → League coverage plan: exposes coverage (evidence: `README.md`)
- CLI, API, UI → Data quality checks: runs checks (evidence: `README.md`)
- League model profiles → Dixon-Coles model: configures model
