Skip to content
AabhasKPublic

About

Pick F1 race outcomes with friends, earn points when results come in, and compete on a private leaderboard. Built with Python FastAPI, FastF1 API, and managed with uv.

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Compete with friends on F1 race outcomes. Predict the podium, pole, fastest lap, DNF and more before each Grand Prix — earn points when the real results come in.

▶ Live app — dream-f1.vercel.app

Next.js FastAPI PostgreSQL Python Docker AWS License Status

UI

All data is real 2026 Formula 1 data, pulled from FastF1. The design borrows from F1 timing graphics: dark ruled layouts instead of cards, the Formula 1 typeface for times and driver codes, and start lights and kerbs used as parts of the interface. Every page works on a phone.

How it works

  1. Register — create an account, then create or join a Circle (private friend group) with an invite code.
  2. Dashboard — countdown to the next session with the weekend's timetable, the championship, the last race's podium, the constructors' fight and the season calendar.
  3. Submit your race card — lock in your picks before the race starts; the form is auto-locked to the next race and prevents picking the same driver twice.
  4. Explore — dig into per-round telemetry, full championship standings, and head-to-head driver comparisons.
  5. Auto-scoring — after the race, FastF1 fetches the official results and points are computed automatically.
  6. Leaderboard — each Circle's standings update after every Grand Prix.
  [ User ]           [ FastAPI ]              [ FastF1 ]
     │                    │                       │
     │  submit race card  │                       │
     ├───────────────────>│  validate + persist   │
     │                    │                       │
     │                    │  fetch race results ──>
     │                    │<──────────────────────
     │  leaderboard update│  score + rank         │
     │<───────────────────│                       │

Features

Predictions & Circles

  • Up to 9 pick categories per race — Pole, P1, P2, P3 and Fastest Lap (required), plus optional P4, P5, DNF and a Safety Car yes/no call.
  • Strictly next race — the predict form is always locked to the next unscored Grand Prix; no race picker, no editing the past.
  • Duplicate prevention — driver dropdowns disable already-selected drivers across position slots.
  • Auto-scoring engine — results pulled from FastF1 post-race, points computed without manual input (max 64 pts/race).
  • Circles — private friend groups with invite codes and per-circle leaderboards.
  • My Picks — full prediction history with points, accuracy, and per-race status.

Telemetry explorer (12 views per round)

Race classification · Lap times · Race pace · Position changes · Gaps to leader · Tyre strategy · Qualifying (Q1/Q2/Q3 knockout) · Sector times · Speed traces · Circuit explorer (detailed track diagrams + length/laps/record stats) · Weather (track/air temp, humidity, wind, rainfall over the race) · Race Control (flags, safety cars, VSC, penalties, investigations — filterable feed).

Championship & comparison

  • Standings — full Drivers' and Constructors' championship tables with wins, podiums, poles, DNFs, form and gaps, plus the season's leaders in each.
  • Compare — two drivers' fastest laps overlaid (speed, gap, throttle, brake, gear) on one shared cursor, with a track map coloured by who was quicker in each of 25 mini-sectors.

Platform

  • JWT authentication — bcrypt-hashed passwords, validated sign-up with auto-login.
  • Responsive — tables scroll sideways with the driver column pinned, and charts redraw at the screen's real width, so phones get readable axes.
  • Demo mode — when the backend is switched off, the site serves snapshots of real 2026 data and any username signs in, so the link always works.

Scoring

Category Points Notes
P1 / P2 / P3 10 Required
Pole Position 5 Required
Fastest Lap 5 Required
P4 8 Optional
P5 6 Optional
DNF 5 Optional — any driver who retires
Safety Car 5 Optional — was there a SC? yes/no
Max/race 64

Stack

Layer Tech
Frontend Next.js 16 (App Router), React 19, Tailwind CSS v4
Charts Hand-built SVG (telemetry, weather, circuit)
Backend FastAPI, SQLModel / SQLAlchemy, PostgreSQL
Auth JWT bearer, bcrypt
Data FastF1, Pandas, NumPy
Prototype Streamlit, Plotly (reference build)
Infra Docker, AWS EC2 + ECR, Vercel
CI/CD GitHub Actions (test, build, deploy)

Project structure

backend/              FastAPI app: one router per area in app/routers/, the FastF1 session cache,
                      tests, and scripts/snapshot_demo.py (writes the demo-mode data)
frontend/             Next.js app: app/ (one folder per page), components/, lib/,
                      demo-data/ (JSON snapshots), public/ (fonts, driver and car images, circuits)
frontend-prototype/   the original Streamlit build, kept for reference
infra/                Docker Compose files: production on EC2, and the full local stack
.github/workflows/    CI, backend deploy, post-race cache warmer

Quick start

Docker (recommended)

git clone https://github.com/AabhasK/DreamF1
cd DreamF1
docker compose -f infra/compose.dev.yml up --build

Local

# backend
cd backend && uv sync
uv run uvicorn main:app --port 8080 --reload

# Next.js frontend (runs on the bundled demo data until DEMO_MODE=false)
cd frontend && npm install && npm run dev

# Streamlit prototype (optional)
cd frontend-prototype && uv sync
uv run streamlit run main.py

Environment variables

.env.example lists every variable with safe placeholders. The backend reads backend/.env:

# database
POSTGRES_USER=your_user
POSTGRES_PASSWORD=your_password
POSTGRES_HOST=localhost
POSTGRES_PORT=5432
POSTGRES_DB=f1db

# auth
SECRET_KEY=your_secret_key
ALGORITHM=HS256

The frontend reads frontend/.env.local. Leave DEMO_MODE unset to run on the bundled snapshots with no backend at all, or set DEMO_MODE=false and API_URL=http://localhost:8080 to use your local backend.

Deployment

  • Frontend → Vercel, auto-deployed on every push to main. The browser only calls a relative /api/* path, and frontend/app/api/[...path]/route.ts either forwards it to the backend (so the HTTPS page never calls HTTP directly) or, in demo mode, answers from the snapshots in frontend/demo-data/.
  • Backend → AWS EC2, via GitHub Actions: build the image, push to ECR, then SSH in and docker compose up (Postgres + FastAPI). FastF1's cache is a persistent Docker volume. The deploy and cache-warming jobs only run while the repo variable BACKEND_LIVE is true.
  • Demo data is refreshed after each race with cd backend && uv run python scripts/snapshot_demo.py, which calls the same endpoint functions as the live API, so the snapshots match it exactly.

Roadmap

  • Production Next.js frontend (Vercel) + FastAPI backend (AWS EC2)
  • Full telemetry explorer — 12 views per round, incl. circuit / weather / race control
  • Drivers' & Constructors' championship standings
  • My Picks history and head-to-head driver comparison
  • Demo mode, so the site keeps working with the backend switched off
  • Redesign in the style of F1 timing graphics, built to work on phones
  • ML pick advisor — historical data → podium probabilities & DNF risk per driver/circuit
  • Elastic IP + HTTPS (reverse proxy) on the backend

Contributing

Contributions are welcome — see CONTRIBUTING.md for setup, the golden rules of the prediction logic, and good first issues to start with.

About

Pick F1 race outcomes with friends, earn points when results come in, and compete on a private leaderboard. Built with Python FastAPI, FastF1 API, and managed with uv.

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages