# georgedouzas/sports-betting architecture

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

- Interactive diagram: https://gitdiagram.com/georgedouzas/sports-betting
- Repository: https://github.com/georgedouzas/sports-betting

## Overview

#### Purpose and Entry Points

`sports-betting` is a Python package for acquiring sports statistics and odds, shaping them into modelling datasets, and evaluating scikit-learn-based betting strategies. It is consumed through Python, a command-line interface, or an MCP server for AI agents.

Primary entry points:
- Package/module execution: `src/sportsbet/__init__.py`, `src/sportsbet/__main__.py`
- CLI command routing: `src/sportsbet/cli/_cli.py`
- Agent-facing MCP server: `src/sportsbet/mcp/_server.py`

#### Data Acquisition and Source Boundary

The source layer defines provider abstractions and concrete adapters for sports results/statistics and bookmaker odds. It isolates provider-specific HTTP retrieval, source resolution, schema normalization, credentials, and bundled sample data from downstream modelling.

Key paths:
- `src/sportsbet/sources/_base.py`
- `src/sportsbet/sources/_fetch.py`
- `src/sportsbet/sources/_resolver.py`

Concrete integrations include Football-Data, EuroLeague, ESPN NBA, and The Odds API:
- `src/sportsbet/sources/_football_data.py`
- `src/sportsbet/sources/_euroleague.py`
- `src/sportsbet/sources/_nba.py`
- `src/sportsbet/sources/_odds_api.py`

External calls occur during extraction; The Odds API requires an environment-held API key. Packaged compressed CSVs support sample soccer sources under `src/sportsbet/sources/data/`.

#### Dataset Construction

`DataLoader` composes one statistics source and one odds source, expands a user-selected parameter grid (league/division/year), downloads and reconciles records, and produces aligned modelling outputs: features `X`, outcome labels `Y`, and odds `O`.

Core boundary and orchestration:
- `src/sportsbet/dataloaders/_base.py`
- `src/sportsbet/dataloaders/_sourced.py`
- `src/sportsbet/_selection.py`

Training extraction uses historical completed seasons; fixture extraction is a separate current-season request for upcoming events. This separation prevents the normal training/fixture overlap and allows a fitted bettor to score future fixtures with the same feature schema. Dataloaders are intended to be persisted after extraction to avoid repeat downloads or paid API use.

#### Betting Evaluation Engine

The evaluation layer wraps compatible scikit-learn estimators as bettors. It trains models against `X`, `Y`, and odds, compares predicted probability with offered prices to identify value bets, simulates bankroll/stake outcomes, and reports backtest metrics.

Core evaluator contracts and implementations:
- `src/sportsbet/evaluation/_base.py`
- `src/sportsbet/evaluation/_classifier.py`
- `src/sportsbet/evaluation/_rules.py`

Classifier bettors support multi-market outcome prediction; rule-based bettors provide non-estimator strategy logic. Evaluation consumes prepared datasets rather than contacting providers directly.

#### Backtesting and Model Selection

Time-aware backtesting and bettor-aware hyperparameter search sit above bettor implementations. They coordinate fold fitting/evaluation and can search both estimator parameters and betting-market selection.

Key paths:
- `src/sportsbet/evaluation/_model_selection.py`
- `src/sportsbet/evaluation/_base.py`

The principal runtime dependency is scikit-learn: callers supply estimators, pipelines, and CV splitters, while the package adds odds-aware betting semantics and financial metrics.

#### CLI and Persistence Workflow

The CLI mirrors the Python workflow: select sources and parameters, extract/save a dataloader, then backtest, fit/save a bettor, or produce bets from saved artifacts. It is therefore an orchestration boundary over the same dataloader and evaluation APIs, not a separate execution engine.

Command domains:
- `src/sportsbet/cli/_data.py`
- `src/sportsbet/cli/_betting.py`
- `src/sportsbet/cli/_options.py`

#### AI-Agent Surface and Delivery

The optional MCP runtime exposes library/CLI-equivalent operations to AI agents, with agent-oriented discovery and analysis capabilities:
- `src/sportsbet/mcp/__init__.py`
- `src/sportsbet/mcp/_server.py`

