Skip to content
This repository was archived by the owner on Feb 5, 2026. It is now read-only.

iturgut/F1Picks

Repository files navigation

F1 Picks

A free-to-play prediction web app for Formula 1 fans who want to compete socially with friends and groups. Users make predictions before race sessions, which are then automatically scored once official timing and telemetry data becomes available via the FastF1 library.

🌐 Live App: https://f1-picks-frontend.vercel.app
πŸ”§ API: https://f1picks-backend.fly.dev

🏎️ Features

  • Telemetry-Aware Predictions: Predict race winners, podium finishes, fastest laps, sector times, and pit windows
  • Post-Session Auto-Scoring: Transparent scoring using FastF1 data (30-120 minutes post-session)
  • Global & League Leaderboards: Compete globally or create private leagues
  • Real-time Updates: Live leaderboard updates after scoring completes
  • Analytics & Transparency: Hit rate, average margin, and per-prop scoring breakdown
  • Social Features: Camera integration for profile photos and QR code league joining

πŸ—οΈ Architecture

This is a monorepo containing:

  • Frontend (/frontend): Next.js 15 with TypeScript and Tailwind CSS
  • Backend (/backend): FastAPI with Python 3.13
  • Shared (/shared): Common utilities, types, and configurations
  • Worker: Python worker for FastF1 data ingestion (post-session)

Tech Stack

  • Frontend: Next.js 15, React 19, TypeScript 5, Tailwind CSS, shadcn/ui
  • Backend: FastAPI, SQLAlchemy, Alembic, asyncpg, Python 3.13
  • Database: PostgreSQL (Supabase)
  • Data Source: FastF1 library for F1 telemetry and results
  • Authentication: Supabase Auth (email/password, OAuth)
  • Deployment: Vercel (frontend), Fly.io (backend), automated via GitHub Actions
  • CI/CD: GitHub Actions with Release Please
  • Package Management: npm workspaces (frontend), uv (backend)

πŸš€ Quick Start

Prerequisites

  • Node.js 18+ and npm 9+
  • Python 3.13+
  • PostgreSQL
  • Git
  • Docker (optional, for containerized development)

Installation

  1. Clone the repository

    git clone <repository-url>
    cd F1Picks
  2. Install dependencies

    # Install all workspace dependencies
    npm ci --include-workspace-root
    
    # Install backend dependencies
    cd backend
    pip install -r requirements.txt
    pip install -r dev-requirements.txt
    cd ..
  3. Environment Setup

    # Backend environment
    cd backend
    cp .env.example .env
    # Edit .env with your configuration:
    # - DATABASE_URL (PostgreSQL connection string)
    # - SUPABASE_URL and SUPABASE_ANON_KEY
    # - SECRET_KEY for JWT tokens
    
    # Frontend environment
    cd ../frontend
    cp .env.example .env
    # Edit .env with:
    # - NEXT_PUBLIC_SUPABASE_URL
    # - NEXT_PUBLIC_SUPABASE_ANON_KEY
    # - NEXT_PUBLIC_API_URL (backend URL)
  4. Database Setup

    # Run database migrations
    cd backend
    alembic upgrade head
    
    # Optional: Seed development data
    python scripts/seed_dev_data.py
  5. Start Development Servers

    # Start both frontend and backend
    npm run dev
    
    # Or start individually:
    npm run dev:frontend  # http://localhost:3000
    npm run dev:backend   # http://localhost:8000

πŸ“ Project Structure

F1Picks/
β”œβ”€β”€ frontend/                 # Next.js frontend application
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ app/             # App router pages (home, leagues, profile)
β”‚   β”‚   β”œβ”€β”€ components/      # React components (ui, layout)
β”‚   β”‚   β”œβ”€β”€ contexts/        # React contexts (auth)
β”‚   β”‚   └── lib/             # API client, utilities
β”‚   β”œβ”€β”€ public/              # Static assets
β”‚   └── package.json
β”œβ”€β”€ backend/                 # FastAPI backend application
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ models/          # SQLAlchemy database models
β”‚   β”‚   β”œβ”€β”€ repositories/    # Data access layer
β”‚   β”‚   β”œβ”€β”€ routers/         # API endpoints (users, leagues, picks, etc.)
β”‚   β”‚   β”œβ”€β”€ config.py        # Application settings
β”‚   β”‚   β”œβ”€β”€ database.py      # Database connection
β”‚   β”‚   └── main.py          # FastAPI app with CORS
β”‚   β”œβ”€β”€ alembic/             # Database migrations
β”‚   β”œβ”€β”€ scripts/             # Utility scripts (seed data, migrations)
β”‚   β”œβ”€β”€ tests/               # Backend tests
β”‚   β”œβ”€β”€ requirements.txt     # Python dependencies
β”‚   └── fly.toml             # Fly.io deployment config
β”œβ”€β”€ worker/                  # FastF1 data ingestion worker
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ fastf1_client.py # FastF1 integration
β”‚   β”‚   β”œβ”€β”€ scheduler.py     # Celery task scheduler
β”‚   β”‚   └── database.py      # Database connection
β”‚   └── requirements.txt
β”œβ”€β”€ shared/                  # Shared TypeScript types
β”œβ”€β”€ .github/workflows/       # CI/CD workflows
β”‚   β”œβ”€β”€ ci.yml              # PR validation
β”‚   β”œβ”€β”€ deploy.yml          # Production deployment
β”‚   └── daily-data-sync.yml # Scheduled data updates
β”œβ”€β”€ package.json            # Root package.json with workspaces
└── README.md

