Skip to content
AIJS2Public

About

🏎️ ANALYZIZ β€” Full-Stack F1 2026 Telemetry, SignalR Live Timing, Team Radio & Championship Analytics Platform (FastAPI + React/TypeScript)

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

215 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

ANALYZIZ: Formula 1 Telemetry, Live Timing & Championship Analytics

CI Python FastAPI React TypeScript Vite Tailwind CSS

ANALYZIZ (adnaizf1) is a full-stack Formula 1 telemetry, live timing, and championship analytics web application built for the FIA Formula 1 World Championship.

It combines a FastAPI backend (FastF1, OpenF1, native SignalR live-timing stream, Redis + disk SWR cache) with a React 19 + TypeScript + Tailwind CSS v4 frontend designed around a broadcast timing-tower interface.


Table of Contents


Core Capabilities

1. Pit-Wall Live Timing (/live & /overlay/live)

  • SignalR WebSocket Stream (/ws/livetiming): Consumes Formula 1 timing feeds directly with automatic reconnection, gzip payload decoding, per-IP connection caps, and background JSON serialization.
  • Canonical Vector Circuit Maps: 24 vectorized circuit layouts rendered via SVG path geometry (getPointAtLength()) with interactive corner badges, sector splits, and DRS / Active Aero zones.
  • Previous Session & Simulator Modes: Switches between active live timing, the last completed session classification (/api/livetiming/previous), an interactive pit-wall physics demo (?sim=1), and a transparent 1920x1080 OBS stream overlay (/overlay/live).
  • Team Radio Player: Streams .mp3 pit-wall transmissions with keyboard-seekable progress sliders, variable playback speed, driver filtering, and automatic failover between SignalR captures and OpenF1 archives.

2. Multi-Driver Lap Telemetry (/race/:year/:round)

  • Up to 5-Driver Overlaid Traces: Compares Speed, Throttle, Brake, and Time Delta channels aligned over circuit distance (0 to full lap length).
  • Synchronized Distance Crosshair & Track Domination Map: Scrubbing any chart updates all sibling traces and highlights micro-sector ownership around the circuit.
  • Two-Source Session Details: Reads official FastF1 session archives first and fills missing lap-derived blocks (stints, speed traps, sector matrix, weather, lap/gap charts) from OpenF1 when FastF1's archive has not published lap timing yet.

3. Championship Standings, Profiles & What-If Tools

  • WDC & WCC Standings (/stats, /drivers, /teams): Sortable championship tables with mathematical title-clinch / elimination badges and a cumulative points progression worm chart.
  • Driver & Constructor Profiles (/driver/:id, /team/:id) & H2H Duel (/compare): Teammate qualifying and race head-to-head bars, normalized radar attributes, round-by-round logs, and Sprint/GP DNF & DNS breakdowns.
  • Title Simulator (/simulator), Ghost Race (/ghost), & Watch-Party Bingo (/bingo): FIA 2025/2026 points simulator (25-point GP win, 8-point Sprint win, no fastest-lap bonus point), dual-car SVG lap replay, and deterministic race-day bingo cards.
  • Command Palette (Ctrl+K / Cmd+K): Keyboard-navigable search across pages, drivers, constructors, and season rounds with diacritic normalization (perez matches Sergio PΓ©rez).

4. Backend Reliability & Security Hardening

  • Single-Flight SWR Cache (config/cache.py): Coalesces concurrent cold misses per cache key, serves stale-while-revalidate responses during background refreshes, sanitizes NaN/Infinity values before atomic temp-file renames, and refuses to cache upstream error payloads.
  • Proxy-Safe Rate Limiting (config/limiter.py): Trusts X-Forwarded-For / X-Real-IP only when the peer IP belongs to TRUSTED_PROXIES, with automatic in-memory fallback if Redis is unavailable.
  • Constant-Time Admin Auth (utils/auth.py): Protects cache invalidation (/api/clear_cache/{year}) and forced upstream refreshes (?refresh=true) with UTF-8 byte secrets.compare_digest checks on X-API-Key.
  • Strict Security Headers: Enforces script-src 'self', object-src 'none', frame-ancestors 'none', X-Content-Type-Options: nosniff, Referrer-Policy, and production Strict-Transport-Security across both FastAPI and Nginx, including 4xx/500 error responses.

