# tylersherrick/sports-prediction-engine architecture

> Architecture diagram of the GitHub repository tylersherrick/sports-prediction-engine, 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/tylersherrick/sports-prediction-engine
- Repository: https://github.com/tylersherrick/sports-prediction-engine

## Overview

This repository is a sports-game prediction service with NFL and NHL workflows, exposed through a FastAPI application. The main user path is a game-ID request to the API, which dispatches to the sport-specific prediction module and returns a prediction; NFL responses also include winner, spread, and total predictions. Separate collection, processing, feature-generation, and modeling code supports historical data and additional betting and player-prop capabilities. The README is empty, and several links between batch stages and runtime models are not shown in the excerpts, so those links are marked unverified rather than asserted.

Main entry points: [`src/api.py`](https://github.com/tylersherrick/sports-prediction-engine/blob/master/src/api.py) (FastAPI routes), [`src/nfl_prediction.py`](https://github.com/tylersherrick/sports-prediction-engine/blob/master/src/nfl_prediction.py) (NFL predictions), [`src/nhl_prediction.py`](https://github.com/tylersherrick/sports-prediction-engine/blob/master/src/nhl_prediction.py) (NHL predictions), [`src/collectors/nfl.py`](https://github.com/tylersherrick/sports-prediction-engine/blob/master/src/collectors/nfl.py) (NFL collector)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API"]
  node_api["FastAPI routes<br/>[api.py]"]
  node_report["Prediction report<br/>[report.py]"]
end

subgraph group_data["Data preparation"]
  node_nfl_collect["NFL collector<br/>[nfl.py]"]
  node_nhl_collect["NHL collector<br/>[nhl.py]"]
  node_nfl_process["NFL processing<br/>[nfl.py]"]
  node_nhl_process["NHL processing<br/>[nhl.py]"]
  node_nhl_validate["NHL validation<br/>[nhl_validate.py]"]
  node_nfl_features["NFL features<br/>[nfl.py]"]
  node_nhl_features["NHL team features<br/>[nhl.py]"]
  node_nhl_goalie_features["Goalie features<br/>[nhl_goalies.py]"]
  node_nhl_skater_features["Skater features<br/>[nhl_skaters.py]"]
end

subgraph group_prediction["Prediction"]
  node_nfl_runtime["NFL predictions<br/>[nfl_prediction.py]"]
  node_nhl_runtime["NHL predictions<br/>[nhl_prediction.py]"]
  node_nfl_models["NFL models"]
  node_nhl_models["NHL models"]
  node_nhl_service["NHL prediction service<br/>[nhl_prediction.py]"]
  node_nhl_live["NHL live predictor"]
end

subgraph group_analysis["Evaluation"]
  node_nfl_evaluation["NFL betting evaluation<br/>[nfl_betting.py]"]
  node_nfl_spread_eval["Spread evaluation"]
  node_nfl_total_eval["Total evaluation"]
  node_nfl_calibration["NFL calibration<br/>[nfl_calibration.py]"]
  node_odds_download["Odds download"]
  node_nhl_eval["NHL evaluation<br/>[nhl_evaluate.py]"]
end

node_user(("API caller"))
node_espn["ESPN data"]
node_nfl_data[("NFL data and models")]
node_nhl_data[("NHL data and models")]

node_user -->|"requests prediction"| node_api
node_api -->|"dispatches NFL"| node_nfl_runtime
node_api -->|"dispatches NHL"| node_nhl_runtime
node_nfl_runtime -->|"fetches game data"| node_espn
node_nhl_runtime -->|"fetches game data"| node_espn
node_nfl_collect -.->|"stores raw games"| node_nfl_data
node_nfl_process -.->|"writes processed data"| node_nfl_data
node_nfl_features -.->|"writes features"| node_nfl_data
node_nfl_runtime -.->|"reads state and models"| node_nfl_data
node_nhl_collect -->|"stores raw games"| node_nhl_data
node_nhl_process -.->|"writes processed data"| node_nhl_data
node_nhl_validate -.->|"validates data"| node_nhl_data
node_nhl_features -.->|"writes features"| node_nhl_data
node_nhl_goalie_features -.->|"builds goalie features"| node_nhl_data
node_nhl_skater_features -.->|"builds skater features"| node_nhl_data
node_nhl_runtime -.->|"reads team and player state"| node_nhl_data
node_nfl_data -.->|"trains models"| node_nfl_models
node_nhl_data -.->|"trains models"| node_nhl_models
node_nhl_service -->|"loads model and features"| node_nhl_data
node_nhl_live -.->|"loads features and models"| node_nhl_data
node_nfl_evaluation -.->|"reads features and odds"| node_nfl_data
node_nfl_spread_eval -.->|"evaluates spread bets"| node_nfl_data
node_nfl_total_eval -.->|"evaluates total bets"| node_nfl_data
node_nfl_calibration -.->|"calibrates predictions"| node_nfl_data
node_odds_download -.->|"downloads odds"| node_nfl_data
node_nhl_eval -.->|"evaluates predictions"| node_nhl_data
node_api -.->|"renders reports"| node_report

click node_api "https://github.com/tylersherrick/sports-prediction-engine/blob/master/src/api.py"
click node_nfl_runtime "https://github.com/tylersherrick/sports-prediction-engine/blob/master/src/nfl_prediction.py"
click node_nhl_runtime "https://github.com/tylersherrick/sports-prediction-engine/blob/master/src/nhl_prediction.py"
click node_nfl_collect "https://github.com/tylersherrick/sports-prediction-engine/blob/master/src/collectors/nfl.py"
click node_nhl_collect "https://github.com/tylersherrick/sports-prediction-engine/blob/master/src/collectors/nhl/nhl.py"
click node_nfl_process "https://github.com/tylersherrick/sports-prediction-engine/blob/master/src/processors/nfl.py"
click node_nhl_process "https://github.com/tylersherrick/sports-prediction-engine/blob/master/src/processors/nhl.py"
click node_nhl_validate "https://github.com/tylersherrick/sports-prediction-engine/blob/master/src/processors/nhl_validate.py"
click node_nfl_features "https://github.com/tylersherrick/sports-prediction-engine/blob/master/src/features/nfl.py"
click node_nhl_features "https://github.com/tylersherrick/sports-prediction-engine/blob/master/src/features/nhl/nhl.py"
click node_nhl_goalie_features "https://github.com/tylersherrick/sports-prediction-engine/blob/master/src/features/nhl/nhl_goalies.py"
click node_nhl_skater_features "https://github.com/tylersherrick/sports-prediction-engine/blob/master/src/features/nhl/nhl_skaters.py"
click node_nfl_models "https://github.com/tylersherrick/sports-prediction-engine/tree/master/src/models"
click node_nhl_models "https://github.com/tylersherrick/sports-prediction-engine/tree/master/src/models/nhl"
click node_nhl_service "https://github.com/tylersherrick/sports-prediction-engine/blob/master/src/services/nhl_prediction.py"
click node_nhl_live "https://github.com/tylersherrick/sports-prediction-engine/blob/master/src/models/nhl/nhl_live_predictor.py"
click node_nfl_evaluation "https://github.com/tylersherrick/sports-prediction-engine/blob/master/src/evaluation/nfl_betting.py"
click node_nfl_spread_eval "https://github.com/tylersherrick/sports-prediction-engine/blob/master/src/evaluation/nfl_spread_betting.py"
click node_nfl_total_eval "https://github.com/tylersherrick/sports-prediction-engine/blob/master/src/evaluation/nfl_total_betting.py"
click node_nfl_calibration "https://github.com/tylersherrick/sports-prediction-engine/blob/master/src/evaluation/nfl_calibration.py"
click node_odds_download "https://github.com/tylersherrick/sports-prediction-engine/blob/master/src/evaluation/download_nfl_odds.py"
click node_nhl_eval "https://github.com/tylersherrick/sports-prediction-engine/blob/master/src/models/nhl/nhl_evaluate.py"
click node_report "https://github.com/tylersherrick/sports-prediction-engine/blob/master/src/report.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_api,node_report toneBlue
class node_nfl_collect,node_nhl_collect,node_nfl_process,node_nhl_process,node_nhl_validate,node_nfl_features,node_nhl_features,node_nhl_goalie_features,node_nhl_skater_features,node_nfl_data,node_nhl_data toneAmber
class node_nfl_runtime,node_nhl_runtime,node_nfl_models,node_nhl_models,node_nhl_service,node_nhl_live,node_user toneMint
class node_nfl_evaluation,node_nfl_spread_eval,node_nfl_total_eval,node_nfl_calibration,node_odds_download,node_nhl_eval toneRose
class node_espn toneIndigo
```

## Components

### API

- [FastAPI routes](https://github.com/tylersherrick/sports-prediction-engine/blob/master/src/api.py): `src/api.py`
- [Prediction report](https://github.com/tylersherrick/sports-prediction-engine/blob/master/src/report.py): `src/report.py`

### Data preparation

- [NFL collector](https://github.com/tylersherrick/sports-prediction-engine/blob/master/src/collectors/nfl.py): `src/collectors/nfl.py`
- [NHL collector](https://github.com/tylersherrick/sports-prediction-engine/blob/master/src/collectors/nhl/nhl.py): `src/collectors/nhl/nhl.py`
- [NFL processing](https://github.com/tylersherrick/sports-prediction-engine/blob/master/src/processors/nfl.py): `src/processors/nfl.py`
- [NHL processing](https://github.com/tylersherrick/sports-prediction-engine/blob/master/src/processors/nhl.py): `src/processors/nhl.py`
- [NHL validation](https://github.com/tylersherrick/sports-prediction-engine/blob/master/src/processors/nhl_validate.py): `src/processors/nhl_validate.py`
- [NFL features](https://github.com/tylersherrick/sports-prediction-engine/blob/master/src/features/nfl.py): `src/features/nfl.py`
- [NHL team features](https://github.com/tylersherrick/sports-prediction-engine/blob/master/src/features/nhl/nhl.py): `src/features/nhl/nhl.py`
- [Goalie features](https://github.com/tylersherrick/sports-prediction-engine/blob/master/src/features/nhl/nhl_goalies.py): `src/features/nhl/nhl_goalies.py`
- [Skater features](https://github.com/tylersherrick/sports-prediction-engine/blob/master/src/features/nhl/nhl_skaters.py): `src/features/nhl/nhl_skaters.py`

### Prediction

- [NFL predictions](https://github.com/tylersherrick/sports-prediction-engine/blob/master/src/nfl_prediction.py): `src/nfl_prediction.py`
- [NHL predictions](https://github.com/tylersherrick/sports-prediction-engine/blob/master/src/nhl_prediction.py): `src/nhl_prediction.py`
- [NFL models](https://github.com/tylersherrick/sports-prediction-engine/tree/master/src/models): `src/models`
- [NHL models](https://github.com/tylersherrick/sports-prediction-engine/tree/master/src/models/nhl): `src/models/nhl`
- [NHL prediction service](https://github.com/tylersherrick/sports-prediction-engine/blob/master/src/services/nhl_prediction.py): `src/services/nhl_prediction.py`
- [NHL live predictor](https://github.com/tylersherrick/sports-prediction-engine/blob/master/src/models/nhl/nhl_live_predictor.py): `src/models/nhl/nhl_live_predictor.py`

### Evaluation

- [NFL betting evaluation](https://github.com/tylersherrick/sports-prediction-engine/blob/master/src/evaluation/nfl_betting.py): `src/evaluation/nfl_betting.py`
- [Spread evaluation](https://github.com/tylersherrick/sports-prediction-engine/blob/master/src/evaluation/nfl_spread_betting.py): `src/evaluation/nfl_spread_betting.py`
- [Total evaluation](https://github.com/tylersherrick/sports-prediction-engine/blob/master/src/evaluation/nfl_total_betting.py): `src/evaluation/nfl_total_betting.py`
- [NFL calibration](https://github.com/tylersherrick/sports-prediction-engine/blob/master/src/evaluation/nfl_calibration.py): `src/evaluation/nfl_calibration.py`
- [Odds download](https://github.com/tylersherrick/sports-prediction-engine/blob/master/src/evaluation/download_nfl_odds.py): `src/evaluation/download_nfl_odds.py`
- [NHL evaluation](https://github.com/tylersherrick/sports-prediction-engine/blob/master/src/models/nhl/nhl_evaluate.py): `src/models/nhl/nhl_evaluate.py`

### Other components

- **API caller**
- **ESPN data**
- **NFL data and models**
- **NHL data and models**

## Connections

- API caller → FastAPI routes: requests prediction
- FastAPI routes → NFL predictions: dispatches NFL (evidence: `src/api.py`)
- FastAPI routes → NHL predictions: dispatches NHL (evidence: `src/api.py`)
- NFL predictions → ESPN data: fetches game data (evidence: `src/nfl_prediction.py`)
- NHL predictions → ESPN data: fetches game data (evidence: `src/nhl_prediction.py`)
- NFL collector → NFL data and models: stores raw games
- NFL processing → NFL data and models: writes processed data
- NFL features → NFL data and models: writes features
- NFL predictions → NFL data and models: reads state and models
- NHL collector → NHL data and models: stores raw games (evidence: `src/collectors/nhl/nhl.py`)
- NHL processing → NHL data and models: writes processed data
- NHL validation → NHL data and models: validates data
- NHL team features → NHL data and models: writes features
- Goalie features → NHL data and models: builds goalie features
- Skater features → NHL data and models: builds skater features
- NHL predictions → NHL data and models: reads team and player state
- NFL data and models → NFL models: trains models
- NHL data and models → NHL models: trains models
- NHL prediction service → NHL data and models: loads model and features (evidence: `src/services/nhl_prediction.py`)
- NHL live predictor → NHL data and models: loads features and models
- NFL betting evaluation → NFL data and models: reads features and odds
- Spread evaluation → NFL data and models: evaluates spread bets
- Total evaluation → NFL data and models: evaluates total bets
- NFL calibration → NFL data and models: calibrates predictions
- Odds download → NFL data and models: downloads odds
- NHL evaluation → NHL data and models: evaluates predictions
- FastAPI routes → Prediction report: renders reports
