# uzeyr77/prempredictor architecture

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

- Interactive diagram: https://gitdiagram.com/uzeyr77/prempredictor
- Repository: https://github.com/uzeyr77/prempredictor

## Overview

Premier League Predictor serves match and season forecasts through a Flask dashboard and scenario-analysis flow. Requests pass through route handlers and a prediction orchestration service to the statistical engine and repository; the repository reads league and match data and maintains cached results. Separate job endpoints trigger match-data, standings, and cache-refresh tasks. The README documents scheduled updates from Football-Data.org, but sampled job code does not show the API client or its database writes, so those links are marked unverified where appropriate.

Main entry points: [`services/prediction_service.py`](https://github.com/uzeyr77/prempredictor/blob/main/services/prediction_service.py) (Prediction orchestration), [`app_factory.py`](https://github.com/uzeyr77/prempredictor/blob/main/app_factory.py) (Flask app setup), [`routes/jobs_routes.py`](https://github.com/uzeyr77/prempredictor/blob/main/routes/jobs_routes.py) (Job endpoints), [`routes/dashboard_routes.py`](https://github.com/uzeyr77/prempredictor/blob/main/routes/dashboard_routes.py) (Dashboard routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_dashboard_routes["Dashboard routes"]
  node_dashboard_view["Dashboard view<br/>[index.html]"]
  node_scenario_routes["Scenario routes<br/>[scenario_routes.py]"]
  node_scenario_view["Scenario view<br/>[scenario.html]"]
  node_app["Flask app setup<br/>[app_factory.py]"]
end

subgraph group_prediction["Prediction services"]
  node_prediction_service["Prediction orchestration"]
  node_prediction_engine["Prediction engine<br/>[predictions.py]"]
  node_validation["Scenario validation<br/>[validators.py]"]
  node_contracts["Response contracts<br/>[contracts.py]"]
end

subgraph group_data["Data access"]
  node_repository["Prediction repository<br/>[repository.py]"]
  node_db_connection["Database connection<br/>[database.py]"]
  node_postgres[("PostgreSQL")]
end

subgraph group_operations["Data operations"]
  node_jobs_routes["Job endpoints<br/>[jobs_routes.py]"]
  node_match_job["Match data update"]
  node_table_job["Standings update"]
  node_cache_job["Cache refresh<br/>[refresh_cache.py]"]
end

node_user(("Dashboard user"))
node_schedule(("Job scheduler"))
node_football_data["Football-Data.org"]

node_user -->|"requests dashboard"| node_dashboard_routes
node_dashboard_routes -->|"gets summary"| node_prediction_service
node_dashboard_routes -->|"renders"| node_dashboard_view
node_user -->|"submits scenario"| node_scenario_routes
node_scenario_routes -->|"renders"| node_scenario_view
node_scenario_routes -->|"runs scenario"| node_prediction_service
node_app -->|"registers"| node_dashboard_routes
node_app -->|"registers"| node_scenario_routes
node_app -->|"registers"| node_jobs_routes
node_app -->|"constructs"| node_prediction_service
node_app -->|"constructs"| node_repository
node_prediction_service -->|"calls modeling"| node_prediction_engine
node_prediction_service -->|"reads data"| node_repository
node_prediction_service -->|"validates overrides"| node_validation
node_prediction_service -->|"uses response types"| node_contracts
node_repository -->|"opens connections"| node_db_connection
node_db_connection -->|"connects"| node_postgres
node_schedule -->|"triggers jobs"| node_jobs_routes
node_jobs_routes -->|"starts update"| node_match_job
node_jobs_routes -->|"starts update"| node_table_job
node_jobs_routes -->|"starts refresh"| node_cache_job
node_schedule -->|"runs periodically"| node_match_job
node_schedule -->|"runs periodically"| node_cache_job
node_match_job -.->|"fetches match data"| node_football_data
node_match_job -.->|"syncs records"| node_postgres
node_table_job -.->|"fetches standings"| node_football_data
node_table_job -.->|"syncs records"| node_postgres
node_cache_job -->|"refreshes predictions"| node_prediction_service

click node_dashboard_routes "https://github.com/uzeyr77/prempredictor/blob/main/routes/dashboard_routes.py"
click node_dashboard_view "https://github.com/uzeyr77/prempredictor/blob/main/templates/index.html"
click node_scenario_routes "https://github.com/uzeyr77/prempredictor/blob/main/routes/scenario_routes.py"
click node_scenario_view "https://github.com/uzeyr77/prempredictor/blob/main/templates/scenario.html"
click node_app "https://github.com/uzeyr77/prempredictor/blob/main/app_factory.py"
click node_prediction_service "https://github.com/uzeyr77/prempredictor/blob/main/services/prediction_service.py"
click node_prediction_engine "https://github.com/uzeyr77/prempredictor/blob/main/services/predictions.py"
click node_validation "https://github.com/uzeyr77/prempredictor/blob/main/services/validators.py"
click node_contracts "https://github.com/uzeyr77/prempredictor/blob/main/models/contracts.py"
click node_repository "https://github.com/uzeyr77/prempredictor/blob/main/services/repository.py"
click node_db_connection "https://github.com/uzeyr77/prempredictor/blob/main/database.py"
click node_jobs_routes "https://github.com/uzeyr77/prempredictor/blob/main/routes/jobs_routes.py"
click node_match_job "https://github.com/uzeyr77/prempredictor/blob/main/scripts/jobs/update_match_data.py"
click node_table_job "https://github.com/uzeyr77/prempredictor/blob/main/scripts/jobs/update_league_table.py"
click node_cache_job "https://github.com/uzeyr77/prempredictor/blob/main/scripts/jobs/refresh_cache.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_dashboard_routes,node_dashboard_view,node_scenario_routes,node_scenario_view,node_app,node_user toneBlue
class node_prediction_service,node_prediction_engine,node_validation,node_contracts toneAmber
class node_repository,node_db_connection,node_postgres toneMint
class node_jobs_routes,node_match_job,node_table_job,node_cache_job,node_schedule toneRose
class node_football_data toneIndigo
```

## Components

### Web experience

- [Dashboard routes](https://github.com/uzeyr77/prempredictor/blob/main/routes/dashboard_routes.py): `routes/dashboard_routes.py`
- [Dashboard view](https://github.com/uzeyr77/prempredictor/blob/main/templates/index.html): `templates/index.html`
- [Scenario routes](https://github.com/uzeyr77/prempredictor/blob/main/routes/scenario_routes.py): `routes/scenario_routes.py`
- [Scenario view](https://github.com/uzeyr77/prempredictor/blob/main/templates/scenario.html): `templates/scenario.html`
- [Flask app setup](https://github.com/uzeyr77/prempredictor/blob/main/app_factory.py): `app_factory.py`

### Prediction services

- [Prediction orchestration](https://github.com/uzeyr77/prempredictor/blob/main/services/prediction_service.py): `services/prediction_service.py`
- [Prediction engine](https://github.com/uzeyr77/prempredictor/blob/main/services/predictions.py): `services/predictions.py`
- [Scenario validation](https://github.com/uzeyr77/prempredictor/blob/main/services/validators.py): `services/validators.py`
- [Response contracts](https://github.com/uzeyr77/prempredictor/blob/main/models/contracts.py): `models/contracts.py`

### Data access

- [Prediction repository](https://github.com/uzeyr77/prempredictor/blob/main/services/repository.py): `services/repository.py`
- [Database connection](https://github.com/uzeyr77/prempredictor/blob/main/database.py): `database.py`
- **PostgreSQL**

### Data operations

- [Job endpoints](https://github.com/uzeyr77/prempredictor/blob/main/routes/jobs_routes.py): `routes/jobs_routes.py`
- [Match data update](https://github.com/uzeyr77/prempredictor/blob/main/scripts/jobs/update_match_data.py): `scripts/jobs/update_match_data.py`
- [Standings update](https://github.com/uzeyr77/prempredictor/blob/main/scripts/jobs/update_league_table.py): `scripts/jobs/update_league_table.py`
- [Cache refresh](https://github.com/uzeyr77/prempredictor/blob/main/scripts/jobs/refresh_cache.py): `scripts/jobs/refresh_cache.py`

### Other components

- **Dashboard user**
- **Job scheduler**
- **Football-Data.org**

## Connections

- Dashboard user → Dashboard routes: requests dashboard (evidence: `README.md`)
- Dashboard routes → Prediction orchestration: gets summary (evidence: `routes/dashboard_routes.py`)
- Dashboard routes → Dashboard view: renders (evidence: `routes/dashboard_routes.py`)
- Dashboard user → Scenario routes: submits scenario (evidence: `README.md`)
- Scenario routes → Scenario view: renders (evidence: `routes/scenario_routes.py`)
- Scenario routes → Prediction orchestration: runs scenario (evidence: `routes/scenario_routes.py`)
- Flask app setup → Dashboard routes: registers (evidence: `app_factory.py`)
- Flask app setup → Scenario routes: registers (evidence: `app_factory.py`)
- Flask app setup → Job endpoints: registers (evidence: `app_factory.py`)
- Flask app setup → Prediction orchestration: constructs (evidence: `app_factory.py`)
- Flask app setup → Prediction repository: constructs (evidence: `app_factory.py`)
- Prediction orchestration → Prediction engine: calls modeling (evidence: `services/prediction_service.py`)
- Prediction orchestration → Prediction repository: reads data (evidence: `services/prediction_service.py`)
- Prediction orchestration → Scenario validation: validates overrides (evidence: `services/prediction_service.py`)
- Prediction orchestration → Response contracts: uses response types (evidence: `services/prediction_service.py`)
- Prediction repository → Database connection: opens connections (evidence: `services/repository.py`)
- Database connection → PostgreSQL: connects (evidence: `database.py`)
- Job scheduler → Job endpoints: triggers jobs (evidence: `README.md`)
- Job endpoints → Match data update: starts update (evidence: `routes/jobs_routes.py`)
- Job endpoints → Standings update: starts update (evidence: `routes/jobs_routes.py`)
- Job endpoints → Cache refresh: starts refresh (evidence: `routes/jobs_routes.py`)
- Job scheduler → Match data update: runs periodically (evidence: `README.md`)
- Job scheduler → Cache refresh: runs periodically (evidence: `README.md`)
- Match data update → Football-Data.org: fetches match data
- Match data update → PostgreSQL: syncs records
- Standings update → Football-Data.org: fetches standings
- Standings update → PostgreSQL: syncs records
- Cache refresh → Prediction orchestration: refreshes predictions (evidence: `scripts/jobs/refresh_cache.py`)
