← Back to Projects

F1 Pit Window Predictor

An automated data pipeline that ingests telemetry data to predict tire degradation and optimal pit stops in real-time.

View RepositoryStatus: In Development

The Challenge

Formula 1 strategy relies heavily on understanding tire degradation ("deg"). However, deg is non-linear and affected by track temperature, fuel load, and traffic. The goal was to build a system that could ingest raw lap time data and visualize the "crossover point"—the exact moment a new set of tires becomes faster than the current set.

System Architecture

  • 01. IngestionPython scripts pull telemetry from the OpenF1 API, containerized in Docker for consistency.
  • 02. StorageRaw JSON is processed and normalized into a PostgreSQL database schema designed for time-series queries.
  • 03. OrchestrationApache Airflow (running in Docker Compose) schedules the ingestion jobs and manages dependencies.
  • 04. AnalysisPandas & Scikit-learn models calculate the deg curve and predict the pit window.

Tech Stack

PythonDockerAirflowPostgreSQLPandasMLflow

Key Learnings

  • Managing Airflow DAGs in a containerized environment.
  • Handling API rate limits and data normalization.
  • Designing idempotent data pipelines.

Ingestion Logic

# Example: Dockerized ingestion script snippet

def fetch_telemetry(session_key, driver_number):
    """
    Fetches lap data and normalizes for storage.
    Running inside Docker container 'ingest-worker-01'
    """
    endpoint = f"https://api.openf1.org/v1/laps?session_key={session_key}"
    response = requests.get(endpoint)
    
    if response.status_code == 200:
        data = normalize_laps(response.json())
        db.bulk_insert(data)
        logger.info(f"Ingested {len(data)} laps for Driver {driver_number}")
    else:
        logger.error("API Gateway Timeout")