# basketballrelativity/etm architecture

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

- Interactive diagram: https://gitdiagram.com/basketballrelativity/etm
- Repository: https://github.com/basketballrelativity/etm

## Overview

ETM develops a late-game basketball decision metric. Its documented workflow builds a win-probability model, simulates qualifying possessions to compare actual and optimal decisions, aggregates possession results by game, and produces team season summaries. The graph also includes the documented game data and shooting adjustment inputs. No source excerpts were provided, so relationships are limited to those stated in the README; the season-summary output is not represented as a separate file because its destination is unspecified.

Main entry points: [`simulate_season.R`](https://github.com/basketballrelativity/etm/blob/master/simulate_season.R) (Possession Simulation), [`ETM.R`](https://github.com/basketballrelativity/etm/blob/master/ETM.R) (Season Summary), [`newPBP_1.csv`](https://github.com/basketballrelativity/etm/blob/master/newPBP_1.csv) (Possession ETM Data), [`NBA_WPM.R`](https://github.com/basketballrelativity/etm/blob/master/NBA_WPM.R) (Win Probability Model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_model["Win Probability"]
  node_wpm["Win Probability Model<br/>[NBA_WPM.R]"]
  node_modeldata["Model Data<br/>[nbawp.RData]"]
end

subgraph group_metric["ETM Development"]
  node_simulation["Possession Simulation<br/>[simulate_season.R]"]
end

subgraph group_analysis["ETM Analysis"]
  node_possessiondata["Possession ETM Data<br/>[newPBP_1.csv]"]
  node_gameaggregation["Game Aggregation<br/>[newGame.R]"]
  node_gamedata["Game ETM Data<br/>[newGBG_1.csv]"]
  node_seasonanalysis["Season Summary<br/>[ETM.R]"]
end

subgraph group_inputs["Game Data"]
  node_situations["Season Situations<br/>[situation0506.mat]"]
  node_pbpinput["Season Play-by-Play<br/>[PlayByPlay3.csv]"]
  node_teamstats["Team Statistics"]
  node_shooting["Shooting Coefficients<br/>[shootingcoeff.mat]"]
end

node_analyst(("Analyst"))

node_wpm -->|"reads situations"| node_situations
node_wpm -->|"builds model data"| node_modeldata
node_simulation -->|"uses model"| node_modeldata
node_simulation -->|"reads possessions"| node_pbpinput
node_simulation -->|"uses statistics"| node_teamstats
node_simulation -->|"applies weights"| node_shooting
node_simulation -->|"outputs ETM"| node_possessiondata
node_gameaggregation -->|"reads possessions"| node_possessiondata
node_gameaggregation -->|"outputs aggregates"| node_gamedata
node_seasonanalysis -->|"reads possessions"| node_possessiondata
node_seasonanalysis -->|"reads game stats"| node_gamedata
node_analyst -->|"runs season"| node_simulation
node_analyst -->|"analyzes season"| node_seasonanalysis

click node_wpm "https://github.com/basketballrelativity/etm/blob/master/NBA_WPM.R"
click node_situations "https://github.com/basketballrelativity/etm/blob/master/situation0506.mat"
click node_modeldata "https://github.com/basketballrelativity/etm/blob/master/nbawp.RData"
click node_simulation "https://github.com/basketballrelativity/etm/blob/master/simulate_season.R"
click node_pbpinput "https://github.com/basketballrelativity/etm/blob/master/PlayByPlay3.csv"
click node_teamstats "https://github.com/basketballrelativity/etm/blob/master/leagues_NBA_2016_team.csv"
click node_shooting "https://github.com/basketballrelativity/etm/blob/master/shootingcoeff.mat"
click node_possessiondata "https://github.com/basketballrelativity/etm/blob/master/newPBP_1.csv"
click node_gameaggregation "https://github.com/basketballrelativity/etm/blob/master/newGame.R"
click node_gamedata "https://github.com/basketballrelativity/etm/blob/master/newGBG_1.csv"
click node_seasonanalysis "https://github.com/basketballrelativity/etm/blob/master/ETM.R"

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_wpm,node_modeldata toneBlue
class node_simulation toneAmber
class node_possessiondata,node_gameaggregation,node_gamedata,node_seasonanalysis toneMint
class node_situations,node_pbpinput,node_teamstats,node_shooting toneRose
class node_analyst toneIndigo
```

## Components

### Win Probability

- [Win Probability Model](https://github.com/basketballrelativity/etm/blob/master/NBA_WPM.R): `NBA_WPM.R`
- [Model Data](https://github.com/basketballrelativity/etm/blob/master/nbawp.RData): `nbawp.RData`

### ETM Development

- [Possession Simulation](https://github.com/basketballrelativity/etm/blob/master/simulate_season.R): `simulate_season.R`

### ETM Analysis

- [Possession ETM Data](https://github.com/basketballrelativity/etm/blob/master/newPBP_1.csv): `newPBP_1.csv`
- [Game Aggregation](https://github.com/basketballrelativity/etm/blob/master/newGame.R): `newGame.R`
- [Game ETM Data](https://github.com/basketballrelativity/etm/blob/master/newGBG_1.csv): `newGBG_1.csv`
- [Season Summary](https://github.com/basketballrelativity/etm/blob/master/ETM.R): `ETM.R`

### Game Data

- [Season Situations](https://github.com/basketballrelativity/etm/blob/master/situation0506.mat): `situation0506.mat`
- [Season Play-by-Play](https://github.com/basketballrelativity/etm/blob/master/PlayByPlay3.csv): `PlayByPlay3.csv`
- [Team Statistics](https://github.com/basketballrelativity/etm/blob/master/leagues_NBA_2016_team.csv): `leagues_NBA_2016_team.csv`
- [Shooting Coefficients](https://github.com/basketballrelativity/etm/blob/master/shootingcoeff.mat): `shootingcoeff.mat`

### Other components

- **Analyst**

## Connections

- Win Probability Model → Season Situations: reads situations (evidence: `README.md`)
- Win Probability Model → Model Data: builds model data (evidence: `README.md`)
- Possession Simulation → Model Data: uses model (evidence: `README.md`)
- Possession Simulation → Season Play-by-Play: reads possessions (evidence: `README.md`)
- Possession Simulation → Team Statistics: uses statistics (evidence: `README.md`)
- Possession Simulation → Shooting Coefficients: applies weights (evidence: `README.md`)
- Possession Simulation → Possession ETM Data: outputs ETM (evidence: `README.md`)
- Game Aggregation → Possession ETM Data: reads possessions (evidence: `README.md`)
- Game Aggregation → Game ETM Data: outputs aggregates (evidence: `README.md`)
- Season Summary → Possession ETM Data: reads possessions (evidence: `README.md`)
- Season Summary → Game ETM Data: reads game stats (evidence: `README.md`)
- Analyst → Possession Simulation: runs season (evidence: `README.md`)
- Analyst → Season Summary: analyzes season (evidence: `README.md`)