System Architecture

                       [ F1 SignalR Live Stream / FastF1 / OpenF1 ]
                                            |
                                            v
  +----------------------+        +-----------------------+        +----------------------+
  | React 19 + Vite 7    | <----> | FastAPI (Python 3.11+)| <----> | Redis 7 + Disk SWR   |
  | TypeScript 5.7 + TW4 |  REST  | Single-Flight Cache   |  I/O   | Atomic JSON Store    |
  | Recharts + SVG Maps  |  & WS  | SlowAPI + Auth Guards |        | FastF1 HTTP Cache    |
  +----------------------+        +-----------------------+        +----------------------+
             ^                                ^
             |                                |
       [ Web Client ]              [ Nginx Microcache :80 ]

Tech Stack

Layer Technologies
Frontend React 19.1, TypeScript 5.7, Vite 7.3, Tailwind CSS 4.3, Framer Motion, Lucide React
Charts & Maps Recharts 3, D3 utilities, canonical SVG circuit paths & corner layout solver
Client State TanStack React Query 5, React Router 7, native Fetch & WebSocket clients
Backend FastAPI, Python 3.11+, Uvicorn, Pydantic v2, HTTPX, Loguru, Sentry SDK
Data Sources FastF1 3.7, OpenF1 REST API, Formula 1 SignalR WebSocket feed, official standings scraper
Caching & Infra Redis 7, atomic file-backed SWR cache, Nginx reverse-proxy microcache, Docker Compose
Quality Gates Vitest, Testing Library, ESLint 9 (react-hooks + typescript-eslint), Ruff (E9,F,B), unittest

Repository Structure

adnaizf1/
β”œβ”€β”€ .github/workflows/ci.yml         # Frontend, Backend, and Docker Compose CI jobs
β”œβ”€β”€ AGENTS.md                        # Developer and coding-agent workflow notes
β”œβ”€β”€ README.md                        # Project documentation
└── F1-Fullstack-project/
    β”œβ”€β”€ DESIGN.md                    # UI typography, color tokens, and interaction rules
    β”œβ”€β”€ docker-compose.yml           # Redis + FastAPI backend + Nginx frontend stack
    β”œβ”€β”€ Backend/
    β”‚   β”œβ”€β”€ Dockerfile               # Multi-stage non-root Python 3.11 container
    β”‚   β”œβ”€β”€ main.py                  # FastAPI lifespan, CORS, security headers, routers
    β”‚   β”œβ”€β”€ pyproject.toml           # Ruff linter configuration (E9, F, B)
    β”‚   β”œβ”€β”€ requirements.txt         # Locked Python dependencies
    β”‚   β”œβ”€β”€ config/                  # SWR cache, rate limiter, Loguru/Sentry setup
    β”‚   β”œβ”€β”€ routers/                 # dashboard, championship, standings, races, race_details,
    β”‚   β”‚                            # profiles, telemetry, team_radio, livetiming, system
    β”‚   β”œβ”€β”€ services/                # FastF1, OpenF1 fallback, SignalR, scraper, circuit maps
    β”‚   β”œβ”€β”€ utils/                   # API key authentication helper
    β”‚   └── tests/                   # Contract, coalescing, security, and service unit tests
    └── frontend/
        β”œβ”€β”€ Dockerfile               # Node 22 build stage + Nginx Alpine runtime
        β”œβ”€β”€ nginx.conf               # Reverse proxy, microcache, WS upgrade, CSP headers
        β”œβ”€β”€ package.json             # Scripts and locked frontend dependencies
        β”œβ”€β”€ vite.config.js           # Vite build chunking and Vitest configuration
        └── src/
            β”œβ”€β”€ pages/               # Landing, Dashboard, Stats, Races, RaceDetail, LiveTiming,
            β”‚                        # OverlayLive, Compare, Simulator, GhostRace, Bingo, Guide,
            β”‚                        # Drivers, Teams, DriverProfile, TeamProfile, NotFound
            β”œβ”€β”€ components/          # Layout, Telemetry charts, Race tables, SVG track maps
            β”œβ”€β”€ data/                # Canonical circuit paths, corner lore, team colors/logos
            β”œβ”€β”€ hooks/               # Live timing WebSocket and physics simulation hooks
            β”œβ”€β”€ services/            # Typed API client with timeout & AbortSignal support
            └── utils/               # Championship math, next-race resolver, bingo & chart utils

