tif1 is built with a modular architecture focused on performance, reliability, and maintainability. Each module has a clear responsibility and well-defined boundaries.
System Overview
Module Ownership
tif1.session: canonical session entrypoint (Session, get_session).
tif1.models: canonical dataframe-backed domain models (Laps, Lap, Driver, Telemetry).
tif1.io_pipeline: payload normalization helpers used by session loading paths.
tif1.lap_ops: lap-number/time coercion and lap-column helpers.
tif1.http_session: sole owner of HTTP session lifecycle and connection metrics.
tif1.async_fetch: async fetch orchestration and executor lifecycle.
tif1.cache: SQLite + in-memory caching.
tif1.events: event/session lookup via packaged JSON schedules.
tif1.schedule_schema: schema validation for schedule assets.
Data Flow
The data pipeline transforms raw JSON from the CDN into structured DataFrames:
- CDN Fetch: Parallel HTTP/2 requests to jsdelivr CDN
- JSON Parse: Fast parsing with orjson
- DataFrame Construction: Column mapping and type conversion
- Enrichment: Add weather data, calculate derived fields
- Caching: Store in SQLite + memory LRU
- Return: Pandas or Polars DataFrame
Data Flow
get_session(...) resolves event/session aliases and creates a Session.
Session methods load JSON payloads via CDN manager + shared HTTP session.
io_pipeline helpers normalize payloads into lib dataframes.
cache stores/retrieves JSON payloads and telemetry batches.
models expose dataframe-centric APIs for lap/driver/telemetry access.
Schedule System
- Static schedules are packaged as JSON files in
src/tif1/data/schedules/f1schedule/ (one file per year: schedule_2018.json, schedule_2019.json, etc.).
events.py reads these assets through importlib.resources and converts them to the internal format.
schedule_schema.validate_schedule_payload enforces structure and schema versioning.
- CDN fallback fetches missing years from jsdelivr (f1schedule repository).
Design Rules
- No compatibility shims for unsupported FastF1 namespaces.
- Shared network session ownership stays in
http_session.
- Performance benchmarks live under
tests/benchmarks and are excluded from default pytest runs.
Last modified on May 8, 2026