# F1 Live Race & Winner Prediction Platform Full-stack application for live Formula 1 race tracking, lap-level telemetry ingestion, and real-time winner prediction using machine learning (XGBoost). ## Project Structure ```text f1-live-backend/ ├── backend/ # FastAPI backend service │ ├── app/ # Application code (routes, services, providers) │ ├── models/ # XGBoost model pickle & feature schema │ ├── tests/ # Automated pytest suite │ ├── testing_pipeline/ # FastF1 historical replay & probe test harness │ ├── test_backend.py # Standalone replay test runner │ ├── requirements.txt # Python dependencies │ ├── pytest.ini # Pytest discovery config │ ├── .env # Backend environment configuration │ └── docs/ # Feature contract & architecture docs │ └── frontend/ # React + TypeScript + Vite Dashboard └── Dashboard/ # F1 live telemetry & prediction dashboard ├── src/ │ ├── components/ # Track map, leaderboard, vitals, telemetry panels │ ├── hooks/ # usePredictions (WebSocket & REST live connection) │ ├── types/ # TypeScript schemas & contracts │ └── App.tsx # Main application layout ├── package.json └── vite.config.ts # Dev server with proxy to backend ``` --- ## Quick Start ### 1. Backend Setup & Run ```powershell # Navigate to backend cd backend # Setup virtual environment (if not already created) python -m venv .venv .\.venv\Scripts\Activate.ps1 pip install -r requirements.txt # Run FastAPI backend with Uvicorn (port 8000) uvicorn app.main:app --reload --host 127.0.0.1 --port 8000 ``` - API Docs / Swagger UI: `http://127.0.0.1:8000/docs` - Health check: `http://127.0.0.1:8000/health` - Frontend snapshot: `http://127.0.0.1:8000/live/frontend` - WebSocket stream: `ws://127.0.0.1:8000/live/ws` ### 2. Frontend Setup & Run ```powershell # Navigate to frontend dashboard cd frontend\Dashboard # Install dependencies (Node 18+) npm install # Run Vite dev server (port 5173 with proxy to backend) npm run dev ``` Open `http://localhost:5173` in your browser. --- ## Live Features & Wiring - **WebSocket Stream (`/live/ws`)**: Streams real-time snapshot every second directly to the dashboard. - **REST Snapshot (`/live/frontend`)**: Provides zero-delay initial load and automatic polling fallback if the socket disconnects. - **Live Leaderboard & Win Probabilities**: Real-time XGBoost winner probabilities updated lap-by-lap. - **Live Driver Vitals**: Speed (km/h), RPM, Gear, Throttle %, Brake, DRS status. - **Live Track & Weather Strip**: Dynamic track temperature, air temperature, rain probability, and track status flags (Clear, Caution, Safety Car). - **Interactive Controls**: Header includes live connection status indicator, "Simulate Lap" action to trigger test predictions, and race reset. --- ## Running Tests ### Backend Tests ```powershell cd backend python -m pytest ``` ### Frontend Build & Typecheck ```powershell cd frontend\Dashboard npm run build ``` --- Copyright © 2026 NexInteract Systems Pvt. Ltd. All rights reserved.