How eisoptrophobicc/f1-app works
1. Repository shape
This is a two-part system: a Python CLI/data-processing backend under src/ and a separate React + Vite + PIXI.js replay viewer under frontend/. Most screens render to the terminal; only the replay feature crosses into the browser.
2. Top-level control flow
src/main.py is the entrypoint and acts as a routing layer, not a domain layer. It selects one screen via CLI flags such as --screen, --season, --round, and --session, then delegates to the corresponding module in src/screens/.
3. Shared season/session semantics
The common season logic lives outside the screens in src/utils/season.py and src/utils/session_context.py. This is important architecturally: screens do not decide season defaults themselves. The app distinguishes standings season semantics from calendar season semantics, and the shared utilities enforce those rules consistently.
4. Season-based terminal screens
src/screens/driver_standings.py, constructor_standings.py, and race_calendar.py are independent terminal screens. They consume season-resolved data and present different domain views:
- driver standings: driver/team/points ranking
- constructor standings: team ranking
- race calendar: season event list, including testing and race weekends
These screens are read-only projections over FastF1/JolpicaF1 data.
5. Race weekend session overview
src/screens/session_overview.py is the bridge between season-level event selection and session-level detail. It loads the sessions for a specific round or testing event and displays session metadata such as UTC date, status, and top-three fastest laps. This is the screen that moves from calendar semantics into event/session semantics.
6. Telemetry replay backend
src/screens/session_replay.py and src/engines/replay_engine.py form the replay pipeline. The screen is the orchestration layer; the engine performs the heavy work: loading telemetry, deriving replay state, and exporting a compact binary artifact for visualization. The README indicates a 6-state constant-acceleration Kalman model is used for replay reconstruction.
7. Replay data boundary
The replay path is the main cross-process boundary in the repo. Python generates the replay dataset, then the browser viewer consumes it. This is different from the other screens, which stay entirely in the CLI/terminal. The binary export format exists specifically to make replay loading efficient and lightweight for the frontend.
8. Frontend visualization boundary
frontend/src/App.jsx and frontend/src/pixi/ReplayScene.jsx implement the browser-side replay experience. React provides the UI shell, while PIXI.js handles the animated track visualization. This layer is intentionally separate from the FastF1 data fetching and numerical processing, so rendering does not depend on Python runtime internals.
9. Data sources and domain enrichment
The app pulls race/telemetry data from JolpicaF1 via FastF1 and uses FastF1’s local cache. It also includes data/nationality_ioc.json, which maps nationality values to IOC-style country codes for display. These are supporting data sources rather than standalone subsystems, but they materially affect presentation and identity mapping across screens.
10. Operational characteristics
The backend is optimized for on-demand analytics: heavy session loading happens only for the screens that need it, session data is cached in memory during runtime, and derived analytics may use parallelism when worthwhile. There is no long-running application server; the main execution model is CLI-driven, with the frontend started separately via Vite for replay playback.
11. What to show in an architecture diagram
A good diagram would show:
- CLI entrypoint as the router
- shared season/session utilities feeding all screens
- three terminal data screens sharing the same data source path
- session overview as the event/session bridge
- replay screen handing off to the replay engine
- replay engine exporting binary telemetry to the React/PIXI viewer
- FastF1/JolpicaF1 and nationality mapping as external/supporting inputs
Main entry points: main.py CLI router · season.py Season rules · session_overview.py Session overview · replay_engine.py Replay engine
Components 15
Python backend
CLI screens, shared season/session logic, and replay generation
- CLI router · Parses screen and season/session flags, then dispatches to a screen
src/main.py - Season rules · Shared season semantics used across screens
src/utils/season.py - Session context · Resolves and carries session-level selection state
src/utils/session_context.py - Driver standings · Read-only driver/team points ranking view
src/screens/driver_standings.py - Constructor standings · Read-only team ranking view
src/screens/constructor_standings.py - Race calendar · Season event list with testing and race weekends
src/screens/race_calendar.py - Session overview · Bridges event selection to session metadata and results
src/screens/session_overview.py - Replay screen · Orchestrates replay preparation for a selected session
src/screens/session_replay.py - Replay engine · Loads telemetry, derives replay state, and exports compact binary replay data
src/engines/replay_engine.py
Replay frontend
React and PIXI-based browser playback
- Viewer shell · Browser UI shell that hosts the replay experience
frontend/src/App.jsx - Replay scene · PIXI.js animation and track visualization layer
frontend/src/pixi/ReplayScene.jsx - Frontend bootstrap · Vite/React application entry point
frontend/src/main.jsx
Support data
Static mappings and external data sources
- FastF1 / JolpicaF1 · Telemetry and session data source with local caching
- Nationality map · IOC-style nationality code mapping for display
data/nationality_ioc.json - Replay binary · Compact dataset consumed by the browser viewer
Connections 24
- CLI router → Season rules: resolve season · Normalizes season semantics before screen dispatch
- CLI router → Session context: resolve session · Builds session selection context for session-aware screens
- CLI router → Driver standings: route · Dispatches to the driver standings screen
- CLI router → Constructor standings: route · Dispatches to the constructor standings screen
- CLI router → Race calendar: route · Dispatches to the race calendar screen
- CLI router → Session overview: route · Dispatches to the session overview screen
- CLI router → Replay screen: route · Dispatches to the replay screen
- Driver standings → Season rules: season data · Uses shared season resolution for standings views
- Constructor standings → Season rules: season data · Uses shared season resolution for standings views
- Race calendar → Season rules: season data · Uses shared season resolution for calendar views
- Session overview → Season rules: season data · Uses calendar-season semantics when selecting events
- Session overview → Session context: session data · Consumes round or testing-event context
- Driver standings → FastF1 / JolpicaF1: load data · Fetches standings data from the FastF1/JolpicaF1 source
- Constructor standings → FastF1 / JolpicaF1: load data · Fetches standings data from the FastF1/JolpicaF1 source
- Race calendar → FastF1 / JolpicaF1: load data · Fetches season calendar and event metadata
- Session overview → FastF1 / JolpicaF1: load data · Loads session metadata and lap results
- Replay screen → Replay engine: orchestrate · Delegates heavy replay reconstruction work
- Replay engine → FastF1 / JolpicaF1: load telemetry · Reads session telemetry and timing data
- Replay engine → Nationality map: enrich display · Maps nationality values for presentation
- Replay engine → Replay binary: export · Writes compact binary replay artifact for the browser
- Frontend bootstrap → Viewer shell: mount · Bootstraps the React application shell
- Viewer shell → Replay scene: render · Hands replay playback off to the PIXI scene
- Replay scene → Replay binary: consume · Loads the exported replay dataset for animation
- Replay screen → Viewer shell: handoff · Cross-process boundary between Python replay generation and browser playback