File size: 3,475 Bytes
267266e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# 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.