Quick Start

Option A: Docker Compose

From F1-Fullstack-project/, copy .env.example if needed and launch the stack:

cd F1-Fullstack-project
cp Backend/.env.example Backend/.env
docker compose up --build -d
  • Web App (via Nginx): http://localhost:5173
  • Health Check: http://localhost:5173/health

Stop the stack with:

docker compose down

Option B: Local Development

1. Backend (F1-Fullstack-project/Backend)

Launch Uvicorn from inside Backend/ so .env, logs/, and cache/ paths resolve relative to the backend directory:

cd F1-Fullstack-project/Backend
python -m venv venv
# Windows PowerShell:
.\venv\Scripts\Activate.ps1
# Linux / macOS:
source venv/bin/activate

pip install -r requirements.txt
cp .env.example .env
uvicorn main:app --host 127.0.0.1 --port 8000 --reload
  • API Base URL: http://127.0.0.1:8000
  • Swagger UI (development mode): http://127.0.0.1:8000/docs

2. Frontend (F1-Fullstack-project/frontend)

Requires Node.js >=20.19.0 (Node 22 LTS recommended):

cd F1-Fullstack-project/frontend
npm ci --ignore-scripts
cp .env.example .env
npm run dev
  • Frontend Dev Server: http://localhost:5173

Verification & CI

Run the exact checks enforced by .github/workflows/ci.yml before pushing:

Frontend Checks

cd F1-Fullstack-project/frontend
npm run typecheck   # tsc --noEmit
npm run lint        # ESLint (typescript-eslint + react-hooks)
npm run test        # Vitest unit & component suite
npm run build       # Production bundle build

Backend Checks

cd F1-Fullstack-project/Backend
python -m compileall -q .
python -m ruff check .
python -m unittest discover -s tests -v

API Reference

Note: Passing ?refresh=true on cached read endpoints requires a valid X-API-Key header.

Method Endpoint Description Rate Limit
GET /health Service and Redis cache health check Exempt
GET /api/dashboard/{year} Season overview, leader gap, recent results, next session 100/minute
GET /api/championship/{year} WDC & WCC standings plus per-round session_results 100/minute
GET /api/standings/{year} Standings endpoint (shares FastF1/OpenF1 pipeline; optional SQLite mode) 100/minute
GET /api/races/{year} Season calendar, round status, and race winners 100/minute
GET /api/race/{year}/{round} Full weekend classification, stints, sectors, weather, lap/gap charts 60/minute
GET /api/telemetry-drivers/{year}/{round} Drivers available for telemetry comparison in a round 100/minute
GET /api/telemetry/{year}/{round}?drivers=VER,NOR Distance-aligned telemetry channels for up to 5 drivers 60/minute
GET /api/driver/{year}/{driver_id} Driver season profile, H2H split, progression, DNF/DNS details 100/minute
GET /api/team/{year}/{team_id} Constructor season profile, driver points share, progression 100/minute
GET /api/team_radio?session_key=latest Team radio clips from OpenF1 with SignalR cache fallback 60/minute
GET /api/livetiming/previous Snapshot of the last completed live-timing session 60/minute
WS /ws/livetiming Real-time SignalR timing, track map, weather, and race control feed Max 5 / IP
POST / DELETE / GET /api/clear_cache/{year} Clears Redis and disk caches for {year} (requires X-API-Key) 5/minute

License & Disclaimer

This project is released under the MIT License.

Disclaimer: This project is unofficial and is not associated in any way with the Formula 1 companies. F1, FORMULA ONE, FORMULA 1, FIA FORMULA ONE WORLD CHAMPIONSHIP, GRAND PRIX, and related marks are trademarks of Formula One Licensing B.V.

About

🏎️ ANALYZIZ β€” Full-Stack F1 2026 Telemetry, SignalR Live Timing, Team Radio & Championship Analytics Platform (FastAPI + React/TypeScript)

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Packages

Contributors

Languages