Skip to content
Subhash edited this page Apr 7, 2025 · 4 revisions

Fastlytics Wiki

Overview

Fastlytics is a lightning-fast platform for Formula 1 fans to explore historical data, compare drivers, and simulate race strategies. The platform provides an intuitive interface for analyzing Formula 1 data without requiring an engineering degree.

Table of Contents

Project Architecture

Fastlytics uses a modern web architecture with:

  • Frontend: React-based application with Tailwind CSS and shadcn/ui
  • Backend: FastAPI Python backend that processes Formula 1 data using FastF1 API
  • Authentication: Supabase for user authentication and data storage
  • Infrastructure: Containerized with Docker, hosted on Oracle Cloud

The application follows a client-server architecture where:

  1. Frontend requests data from the backend API
  2. Backend processes F1 data (either from cache or live processing)
  3. Results are cached for future requests to improve performance

Getting Started

Prerequisites

  • Node.js v18+
  • Python 3.10+
  • Docker (for local Supabase/PostgreSQL)

Installation

  1. Clone the repository:

    git clone https://github.com/subhashhhhhh/Fastlytics.git
  2. Install frontend dependencies:

    npm install
  3. Install backend dependencies:

    git clone https://github.com/subhashhhhhh/Fastlytics-Backend.git
    pip install -r requirements.txt

Environment Setup

  1. Configure environment variables:

    cp .env.example .env
  2. Configure backend environment variables:

    cp .env.example .env

Frontend

Frontend Tech Stack

  • React: UI library
  • Tailwind CSS: Utility-first CSS framework
  • shadcn/ui: UI components based on Radix UI
  • React Router: Client-side routing
  • React Query: Data fetching and state management
  • Supabase JS Client: Authentication and database interactions

Frontend Structure

src/
├── components/     # Reusable UI components
├── contexts/       # React contexts for state management
├── data/           # Static data and constants
├── hooks/          # Custom React hooks
├── lib/            # Utility functions and services
├── pages/          # Page components
└── App.tsx         # Main application component

Key Components

  • App.tsx: The main application component that sets up routing, providers, and layouts
  • AuthProvider: Context for managing authentication state
  • SeasonProvider: Context for managing the selected F1 season
  • Dashboard: Main entry point after login showing F1 data overview
  • Race: Detailed view for a specific race, including telemetry and comparisons
  • DriverStandings/TeamStandings: Displays current championship standings

Authentication

Authentication is handled through Supabase, with protected routes that require login. The ProtectedRoute component ensures users are authenticated before accessing certain pages.

Backend

Backend Tech Stack

  • FastAPI: Modern, high-performance web framework for Python
  • FastF1: Python library for accessing Formula 1 data
  • Pandas: Data manipulation and analysis
  • Uvicorn/Gunicorn: ASGI server for running the application

API Endpoints

The backend provides several endpoint categories:

  1. Schedule Endpoints: Get F1 season schedule

    • /api/schedule/{year}
  2. Session Data Endpoints: Get data about specific sessions

    • /api/session/drivers - List of drivers in a session
    • /api/laps/driver - Lap numbers for a specific driver
    • /api/laptimes - Compare lap times between drivers
    • /api/telemetry/speed - Speed telemetry data for a driver
    • /api/telemetry/gear - Gear shift telemetry data
    • /api/comparison/sectors - Sector time comparisons between drivers
    • /api/strategy - Tire strategy data
    • /api/lapdata/positions - Lap-by-lap position data
  3. Standings Endpoints: Get championship standings

    • /api/standings/drivers - Driver championship standings
    • /api/standings/teams - Constructor championship standings
  4. Results Endpoints: Get race results

    • /api/results/races - Race results summary
    • /api/results/race/{year}/{event_slug} - Specific race result

Data Processing

Data processing is handled by two key components:

  1. Processor: A script that processes raw F1 data and caches it for faster access

    • Handles race data, qualifying sessions, practice sessions
    • Processes telemetry data for speed, gear shifts, etc.
    • Calculates championship standings and race results
  2. API Handlers: The main.py file defines API endpoints that serve processed data

    • Checks cache for pre-processed data
    • Falls back to live processing when needed
    • Formats data for frontend consumption

Development Workflow

Running Locally

  1. Start the frontend development server:

    npm run dev
  2. Start the backend server:

    uvicorn main:app --reload

Contributing Guidelines

  1. Fork the repository
  2. Create a branch: git checkout -b feature/brazilian-gp-2023
  3. Commit changes: git commit -m "Added Hamilton's magic telemetry"
  4. Push: git push origin feature/brazilian-gp-2023
  5. Submit a PR

Deployment

The application is deployed across multiple platforms:

  1. Frontend: Hosted on a cloud provider with static site hosting
  2. Backend: Deployed using Docker containers on Oracle Cloud
  3. Database: Supabase for PostgreSQL database hosting

Deployment is managed through CI/CD pipelines that build, test, and deploy the application automatically.

Troubleshooting

Common Issues

  1. API Key Errors: Ensure your FASTLYTICS_API_KEY environment variable is set correctly in the backend
  2. Data Cache Errors: Check that the DATA_CACHE_PATH directory exists and is writable
  3. FastF1 API Issues: The FastF1 library may occasionally have issues with certain race data or API changes
  4. Authentication Problems: Verify Supabase configuration and credentials

Getting Help

If you encounter issues not covered in this wiki:

  1. Check the GitHub issues for similar problems
  2. Submit a new issue with detailed information about the problem
  3. Reach out to the maintainers through the project's communication channels