Skip to content

prateekmulye/ChatFormula1

🏎️ ChatFormula1

An AI-powered Formula 1 chatbot that provides real-time race information, predictions, and insights using advanced RAG (Retrieval-Augmented Generation) architecture.

πŸš€ Live Demo

Try it now: https://chatformula1.com

Note: First load may take 30 seconds as the free tier wakes up.


πŸ—ΊοΈ Quick Navigation


πŸ“– What It Does

ChatFormula1 is an intelligent chatbot that can:

  • Answer questions about current F1 standings and race results
  • Provide historical F1 statistics and records
  • Generate race predictions based on data analysis
  • Search for latest F1 news and updates
  • Explain technical F1 concepts and regulations
  • Maintain context across conversations

Example Questions:

  • "Who won the 2023 F1 World Championship?"
  • "What are the current driver standings?"
  • "Predict the outcome of the next race"
  • "Explain DRS in Formula 1"

πŸ› οΈ Tech Stack

AI & Machine Learning

  • LangChain - Framework for building LLM applications
  • LangGraph - Library for building stateful, multi-actor applications with LLMs
  • OpenAI GPT - Large language model for generating responses
  • OpenAI Embeddings - Text vectorization for semantic search

Data & Search

  • Pinecone - Vector database for semantic search and retrieval
  • Tavily API - Real-time web search API for current information

Backend

  • Python 3.11+ - Core programming language
  • FastAPI - Modern web framework for building APIs
  • Pydantic - Data validation using Python type hints
  • Poetry - Dependency management and packaging

Frontend

  • Streamlit - Framework for building interactive web applications

Infrastructure

  • Docker - Containerization platform
  • Render - Cloud hosting platform (free tier available)

Observability - COMMING SOON


πŸ—οΈ Architecture

User Input
    ↓
Streamlit UI
    ↓
LangGraph Agent
    β”œβ”€β”€ Query Analysis
    β”œβ”€β”€ Routing (Vector Search / Web Search)
    β”œβ”€β”€ Context Ranking
    └── LLM Generation
    ↓
Response with Citations

Key Components:

  • RAG Pipeline: Combines vector search with LLM generation for accurate, grounded responses
  • Multi-Source Integration: Retrieves from both historical data (Pinecone) and real-time web (Tavily)
  • Intelligent Routing: Automatically determines the best data source for each query
  • Rate Limiting: Built-in protection to stay within free tier limits

πŸš€ Quick Start

Prerequisites

Local Development

  1. Clone the repository

    git clone https://github.com/YOUR_USERNAME/chatformula1.git
    cd chatformula1
  2. Install dependencies

    poetry install
  3. Set up environment variables

    cp .env.example .env
    # Edit .env and add your API keys
  4. Run the application

    # Option 1: Streamlit UI (recommended for testing)
    poetry run streamlit run src/ui/app.py
    
    # Option 2: FastAPI backend
    poetry run uvicorn src.api.main:app --reload
  5. Access the application

Docker

# Build and run with Docker Compose
docker-compose up --build

# Access at:
# - UI: http://localhost:8501
# - API: http://localhost:8000

πŸ“š Documentation

Getting Started

Technical Documentation

πŸ“– Full Documentation Index


🎯 Deployment

Automated with GitHub Actions

Deploy automatically on every commit prefixed with deploy::

# One-time setup (5 minutes)
./scripts/setup_github_actions.sh

# Deploy with a single commit
git commit -m "deploy: Add new feature"
git push origin main

What happens: Code quality checks β†’ Tests β†’ Build β†’ Deploy to Render β†’ Health checks

πŸ“– Guide: GitHub Actions Quick Start | Full Documentation

πŸ“ Project Structure

chatformula1/
β”œβ”€β”€ src/                      # Source code
β”‚   β”œβ”€β”€ agent/               # LangGraph agent implementation
β”‚   β”œβ”€β”€ api/                 # FastAPI endpoints
β”‚   β”œβ”€β”€ config/              # Configuration management
β”‚   β”œβ”€β”€ ingestion/           # Data ingestion pipeline
β”‚   β”œβ”€β”€ prompts/             # LLM prompt templates
β”‚   β”œβ”€β”€ search/              # Tavily search integration
β”‚   β”œβ”€β”€ tools/               # LangChain tools
β”‚   β”œβ”€β”€ ui/                  # Streamlit interface
β”‚   β”œβ”€β”€ utils/               # Utility functions
β”‚   └── vector_store/        # Pinecone integration
β”œβ”€β”€ tests/                   # Test suite
β”œβ”€β”€ scripts/                 # Deployment and utility scripts
β”œβ”€β”€ docs/                    # Documentation
β”‚   β”œβ”€β”€ README.md           # Documentation index
β”‚   β”œβ”€β”€ SETUP.md            # Local setup guide
β”‚   β”œβ”€β”€ DEPLOYMENT.md       # Deployment guide
β”‚   β”œβ”€β”€ CONTRIBUTING.md     # Contribution guidelines
β”‚   β”œβ”€β”€ ARCHITECTURE.md     # System architecture
β”‚   β”œβ”€β”€ API.md              # API reference
β”‚   └── ...                 # Additional technical docs
β”œβ”€β”€ pyproject.toml          # Poetry dependencies
β”œβ”€β”€ Dockerfile              # Docker configuration
└── README.md               # This file (start here!)

πŸ”’ Security & Rate Limiting

  • API keys stored as environment variables (never committed)
  • Input validation and sanitization
  • Rate limiting: 3 requests/minute, 100 requests/day per user
  • HTTPS encryption (automatic on Render)
  • No storage of personally identifiable information (PII)

πŸ’° Cost Optimization

The application is designed to run entirely on free tiers:

Service Free Tier Usage Strategy
Render 750 hrs/month Auto-sleep after 15min inactivity
OpenAI $5 credit Rate limited to 3 RPM, 200 RPD
Pinecone 100K vectors Efficient text chunking
Tavily 1000/month Limited to 30 searches/day

🀝 Contributing

Contributions are welcome! Please see docs/CONTRIBUTING.md for guidelines.

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“„ License

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


πŸ“ž Contact


Built with ❀️ for Formula 1 fans and AI enthusiasts

About

Chat with an Formula 1 Expert Chatbot. Upgrade with future vision is in progress...

Topics

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages