# nabildia/nba-game-data architecture

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

- Interactive diagram: https://gitdiagram.com/nabildia/nba-game-data
- Repository: https://github.com/nabildia/nba-game-data

## Overview

NBA-Game-Data is a Streamlit dashboard for fetching NBA statistics, persisting data, exploring team and player performance, and training a win-factor model. The main workflow starts with a user selecting a season and data type, then uses NBA data loaders and displays results; the team CSV also feeds the Random Forest model. Team rankings and comparisons, player statistics and shot charts, and model evaluation are distinct dashboard capabilities. Several calls are in omitted portions of main.py, so those links rely on README documentation rather than sampled call sites.

Main entry points: [`main.py`](https://github.com/nabildia/nba-game-data/blob/main/main.py) (Streamlit dashboard), [`src/ml_predictions.py`](https://github.com/nabildia/nba-game-data/blob/main/src/ml_predictions.py) (Win-factor model), [`src/analyse.py`](https://github.com/nabildia/nba-game-data/blob/main/src/analyse.py) (Team game logs), [`src/database.py`](https://github.com/nabildia/nba-game-data/blob/main/src/database.py) (Database access)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_acquisition["Data acquisition"]
  node_team_logs["Team game logs<br/>[analyse.py]"]
  node_player_logs["Player game logs<br/>[analyse.py]"]
  node_advanced_stats["Advanced team stats<br/>[analyse.py]"]
  node_shot_data["Player shot data<br/>[analyse.py]"]
end

subgraph group_exploration["Dashboard analytics"]
  node_app["Streamlit dashboard<br/>[main.py]"]
  node_team_views["Team rankings and comparisons<br/>[main.py]"]
  node_player_views["Player stats and comparisons<br/>[main.py]"]
  node_shot_chart["Shot chart rendering<br/>[analyse.py]"]
  node_model_view["Model evaluation view<br/>[main.py]"]
end

subgraph group_persistence["Storage and modeling"]
  node_team_csv["Team stats CSV<br/>[nba_team_stats.csv]"]
  node_database[("SQLite database<br/>[nba_database.db]")]
  node_db_helpers["Database access<br/>[database.py]"]
  node_model["Win-factor model<br/>[ml_predictions.py]"]
end

node_user(("Dashboard user"))
node_nba_api{{"NBA Stats API"}}

node_user -->|"uses"| node_app
node_app -->|"loads team data"| node_team_logs
node_app -->|"loads player data"| node_player_logs
node_app -->|"loads advanced stats"| node_advanced_stats
node_app -->|"requests shot data"| node_shot_data
node_team_logs -->|"fetches logs"| node_nba_api
node_player_logs -->|"fetches logs"| node_nba_api
node_advanced_stats -->|"fetches stats"| node_nba_api
node_shot_data -->|"fetches shots"| node_nba_api
node_app -->|"renders"| node_team_views
node_app -->|"renders"| node_player_views
node_player_views -->|"renders shots"| node_shot_chart
node_app -->|"updates and reads"| node_db_helpers
node_db_helpers -->|"reads and writes"| node_database
node_app -->|"loads team data"| node_team_csv
node_app -->|"trains model"| node_model
node_model -->|"reads features"| node_team_csv
node_app -->|"shows evaluation"| node_model_view
node_model -.->|"returns accuracy"| node_model_view

click node_app "https://github.com/nabildia/nba-game-data/blob/main/main.py"
click node_team_logs "https://github.com/nabildia/nba-game-data/blob/main/src/analyse.py"
click node_player_logs "https://github.com/nabildia/nba-game-data/blob/main/src/analyse.py"
click node_advanced_stats "https://github.com/nabildia/nba-game-data/blob/main/src/analyse.py"
click node_shot_data "https://github.com/nabildia/nba-game-data/blob/main/src/analyse.py"
click node_team_views "https://github.com/nabildia/nba-game-data/blob/main/main.py"
click node_player_views "https://github.com/nabildia/nba-game-data/blob/main/main.py"
click node_shot_chart "https://github.com/nabildia/nba-game-data/blob/main/src/analyse.py"
click node_team_csv "https://github.com/nabildia/nba-game-data/blob/main/export_data/nba_team_stats.csv"
click node_database "https://github.com/nabildia/nba-game-data/blob/main/export_data/nba_database.db"
click node_db_helpers "https://github.com/nabildia/nba-game-data/blob/main/src/database.py"
click node_model "https://github.com/nabildia/nba-game-data/blob/main/src/ml_predictions.py"
click node_model_view "https://github.com/nabildia/nba-game-data/blob/main/main.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_team_logs,node_player_logs,node_advanced_stats,node_shot_data,node_user toneBlue
class node_app,node_team_views,node_player_views,node_shot_chart,node_model_view toneAmber
class node_team_csv,node_database,node_db_helpers,node_model,node_nba_api toneMint
```

## Components

### Data acquisition

- [Team game logs](https://github.com/nabildia/nba-game-data/blob/main/src/analyse.py): `src/analyse.py`
- [Player game logs](https://github.com/nabildia/nba-game-data/blob/main/src/analyse.py): `src/analyse.py`
- [Advanced team stats](https://github.com/nabildia/nba-game-data/blob/main/src/analyse.py): `src/analyse.py`
- [Player shot data](https://github.com/nabildia/nba-game-data/blob/main/src/analyse.py): `src/analyse.py`

### Dashboard analytics

- [Streamlit dashboard](https://github.com/nabildia/nba-game-data/blob/main/main.py): `main.py`
- [Team rankings and comparisons](https://github.com/nabildia/nba-game-data/blob/main/main.py): `main.py`
- [Player stats and comparisons](https://github.com/nabildia/nba-game-data/blob/main/main.py): `main.py`
- [Shot chart rendering](https://github.com/nabildia/nba-game-data/blob/main/src/analyse.py): `src/analyse.py`
- [Model evaluation view](https://github.com/nabildia/nba-game-data/blob/main/main.py): `main.py`

### Storage and modeling

- [Team stats CSV](https://github.com/nabildia/nba-game-data/blob/main/export_data/nba_team_stats.csv): `export_data/nba_team_stats.csv`
- [SQLite database](https://github.com/nabildia/nba-game-data/blob/main/export_data/nba_database.db): `export_data/nba_database.db`
- [Database access](https://github.com/nabildia/nba-game-data/blob/main/src/database.py): `src/database.py`
- [Win-factor model](https://github.com/nabildia/nba-game-data/blob/main/src/ml_predictions.py): `src/ml_predictions.py`

### Other components

- **Dashboard user**
- **NBA Stats API**

## Connections

- Dashboard user → Streamlit dashboard: uses (evidence: `README.md`)
- Streamlit dashboard → Team game logs: loads team data (evidence: `README.md`)
- Streamlit dashboard → Player game logs: loads player data (evidence: `README.md`)
- Streamlit dashboard → Advanced team stats: loads advanced stats (evidence: `README.md`)
- Streamlit dashboard → Player shot data: requests shot data (evidence: `main.py`)
- Team game logs → NBA Stats API: fetches logs (evidence: `src/analyse.py`)
- Player game logs → NBA Stats API: fetches logs (evidence: `src/analyse.py`)
- Advanced team stats → NBA Stats API: fetches stats (evidence: `src/analyse.py`)
- Player shot data → NBA Stats API: fetches shots (evidence: `src/analyse.py`)
- Streamlit dashboard → Team rankings and comparisons: renders (evidence: `main.py`)
- Streamlit dashboard → Player stats and comparisons: renders (evidence: `main.py`)
- Player stats and comparisons → Shot chart rendering: renders shots (evidence: `main.py`)
- Streamlit dashboard → Database access: updates and reads (evidence: `README.md`)
- Database access → SQLite database: reads and writes (evidence: `src/database.py`)
- Streamlit dashboard → Team stats CSV: loads team data (evidence: `main.py`)
- Streamlit dashboard → Win-factor model: trains model (evidence: `README.md`)
- Win-factor model → Team stats CSV: reads features (evidence: `src/ml_predictions.py`)
- Streamlit dashboard → Model evaluation view: shows evaluation (evidence: `README.md`)
- Win-factor model → Model evaluation view: returns accuracy (evidence: `main.py`)
