# theoehrly/fast-f1 architecture

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

- Interactive diagram: https://gitdiagram.com/theoehrly/fast-f1
- Repository: https://github.com/theoehrly/fast-f1

## Overview

FastF1 is a Python library for retrieving and analyzing Formula 1 schedules, historical results, session timing and telemetry, with Pandas-based results and plotting support. A typical workflow selects an event and session, loads session data from F1 timing sources, then analyzes or visualizes it. Separate branches provide the Ergast-compatible historical API and live-timing capture. The source index supports the broad module relationships shown; unsampled implementations are represented only where their role is documented or their path is present in the tree.

Main entry points: [`fastf1/core.py`](https://github.com/theoehrly/fast-f1/blob/main/fastf1/core.py) (Session data model), [`fastf1/events.py`](https://github.com/theoehrly/fast-f1/blob/main/fastf1/events.py) (Events and sessions), [`fastf1/ergast/interface.py`](https://github.com/theoehrly/fast-f1/blob/main/fastf1/ergast/interface.py) (Ergast API client), [`fastf1/_api.py`](https://github.com/theoehrly/fast-f1/blob/main/fastf1/_api.py) (F1 timing API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["User entry"]
  node_events["Events and sessions<br/>[events.py]"]
  node_core["Session data model<br/>[core.py]"]
end

subgraph group_data["Data access"]
  node_f1api["F1 timing API<br/>[_api.py]"]
  node_ergast["Ergast API client<br/>[interface.py]"]
  node_ergastshape["Ergast response types<br/>[structure.py]"]
  node_mvapi["MV API data<br/>[data.py]"]
end

subgraph group_live["Live timing"]
  node_livestream["SignalR client<br/>[client.py]"]
  node_livedata["Live timing data<br/>[data.py]"]
  node_auth["F1 account authentication<br/>[__init__.py]"]
  node_token["Token management<br/>[tokens.py]"]
end

subgraph group_analysis["Analysis and presentation"]
  node_frames["Extended Pandas frames<br/>[pandas_base.py]"]
  node_extensions["Pandas extensions"]
  node_plotting["Matplotlib plotting<br/>[_interface.py]"]
end

subgraph group_shared["Shared runtime"]
  node_http["Cached HTTP requests<br/>[req.py]"]
  node_fuzzy["Fuzzy matching<br/>[fuzzy.py]"]
  node_parsing["Parsing helpers<br/>[parsing_helpers.py]"]
  node_logging["Logging and errors<br/>[logger.py]"]
end

node_user(("Python user"))

node_user -->|"selects event"| node_events
node_user -->|"loads session"| node_core
node_user -->|"queries history"| node_ergast
node_user -->|"captures live feed"| node_livestream
node_user -->|"visualizes data"| node_plotting
node_events -->|"creates sessions"| node_core
node_events -->|"fetches event data"| node_f1api
node_events -->|"queries schedules"| node_ergast
node_core -->|"loads timing data"| node_f1api
node_core -->|"loads historical data"| node_ergast
node_core -->|"uses live data"| node_livedata
node_core -->|"uses MV data"| node_mvapi
node_f1api -->|"requests data"| node_http
node_ergast -->|"requests data"| node_http
node_ergast -->|"builds responses"| node_ergastshape
node_mvapi -->|"requests data"| node_http
node_livestream -->|"gets credentials"| node_auth
node_auth -->|"gets valid token"| node_token
node_livestream -.->|"records stream"| node_livedata
node_core -->|"returns dataframes"| node_frames
node_events -->|"builds event frames"| node_frames
node_ergast -->|"returns dataframes"| node_frames
node_plotting -->|"plots session data"| node_core
node_plotting -->|"matches selections"| node_fuzzy
node_f1api -->|"parses responses"| node_parsing
node_events -->|"matches names"| node_fuzzy
node_frames -.->|"supports extensions"| node_extensions

click node_events "https://github.com/theoehrly/fast-f1/blob/main/fastf1/events.py"
click node_core "https://github.com/theoehrly/fast-f1/blob/main/fastf1/core.py"
click node_f1api "https://github.com/theoehrly/fast-f1/blob/main/fastf1/_api.py"
click node_ergast "https://github.com/theoehrly/fast-f1/blob/main/fastf1/ergast/interface.py"
click node_ergastshape "https://github.com/theoehrly/fast-f1/blob/main/fastf1/ergast/structure.py"
click node_mvapi "https://github.com/theoehrly/fast-f1/blob/main/fastf1/mvapi/data.py"
click node_http "https://github.com/theoehrly/fast-f1/blob/main/fastf1/req.py"
click node_livestream "https://github.com/theoehrly/fast-f1/blob/main/fastf1/livetiming/client.py"
click node_livedata "https://github.com/theoehrly/fast-f1/blob/main/fastf1/livetiming/data.py"
click node_auth "https://github.com/theoehrly/fast-f1/blob/main/fastf1/internals/f1account/__init__.py"
click node_token "https://github.com/theoehrly/fast-f1/blob/main/fastf1/internals/f1account/tokens.py"
click node_frames "https://github.com/theoehrly/fast-f1/blob/main/fastf1/internals/pandas_base.py"
click node_extensions "https://github.com/theoehrly/fast-f1/blob/main/fastf1/internals/pandas_extensions.py"
click node_plotting "https://github.com/theoehrly/fast-f1/blob/main/fastf1/plotting/_interface.py"
click node_fuzzy "https://github.com/theoehrly/fast-f1/blob/main/fastf1/internals/fuzzy.py"
click node_parsing "https://github.com/theoehrly/fast-f1/blob/main/fastf1/internals/parsing_helpers.py"
click node_logging "https://github.com/theoehrly/fast-f1/blob/main/fastf1/logger.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_events,node_core,node_user toneBlue
class node_f1api,node_ergast,node_ergastshape,node_mvapi toneAmber
class node_livestream,node_livedata,node_auth,node_token toneMint
class node_frames,node_extensions,node_plotting toneRose
class node_http,node_fuzzy,node_parsing,node_logging toneIndigo
```

## Components

### User entry

- [Events and sessions](https://github.com/theoehrly/fast-f1/blob/main/fastf1/events.py): `fastf1/events.py`
- [Session data model](https://github.com/theoehrly/fast-f1/blob/main/fastf1/core.py): `fastf1/core.py`

### Data access

- [F1 timing API](https://github.com/theoehrly/fast-f1/blob/main/fastf1/_api.py): `fastf1/_api.py`
- [Ergast API client](https://github.com/theoehrly/fast-f1/blob/main/fastf1/ergast/interface.py): `fastf1/ergast/interface.py`
- [Ergast response types](https://github.com/theoehrly/fast-f1/blob/main/fastf1/ergast/structure.py): `fastf1/ergast/structure.py`
- [MV API data](https://github.com/theoehrly/fast-f1/blob/main/fastf1/mvapi/data.py): `fastf1/mvapi/data.py`

### Live timing

- [SignalR client](https://github.com/theoehrly/fast-f1/blob/main/fastf1/livetiming/client.py): `fastf1/livetiming/client.py`
- [Live timing data](https://github.com/theoehrly/fast-f1/blob/main/fastf1/livetiming/data.py): `fastf1/livetiming/data.py`
- [F1 account authentication](https://github.com/theoehrly/fast-f1/blob/main/fastf1/internals/f1account/__init__.py): `fastf1/internals/f1account/__init__.py`
- [Token management](https://github.com/theoehrly/fast-f1/blob/main/fastf1/internals/f1account/tokens.py): `fastf1/internals/f1account/tokens.py`

### Analysis and presentation

- [Extended Pandas frames](https://github.com/theoehrly/fast-f1/blob/main/fastf1/internals/pandas_base.py): `fastf1/internals/pandas_base.py`
- [Pandas extensions](https://github.com/theoehrly/fast-f1/blob/main/fastf1/internals/pandas_extensions.py): `fastf1/internals/pandas_extensions.py`
- [Matplotlib plotting](https://github.com/theoehrly/fast-f1/blob/main/fastf1/plotting/_interface.py): `fastf1/plotting/_interface.py`

### Shared runtime

- [Cached HTTP requests](https://github.com/theoehrly/fast-f1/blob/main/fastf1/req.py): `fastf1/req.py`
- [Fuzzy matching](https://github.com/theoehrly/fast-f1/blob/main/fastf1/internals/fuzzy.py): `fastf1/internals/fuzzy.py`
- [Parsing helpers](https://github.com/theoehrly/fast-f1/blob/main/fastf1/internals/parsing_helpers.py): `fastf1/internals/parsing_helpers.py`
- [Logging and errors](https://github.com/theoehrly/fast-f1/blob/main/fastf1/logger.py): `fastf1/logger.py`

### Other components

- **Python user**

## Connections

- Python user → Events and sessions: selects event
- Python user → Session data model: loads session
- Python user → Ergast API client: queries history
- Python user → SignalR client: captures live feed
- Python user → Matplotlib plotting: visualizes data
- Events and sessions → Session data model: creates sessions (evidence: `fastf1/events.py`)
- Events and sessions → F1 timing API: fetches event data (evidence: `fastf1/events.py`)
- Events and sessions → Ergast API client: queries schedules (evidence: `fastf1/events.py`)
- Session data model → F1 timing API: loads timing data (evidence: `fastf1/core.py`)
- Session data model → Ergast API client: loads historical data (evidence: `fastf1/core.py`)
- Session data model → Live timing data: uses live data (evidence: `fastf1/core.py`)
- Session data model → MV API data: uses MV data (evidence: `fastf1/core.py`)
- F1 timing API → Cached HTTP requests: requests data (evidence: `fastf1/_api.py`)
- Ergast API client → Cached HTTP requests: requests data (evidence: `fastf1/ergast/interface.py`)
- Ergast API client → Ergast response types: builds responses (evidence: `fastf1/ergast/interface.py`)
- MV API data → Cached HTTP requests: requests data
- SignalR client → F1 account authentication: gets credentials (evidence: `fastf1/livetiming/client.py`)
- F1 account authentication → Token management: gets valid token (evidence: `fastf1/internals/f1account/__init__.py`)
- SignalR client → Live timing data: records stream
- Session data model → Extended Pandas frames: returns dataframes (evidence: `fastf1/core.py`)
- Events and sessions → Extended Pandas frames: builds event frames (evidence: `fastf1/events.py`)
- Ergast API client → Extended Pandas frames: returns dataframes (evidence: `fastf1/ergast/interface.py`)
- Matplotlib plotting → Session data model: plots session data (evidence: `fastf1/plotting/_interface.py`)
- Matplotlib plotting → Fuzzy matching: matches selections (evidence: `fastf1/plotting/_interface.py`)
- F1 timing API → Parsing helpers: parses responses (evidence: `fastf1/_api.py`)
- Events and sessions → Fuzzy matching: matches names (evidence: `fastf1/events.py`)
- Extended Pandas frames → Pandas extensions: supports extensions
