How amrrish21/f1_dashboard works
Purpose and Entry Point
This is a local Streamlit dashboard for comparing Formula 1 drivers’ session telemetry and lap performance. Start it with streamlit run app.py; the UI is hosted by app.py, while data_provider.py isolates FastF1 access and data preparation.
Paths: app.py, data_provider.py, requirements.txt
UI Orchestration
app.py owns user interaction and rendering: sidebar controls select season, circuit, and session type; a load action retrieves session data; driver selectors enable a two-driver comparison. It renders KPI summaries and four analysis views: speed trace, lap pace, track map, and sector analysis.
Path: app.py
Session Acquisition Boundary
data_provider.py is the boundary between the application and FastF1. It loads a selected event/session, handles fetch failures by returning None, and keeps FastF1 internals out of the Streamlit layer. FastF1 sources historical and live-timing-derived F1 data, including Ergast-backed information.
Path: data_provider.py
Caching Layers
Raw FastF1 responses persist in a writable .fastf1_cache disk directory, avoiding repeated network retrieval after process restarts. Streamlit resource caching retains parsed session objects in memory; data caching retains derived DataFrames for an hour. This is important because initial session loading may take 15–60 seconds.
Paths: data_provider.py, app.py
Data Extraction and Transformation
The provider exposes session results for valid driver selection, fastest-lap lookup for each selected driver, telemetry extraction for distance-indexed channels and circuit coordinates, and all-driver-laps extraction for pace analysis. Derived data is exchanged primarily as pandas DataFrames, with NumPy supporting numerical processing and time/delta calculations.
Path: data_provider.py
Visualization Pipeline
The UI consumes provider outputs only after checking for missing data. Plotly renders:
• synchronized speed, throttle, and brake traces over lap distance;
• lap-time violin/scatter distributions and chronological pace;
• XY track geometry colored by speed, gear, or throttle;
• sector-time grouped bars and delta-oriented tabular comparison.
Speed traces apply rolling smoothing; track-map axes preserve geometric aspect ratio.
Path: app.py
Runtime and External Dependencies
The runtime is Python 3.10+ with Streamlit 1.35+, FastF1 3.3+, Plotly 5.22+, pandas, and NumPy. It is intended for local browser access at Streamlit’s default port 8501. External dependency availability and a writable local cache are operational requirements; UI warnings should contain provider/network failures rather than crash rendering.
Paths: requirements.txt, data_provider.py, app.py
Main entry points: app.py Dashboard orchestration · data_provider.py Provider API · requirements.txt Python dependencies
Components 17
Streamlit UI
- Local browser · Accesses the dashboard on Streamlit's local server.
- Dashboard orchestration · Coordinates controls, loading, validation, and rendering.
app.py - Session and driver controls · Selects season, circuit, session type, and two drivers.
app.py - KPI summaries
app.py - Speed trace analysis · Plots smoothed speed, throttle, and brake by lap distance.
app.py - Lap pace analysis · Shows lap-time distributions and chronological pace.
app.py - Track map analysis · Colors circuit geometry by telemetry channels.
app.py - Sector analysis · Compares sector times and deltas.
app.py
Data Provider
- Provider API · Contains FastF1 failures and returns missing data safely.
data_provider.py - Session loader · Loads the selected event session.
data_provider.py - Telemetry and lap DataFrames · Provides results, fastest laps, telemetry, and all-driver laps.
data_provider.py
Caching
- Parsed session cache · Retains session objects in memory.
app.py - Derived data cache · Caches derived DataFrames for one hour.
data_provider.py - FastF1 disk cache · Persists raw FastF1 responses across process restarts.
External Data
- FastF1
- F1 timing and Ergast data
Other components
- Python dependencies · Defines Streamlit, FastF1, Plotly, pandas, and NumPy requirements.
requirements.txt
Connections 19
- Local browser → Dashboard orchestration: uses
- Session and driver controls → Dashboard orchestration: drives load and comparison
- Dashboard orchestration → Session and driver controls: renders
- Dashboard orchestration → Provider API: requests session data
- Provider API → Session loader: loads selected session
- Session loader → FastF1: calls
- FastF1 → F1 timing and Ergast data: retrieves timing data
- FastF1 → FastF1 disk cache: reads and writes raw responses
- Session loader → Parsed session cache: stores parsed sessions
- Provider API → Derived data cache: caches derived outputs
- Provider API → Telemetry and lap DataFrames: extracts and transforms
- Telemetry and lap DataFrames → Dashboard orchestration: returns validated data
- Dashboard orchestration → KPI summaries: renders
- Dashboard orchestration → Speed trace analysis: renders
- Dashboard orchestration → Lap pace analysis: renders
- Dashboard orchestration → Track map analysis: renders
- Dashboard orchestration → Sector analysis: renders
- Python dependencies → Dashboard orchestration: provides runtime libraries
- Python dependencies → Provider API: provides data libraries