The project is packaged as typed Python (`src/sportsbet/py.typed`), distributed through PyPI, and documents its public Python, CLI, and agent interfaces under `docs/interfaces/`.

Main entry points: [`src/sportsbet/evaluation/_base.py`](https://github.com/georgedouzas/sports-betting/blob/main/src/sportsbet/evaluation/_base.py) (Bettor contracts), [`src/sportsbet/dataloaders/_sourced.py`](https://github.com/georgedouzas/sports-betting/blob/main/src/sportsbet/dataloaders/_sourced.py) (DataLoader), [`src/sportsbet/cli/_cli.py`](https://github.com/georgedouzas/sports-betting/blob/main/src/sportsbet/cli/_cli.py) (CLI router), [`src/sportsbet/sources/_base.py`](https://github.com/georgedouzas/sports-betting/blob/main/src/sportsbet/sources/_base.py) (Provider contracts)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["Entry surfaces"]
  node_package["Python package<br/>package entry<br/>[__init__.py]"]
  node_module["Module execution<br/>module entry<br/>[__main__.py]"]
  node_cli["CLI router<br/>[_cli.py]"]
  node_cli_data["Data commands<br/>CLI commands<br/>[_data.py]"]
  node_cli_betting["Betting commands<br/>CLI commands<br/>[_betting.py]"]
end

subgraph group_sources["Source boundary"]
  node_provider_base["Provider contracts<br/>source abstraction<br/>[_base.py]"]
  node_source_fetch["HTTP fetch<br/>retrieval<br/>[_fetch.py]"]
  node_source_resolver["Source resolver<br/>source selection<br/>[_resolver.py]"]
  node_sports_providers{{"Sports data adapters<br/>provider adapters<br/>[_football_data.py]"}}
  node_odds_provider{{"Odds API adapter<br/>odds provider<br/>[_odds_api.py]"}}
  node_sample_data["Bundled sample CSVs<br/>packaged data"]
end

subgraph group_datasets["Dataset construction"]
  node_selection["Parameter grid<br/>selection<br/>[_selection.py]"]
  node_dataloader["DataLoader<br/>dataset orchestrator<br/>[_sourced.py]"]
  node_dataset_contract["Dataset contract<br/>dataloader base<br/>[_base.py]"]
end

subgraph group_evaluation["Betting evaluation"]
  node_bettor_base["Bettor contracts<br/>evaluation base<br/>[_base.py]"]
  node_classifier_bettor["Classifier bettors<br/>sklearn bettor<br/>[_classifier.py]"]
  node_rule_bettor["Rule bettors<br/>strategy bettor<br/>[_rules.py]"]
  node_model_selection["Backtesting and search<br/>model selection"]
end

subgraph group_delivery["Agent and delivery"]
  node_mcp_server["MCP server<br/>agent server<br/>[_server.py]"]
  node_public_docs["Interface documentation<br/>[index.md]"]
end

node_package -->|"supports execution"| node_module
node_module -->|"starts"| node_cli
node_cli -->|"routes"| node_cli_data
node_cli -->|"routes"| node_cli_betting
node_cli_data -->|"extracts and saves"| node_dataloader
node_cli_betting -->|"backtests, fits, bets"| node_bettor_base
node_source_resolver -->|"resolves"| node_provider_base
node_provider_base -->|"retrieves through"| node_source_fetch
node_sports_providers -->|"implements"| node_provider_base
node_odds_provider -->|"implements"| node_provider_base
node_sample_data -.->|"supports sample sources"| node_sports_providers
node_selection -->|"defines requests"| node_dataloader
node_source_resolver -->|"selects sources for"| node_dataloader
node_dataloader -->|"implements"| node_dataset_contract
node_dataset_contract -->|"provides X, Y, O"| node_bettor_base
node_bettor_base -->|"specializes"| node_classifier_bettor
node_bettor_base -->|"specializes"| node_rule_bettor
node_model_selection -->|"fits and evaluates"| node_bettor_base
node_mcp_server -->|"agent operations"| node_dataloader
node_mcp_server -->|"agent operations"| node_bettor_base
node_public_docs -.->|"documents"| node_cli
node_public_docs -.->|"documents"| node_mcp_server

click node_package "https://github.com/georgedouzas/sports-betting/blob/main/src/sportsbet/__init__.py"
click node_module "https://github.com/georgedouzas/sports-betting/blob/main/src/sportsbet/__main__.py"
click node_cli "https://github.com/georgedouzas/sports-betting/blob/main/src/sportsbet/cli/_cli.py"
click node_cli_data "https://github.com/georgedouzas/sports-betting/blob/main/src/sportsbet/cli/_data.py"
click node_cli_betting "https://github.com/georgedouzas/sports-betting/blob/main/src/sportsbet/cli/_betting.py"
click node_provider_base "https://github.com/georgedouzas/sports-betting/blob/main/src/sportsbet/sources/_base.py"
click node_source_fetch "https://github.com/georgedouzas/sports-betting/blob/main/src/sportsbet/sources/_fetch.py"
click node_source_resolver "https://github.com/georgedouzas/sports-betting/blob/main/src/sportsbet/sources/_resolver.py"
click node_sports_providers "https://github.com/georgedouzas/sports-betting/blob/main/src/sportsbet/sources/_football_data.py"
click node_odds_provider "https://github.com/georgedouzas/sports-betting/blob/main/src/sportsbet/sources/_odds_api.py"
click node_sample_data "https://github.com/georgedouzas/sports-betting/blob/main/src/sportsbet/sources/data/England_1_2024_stats.csv.gz"
click node_selection "https://github.com/georgedouzas/sports-betting/blob/main/src/sportsbet/_selection.py"
click node_dataloader "https://github.com/georgedouzas/sports-betting/blob/main/src/sportsbet/dataloaders/_sourced.py"
click node_dataset_contract "https://github.com/georgedouzas/sports-betting/blob/main/src/sportsbet/dataloaders/_base.py"
click node_bettor_base "https://github.com/georgedouzas/sports-betting/blob/main/src/sportsbet/evaluation/_base.py"
click node_classifier_bettor "https://github.com/georgedouzas/sports-betting/blob/main/src/sportsbet/evaluation/_classifier.py"
click node_rule_bettor "https://github.com/georgedouzas/sports-betting/blob/main/src/sportsbet/evaluation/_rules.py"
click node_model_selection "https://github.com/georgedouzas/sports-betting/blob/main/src/sportsbet/evaluation/_model_selection.py"
click node_mcp_server "https://github.com/georgedouzas/sports-betting/blob/main/src/sportsbet/mcp/_server.py"
click node_public_docs "https://github.com/georgedouzas/sports-betting/blob/main/docs/interfaces/index.md"

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_package,node_module,node_cli,node_cli_data,node_cli_betting toneBlue
class node_provider_base,node_source_fetch,node_source_resolver,node_sports_providers,node_odds_provider,node_sample_data toneAmber
class node_selection,node_dataloader,node_dataset_contract toneMint
class node_bettor_base,node_classifier_bettor,node_rule_bettor,node_model_selection toneRose
class node_mcp_server,node_public_docs toneIndigo
```

## Components

### Entry surfaces

- [Python package](https://github.com/georgedouzas/sports-betting/blob/main/src/sportsbet/__init__.py): package entry · `src/sportsbet/__init__.py`
- [Module execution](https://github.com/georgedouzas/sports-betting/blob/main/src/sportsbet/__main__.py): module entry · `src/sportsbet/__main__.py`
- [CLI router](https://github.com/georgedouzas/sports-betting/blob/main/src/sportsbet/cli/_cli.py): CLI · Routes data and betting workflows. · `src/sportsbet/cli/_cli.py`
- [Data commands](https://github.com/georgedouzas/sports-betting/blob/main/src/sportsbet/cli/_data.py): CLI commands · `src/sportsbet/cli/_data.py`
- [Betting commands](https://github.com/georgedouzas/sports-betting/blob/main/src/sportsbet/cli/_betting.py): CLI commands · `src/sportsbet/cli/_betting.py`

### Source boundary

Provider-specific retrieval and normalization.

- [Provider contracts](https://github.com/georgedouzas/sports-betting/blob/main/src/sportsbet/sources/_base.py): source abstraction · `src/sportsbet/sources/_base.py`
- [HTTP fetch](https://github.com/georgedouzas/sports-betting/blob/main/src/sportsbet/sources/_fetch.py): retrieval · `src/sportsbet/sources/_fetch.py`
- [Source resolver](https://github.com/georgedouzas/sports-betting/blob/main/src/sportsbet/sources/_resolver.py): source selection · `src/sportsbet/sources/_resolver.py`
- [Sports data adapters](https://github.com/georgedouzas/sports-betting/blob/main/src/sportsbet/sources/_football_data.py): provider adapters · Football-Data, EuroLeague, and ESPN NBA adapters. · `src/sportsbet/sources/_football_data.py`
- [Odds API adapter](https://github.com/georgedouzas/sports-betting/blob/main/src/sportsbet/sources/_odds_api.py): odds provider · Uses an environment-held API key. · `src/sportsbet/sources/_odds_api.py`
- [Bundled sample CSVs](https://github.com/georgedouzas/sports-betting/blob/main/src/sportsbet/sources/data/England_1_2024_stats.csv.gz): packaged data · `src/sportsbet/sources/data/England_1_2024_stats.csv.gz`

### Dataset construction

- [Parameter grid](https://github.com/georgedouzas/sports-betting/blob/main/src/sportsbet/_selection.py): selection · Expands league, division, and year requests. · `src/sportsbet/_selection.py`
- [DataLoader](https://github.com/georgedouzas/sports-betting/blob/main/src/sportsbet/dataloaders/_sourced.py): dataset orchestrator · Reconciles statistics and odds into X, Y, and O. · `src/sportsbet/dataloaders/_sourced.py`
- [Dataset contract](https://github.com/georgedouzas/sports-betting/blob/main/src/sportsbet/dataloaders/_base.py): dataloader base · `src/sportsbet/dataloaders/_base.py`

### Betting evaluation

- [Bettor contracts](https://github.com/georgedouzas/sports-betting/blob/main/src/sportsbet/evaluation/_base.py): evaluation base · `src/sportsbet/evaluation/_base.py`
- [Classifier bettors](https://github.com/georgedouzas/sports-betting/blob/main/src/sportsbet/evaluation/_classifier.py): sklearn bettor · Predicts multi-market outcomes and value bets. · `src/sportsbet/evaluation/_classifier.py`
- [Rule bettors](https://github.com/georgedouzas/sports-betting/blob/main/src/sportsbet/evaluation/_rules.py): strategy bettor · `src/sportsbet/evaluation/_rules.py`
- [Backtesting and search](https://github.com/georgedouzas/sports-betting/blob/main/src/sportsbet/evaluation/_model_selection.py): model selection · Coordinates time-aware folds and bettor-aware parameter search. · `src/sportsbet/evaluation/_model_selection.py`

### Agent and delivery

- [MCP server](https://github.com/georgedouzas/sports-betting/blob/main/src/sportsbet/mcp/_server.py): agent server · Exposes discovery and analysis operations to AI agents. · `src/sportsbet/mcp/_server.py`
- [Interface documentation](https://github.com/georgedouzas/sports-betting/blob/main/docs/interfaces/index.md): documentation · `docs/interfaces/index.md`

## Connections

- Python package → Module execution: supports execution
- Module execution → CLI router: starts
- CLI router → Data commands: routes
- CLI router → Betting commands: routes
- Data commands → DataLoader: extracts and saves
- Betting commands → Bettor contracts: backtests, fits, bets
- Source resolver → Provider contracts: resolves
- Provider contracts → HTTP fetch: retrieves through
- Sports data adapters → Provider contracts: implements
- Odds API adapter → Provider contracts: implements
- Bundled sample CSVs → Sports data adapters: supports sample sources
- Parameter grid → DataLoader: defines requests
- Source resolver → DataLoader: selects sources for
- DataLoader → Dataset contract: implements
- Dataset contract → Bettor contracts: provides X, Y, O
- Bettor contracts → Classifier bettors: specializes
- Bettor contracts → Rule bettors: specializes
- Backtesting and search → Bettor contracts: fits and evaluates
- MCP server → DataLoader: agent operations
- MCP server → Bettor contracts: agent operations
- Interface documentation → CLI router: documents
- Interface documentation → MCP server: documents
