# jamessshhh/pitchxt architecture

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

- Interactive diagram: https://gitdiagram.com/jamessshhh/pitchxt
- Repository: https://github.com/jamessshhh/pitchxt

## Overview

pitchxt is a football-tracking analytics package and Streamlit app for estimating dangerous space, testing whether it predicts shots, and comparing hand-built scores with a graph attention network. Its main workflow loads and normalizes match tracking, computes pitch control and xT-weighted threat, then evaluates shot predictions; tuning and learned-model comparisons extend that workflow, with SkillCorner providing an external test. The graph reflects documented calls and imports; several analytical links are supported by README descriptions rather than inspected runtime wiring.

Main entry points: [`src/pitchxt/value.py`](https://github.com/jamessshhh/pitchxt/blob/main/src/pitchxt/value.py) (Controlled-space value), [`app/streamlit_app.py`](https://github.com/jamessshhh/pitchxt/blob/main/app/streamlit_app.py) (Streamlit app), [`src/pitchxt/matches.py`](https://github.com/jamessshhh/pitchxt/blob/main/src/pitchxt/matches.py) (Match assembly), [`src/pitchxt/tracking.py`](https://github.com/jamessshhh/pitchxt/blob/main/src/pitchxt/tracking.py) (Tracking transforms)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_inputs["Data inputs"]
  node_metrica[("Metrica tracking<br/>[tracking.py]")]
  node_dfl[("DFL tracking<br/>[dfl.py]")]
  node_skillcorner[("SkillCorner data<br/>[skillcorner.py]")]
  node_statsbomb[("StatsBomb actions<br/>[data.py]")]
  node_events["Match events<br/>[events.py]"]
  node_matches["Match assembly<br/>[matches.py]"]
  node_tracking["Tracking transforms<br/>[tracking.py]"]
end

subgraph group_models["Space valuation"]
  node_pitch["Pitch geometry<br/>[pitch.py]"]
  node_xt["Expected threat<br/>[xt.py]"]
  node_control["Pitch control<br/>[pitch_control.py]"]
  node_value["Controlled-space value<br/>[value.py]"]
end

subgraph group_evaluation["Prediction and evaluation"]
  node_validation["Shot validation<br/>[validate.py]"]
  node_tuning["Parameter tuning<br/>[tune.py]"]
  node_graphdata["Graph preparation<br/>[gnn_data.py]"]
  node_gnn["Graph attention model<br/>[gnn.py]"]
  node_external["External evaluation<br/>[external.py]"]
end

subgraph group_interface["User interface"]
  node_plots["Analytics plots<br/>[plots.py]"]
  node_app["Streamlit app<br/>[streamlit_app.py]"]
end

node_analyst(("Analyst"))

node_matches -->|"loads DFL"| node_dfl
node_matches -->|"loads events"| node_events
node_matches -->|"loads tracking"| node_tracking
node_tracking -->|"reads data"| node_metrica
node_statsbomb -.->|"fits threat"| node_xt
node_control -->|"uses geometry"| node_pitch
node_value -->|"gets control"| node_control
node_value -->|"weights control"| node_xt
node_validation -->|"loads matches"| node_matches
node_validation -->|"scores frames"| node_value
node_tuning -->|"tests parameters"| node_control
node_tuning -->|"scores threat"| node_value
node_graphdata -->|"builds samples"| node_matches
node_graphdata -->|"uses transforms"| node_tracking
node_graphdata -->|"loads frames"| node_skillcorner
node_gnn -.->|"learns from graphs"| node_graphdata
node_external -->|"loads matches"| node_skillcorner
node_external -->|"normalizes frames"| node_tracking
node_external -->|"scores space"| node_value
node_external -->|"uses metrics"| node_validation
node_app -->|"uses tracking"| node_tracking
node_app -->|"shows validation"| node_validation
node_app -->|"shows value"| node_value
node_app -->|"shows control"| node_control
node_analyst -.->|"explores analysis"| node_app
node_plots -.->|"plots value"| node_value

click node_metrica "https://github.com/jamessshhh/pitchxt/blob/main/src/pitchxt/tracking.py"
click node_dfl "https://github.com/jamessshhh/pitchxt/blob/main/src/pitchxt/dfl.py"
click node_skillcorner "https://github.com/jamessshhh/pitchxt/blob/main/src/pitchxt/skillcorner.py"
click node_statsbomb "https://github.com/jamessshhh/pitchxt/blob/main/src/pitchxt/data.py"
click node_events "https://github.com/jamessshhh/pitchxt/blob/main/src/pitchxt/events.py"
click node_matches "https://github.com/jamessshhh/pitchxt/blob/main/src/pitchxt/matches.py"
click node_pitch "https://github.com/jamessshhh/pitchxt/blob/main/src/pitchxt/pitch.py"
click node_xt "https://github.com/jamessshhh/pitchxt/blob/main/src/pitchxt/xt.py"
click node_control "https://github.com/jamessshhh/pitchxt/blob/main/src/pitchxt/pitch_control.py"
click node_value "https://github.com/jamessshhh/pitchxt/blob/main/src/pitchxt/value.py"
click node_tracking "https://github.com/jamessshhh/pitchxt/blob/main/src/pitchxt/tracking.py"
click node_validation "https://github.com/jamessshhh/pitchxt/blob/main/src/pitchxt/validate.py"
click node_tuning "https://github.com/jamessshhh/pitchxt/blob/main/src/pitchxt/tune.py"
click node_graphdata "https://github.com/jamessshhh/pitchxt/blob/main/src/pitchxt/gnn_data.py"
click node_gnn "https://github.com/jamessshhh/pitchxt/blob/main/src/pitchxt/gnn.py"
click node_external "https://github.com/jamessshhh/pitchxt/blob/main/src/pitchxt/external.py"
click node_plots "https://github.com/jamessshhh/pitchxt/blob/main/src/pitchxt/plots.py"
click node_app "https://github.com/jamessshhh/pitchxt/blob/main/app/streamlit_app.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_metrica,node_dfl,node_skillcorner,node_statsbomb,node_events,node_matches,node_tracking toneBlue
class node_pitch,node_xt,node_control,node_value toneAmber
class node_validation,node_tuning,node_graphdata,node_gnn,node_external toneMint
class node_plots,node_app toneRose
class node_analyst toneIndigo
```

## Components

### Data inputs

- [Metrica tracking](https://github.com/jamessshhh/pitchxt/blob/main/src/pitchxt/tracking.py): `src/pitchxt/tracking.py`
- [DFL tracking](https://github.com/jamessshhh/pitchxt/blob/main/src/pitchxt/dfl.py): `src/pitchxt/dfl.py`
- [SkillCorner data](https://github.com/jamessshhh/pitchxt/blob/main/src/pitchxt/skillcorner.py): `src/pitchxt/skillcorner.py`
- [StatsBomb actions](https://github.com/jamessshhh/pitchxt/blob/main/src/pitchxt/data.py): `src/pitchxt/data.py`
- [Match events](https://github.com/jamessshhh/pitchxt/blob/main/src/pitchxt/events.py): `src/pitchxt/events.py`
- [Match assembly](https://github.com/jamessshhh/pitchxt/blob/main/src/pitchxt/matches.py): `src/pitchxt/matches.py`
- [Tracking transforms](https://github.com/jamessshhh/pitchxt/blob/main/src/pitchxt/tracking.py): `src/pitchxt/tracking.py`

### Space valuation

- [Pitch geometry](https://github.com/jamessshhh/pitchxt/blob/main/src/pitchxt/pitch.py): `src/pitchxt/pitch.py`
- [Expected threat](https://github.com/jamessshhh/pitchxt/blob/main/src/pitchxt/xt.py): `src/pitchxt/xt.py`
- [Pitch control](https://github.com/jamessshhh/pitchxt/blob/main/src/pitchxt/pitch_control.py): `src/pitchxt/pitch_control.py`
- [Controlled-space value](https://github.com/jamessshhh/pitchxt/blob/main/src/pitchxt/value.py): `src/pitchxt/value.py`

### Prediction and evaluation

- [Shot validation](https://github.com/jamessshhh/pitchxt/blob/main/src/pitchxt/validate.py): `src/pitchxt/validate.py`
- [Parameter tuning](https://github.com/jamessshhh/pitchxt/blob/main/src/pitchxt/tune.py): `src/pitchxt/tune.py`
- [Graph preparation](https://github.com/jamessshhh/pitchxt/blob/main/src/pitchxt/gnn_data.py): `src/pitchxt/gnn_data.py`
- [Graph attention model](https://github.com/jamessshhh/pitchxt/blob/main/src/pitchxt/gnn.py): `src/pitchxt/gnn.py`
- [External evaluation](https://github.com/jamessshhh/pitchxt/blob/main/src/pitchxt/external.py): `src/pitchxt/external.py`

### User interface

- [Analytics plots](https://github.com/jamessshhh/pitchxt/blob/main/src/pitchxt/plots.py): `src/pitchxt/plots.py`
- [Streamlit app](https://github.com/jamessshhh/pitchxt/blob/main/app/streamlit_app.py): `app/streamlit_app.py`

### Other components

- **Analyst**

## Connections

- Match assembly → DFL tracking: loads DFL (evidence: `src/pitchxt/matches.py`)
- Match assembly → Match events: loads events (evidence: `src/pitchxt/matches.py`)
- Match assembly → Tracking transforms: loads tracking (evidence: `src/pitchxt/matches.py`)
- Tracking transforms → Metrica tracking: reads data (evidence: `src/pitchxt/tracking.py`)
- StatsBomb actions → Expected threat: fits threat (evidence: `README.md`)
- Pitch control → Pitch geometry: uses geometry (evidence: `src/pitchxt/pitch_control.py`)
- Controlled-space value → Pitch control: gets control (evidence: `src/pitchxt/value.py`)
- Controlled-space value → Expected threat: weights control (evidence: `src/pitchxt/value.py`)
- Shot validation → Match assembly: loads matches (evidence: `src/pitchxt/validate.py`)
- Shot validation → Controlled-space value: scores frames (evidence: `src/pitchxt/validate.py`)
- Parameter tuning → Pitch control: tests parameters (evidence: `src/pitchxt/tune.py`)
- Parameter tuning → Controlled-space value: scores threat (evidence: `src/pitchxt/tune.py`)
- Graph preparation → Match assembly: builds samples (evidence: `src/pitchxt/gnn_data.py`)
- Graph preparation → Tracking transforms: uses transforms (evidence: `src/pitchxt/gnn_data.py`)
- Graph preparation → SkillCorner data: loads frames (evidence: `src/pitchxt/gnn_data.py`)
- Graph attention model → Graph preparation: learns from graphs (evidence: `README.md`)
- External evaluation → SkillCorner data: loads matches (evidence: `src/pitchxt/external.py`)
- External evaluation → Tracking transforms: normalizes frames (evidence: `src/pitchxt/external.py`)
- External evaluation → Controlled-space value: scores space (evidence: `src/pitchxt/external.py`)
- External evaluation → Shot validation: uses metrics (evidence: `src/pitchxt/external.py`)
- Streamlit app → Tracking transforms: uses tracking (evidence: `app/streamlit_app.py`)
- Streamlit app → Shot validation: shows validation (evidence: `app/streamlit_app.py`)
- Streamlit app → Controlled-space value: shows value (evidence: `app/streamlit_app.py`)
- Streamlit app → Pitch control: shows control (evidence: `app/streamlit_app.py`)
- Analyst → Streamlit app: explores analysis (evidence: `README.md`)
- Analytics plots → Controlled-space value: plots value (evidence: `README.md`)