πŸ› οΈ Development

Available Scripts

  • npm run dev - Start both frontend and backend in development mode
  • npm run build - Build shared package and frontend for production
  • npm run lint - Run ESLint on frontend
  • npm run lint:backend - Run Ruff linting on backend
  • npm run format:backend - Format backend code with Ruff

Code Quality

  • Frontend: ESLint, TypeScript
  • Backend: Ruff (linting and formatting)
  • CI/CD: Automated testing on PRs, deployment on merge to main

🚒 Deployment

CI/CD Pipeline

The project uses a multi-workflow GitHub Actions setup:

  1. CI Pipeline (ci.yml) - Runs on PRs to main

    • Frontend: Lint, build, and validate
    • Backend: Lint with Ruff, test FastAPI startup
    • Does NOT deploy
  2. Deploy (deploy.yml) - Runs on merge to main

    • Deploys backend to Fly.io using Docker
    • Frontend deploys automatically via Vercel GitHub integration
  3. Release Please (release-please.yml) - Automated versioning

    • Creates release PRs with changelog generation
    • Bumps versions across all workspace packages
    • Follows Conventional Commits specification

Frontend (Vercel)

  • URL: https://f1-picks-frontend.vercel.app
  • Automatic deployment from main branch via Vercel GitHub integration
  • Environment variables configured in Vercel dashboard:
    • NEXT_PUBLIC_API_URL
    • NEXT_PUBLIC_SUPABASE_URL
    • NEXT_PUBLIC_SUPABASE_ANON_KEY

Backend (Fly.io)

  • URL: https://f1picks-backend.fly.dev
  • Deployed using fly.toml configuration
  • Triggered by deploy.yml workflow on merge to main
  • Database migrations run automatically on deployment
  • Environment variables configured via Fly.io secrets:
    • DATABASE_URL
    • SUPABASE_URL
    • SUPABASE_SERVICE_ROLE_KEY
    • SECRET_KEY

πŸ§ͺ Testing

Frontend

cd frontend
npm run test

Backend

cd backend
pytest

CI/CD Testing

All tests run automatically on pull requests via GitHub Actions.

πŸ“Š Data Flow

  1. Schedule Ingestion: Worker fetches F1 schedule from FastF1
  2. User Predictions: Users make picks before session start times
  3. Session Execution: F1 sessions run (qualifying, practice, race)
  4. Data Availability: FastF1 publishes results/telemetry (30-120 min delay)
  5. Auto-Scoring: Worker ingests data, calculates scores, updates leaderboards
  6. User Notification: Users see updated scores and leaderboard positions

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes using Conventional Commits
    • feat: for new features
    • fix: for bug fixes
    • docs: for documentation changes
    • chore: for maintenance tasks
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request
  6. CI pipeline will automatically run tests and validation
  7. After merge, Release Please will handle versioning and changelog generation

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

🏁 Current Status & Roadmap

βœ… Completed

  • Full-stack application deployed (Frontend on Vercel, Backend on Fly.io)
  • Database schema with 8 models (User, League, Event, Pick, Result, Score, etc.)
  • Supabase authentication integration
  • League management (create, join, view members)
  • User profiles and leaderboards
  • CI/CD pipeline with automated deployments
  • CORS configuration for production
  • Database migrations with Alembic

🚧 In Progress

  • FastF1 data ingestion worker
  • Automated scoring system
  • Real-time leaderboard updates

πŸ“‹ Planned

  • Advanced telemetry predictions (sector times, pit windows)
  • QR code league joining
  • Camera integration for profile photos
  • Analytics dashboard (hit rate, average margin)
  • Seasonal leaderboards and playoffs
  • Mobile app (React Native)