F1-Telemetry-Analysis A "Pit Wall" style F1 telemetry dashboard. A FastAPI backend pulls historical and live session data via FastF1 and serves it to a React frontend, which renders a dynamic track map, synchronized telemetry traces, and sector/lap analysis.
Features
- Dynamic track map — 2D circuit layout with corner labels, generated per-session from real telemetry and cached to disk so it's only computed once per circuit.
- Live driver positioning — driver X/Y coordinates plotted on the track map, synced to a shared session clock.
- Telemetry traces — Speed, RPM, Gear, Throttle, Brake, and DRS, synchronized across drivers.
- Historical replay — load and step through any race, qualifying, or practice session FastF1 has data for.
- Driver comparison / time delta — overlay two drivers' fastest laps and see the time delta build up over distance.
- Qualifying traffic detection — flags moments where a driver on a flying lap gets caught behind a car running a prep/out lap, based on proximity and lap classification.
- Track status overlay — yellow flag, Safety Car, VSC, and red flag periods mapped onto the session timeline.
- Practice/qualifying stint breakdown — tyre compound, stint length, and lap classification (push/prep/in/out) per driver.
Comprehensive F1 telemetry dashboard and analysis tools. This repository contains:
- A FastAPI backend that uses
fastf1,pandas, andnumpyto fetch and serve telemetry, track and session data. - A Next.js frontend (in the
frontend/folder) which renders the track map, timing tower and lap analysis UI. - Utilities to pregenerate track layouts and run a live poller for ongoing sessions.
This README documents the tech stack, installation steps, and how to run the demo locally.
Tech Stack:
- Python 3.10+: backend and utilities
- fastf1: fetches F1 timing and telemetry data
- FastAPI: backend HTTP API
- uvicorn: ASGI server for FastAPI
- pandas / numpy: data manipulation
- Next.js (React): frontend UI (
frontend/)
Files of interest:
api.py: main backend API serving/api/schedule,/api/track,/api/session,/api/time-delta.live_race.py: alternative FastAPI service that polls live sessions and exposes live endpoints.pregenerate.py: utility to pregenerate and cache track layout CSVs intodata/.frontend/: Next.js app. API base isfrontend/src/lib/api.ts.
- Python 3.10 or newer
- Node.js 18+ and npm/yarn/pnpm for the frontend
From repository root:
python -m venv .venv
# Windows (PowerShell)
.\.venv\Scripts\Activate.ps1
# macOS / Linux
# source .venv/bin/activate
pip install -r requirements.txtNotes:
- The
requirements.txtincludesfastf1,fastapi,uvicorn[standard],pandas,numpy,requests, andwebsockets. - The app writes cache to
./cache(generated byfastf1) and./datafor pregenerated CSVs.
Start the main API (used by the frontend):
uvicorn api:app --reload --port 8000Start the live poller API (optional, runs its own FastAPI app and background poller):
uvicorn live_race:app --reload --port 8001Pregenerate track data (optional but recommended for faster demo runs):
python pregenerate.pycd frontend
npm install
npm run devThe frontend runs on http://localhost:3000 by default and the client is configured to talk to http://localhost:8000 (see frontend/src/lib/api.ts if you need to change the API base URL).
- Ensure
uvicorn api:appis running on port8000. - (Optional) Run
python pregenerate.pyto create cacheddata/*_track_layout.csvand*_corners.csvfiles. - Run
cd frontend && npm run devand openhttp://localhost:3000.
- If the frontend cannot fetch schedule/track/session data, confirm the backend is reachable at
http://localhost:8000and that CORS allowshttp://localhost:3000(configured inapi.py). - If
fastf1fails to fetch session data, check network access to the underlying timing endpoints and ensurefastf1cache folders (./cache,./cache_live) are writable.
test_integration.pycontains simple requests-based checks for the API.pregenerate.pyprefetches tracks todata/for offline/demo use.