How sanjogbhalla16/velocityai works
Project Type & Purpose
• VelocityAI is a full-stack, real-time F1 data and AI chatbot application.
• It integrates data scraping, vector search (with DataStax AstraDB), and retrieval-augmented generation powered by OpenAI and LangChain.
• The application has a dedicated backend built with FastAPI and a frontend developed using Next.js.
Major Components
a. Frontend:
• Built with Next.js (folder: frontend). It includes standard page components (such as chat interface pages, layout, and UI components).
• It makes API calls to the backend and provides the user interface.
b. Backend:
• Built with FastAPI (evidenced by the use of API endpoints, e.g., in Backend/api/index.py, and main.py for the server entry).
• Contains sub-modules for specific functions:
i. API Handlers: Responsible for managing chat endpoints, querying F1 data (Backend/api/query_f1_data.py), and maintaining chat histories (chat_history.db in the API folder).
ii. Data Scraping: The “scraper” directory shows that a dedicated script (scraper.py) extracts F1 data and stores it (scraped_f1_data.json).
iii. Data Population & Processing: The “populate_db” module handles creating collections, loading data, splitting F1 data, and updating the chat database.
c. Databases & External Services:
• Internal database: A local SQLite file (chat_history.db) for storing chat histories.
• External vector database: DataStax AstraDB (mentioned in the README) used for storing custom embeddings and supporting efficient vector search.
• Third-Party Services: OpenAI for powering AI responses, and LangChain for chain-of-thought or retrieval-augmented generation.
• Web scraping tools (likely using Pyppeteer) for gathering dynamic F1 data.
Architectural Relationships & Interactions
• The Frontend and Backend are separated clearly:
• The Frontend (Next.js) communicates with the Backend via API endpoints.
• The Backend acts as the central hub:
• It serves API endpoints that process user requests, query F1 data, and generate responses using ChatGPT-like models.
• It also integrates the data ingestion pipeline: the scraper gathers real-time or historical data; then the populate_db scripts process and update the SQL or vector database.
• External dependencies:
• The backend reaches out to OpenAI and LangChain for generating responses.
• It also interacts with DataStax AstraDB to retrieve relevant F1 knowledge using vector search.
• Request/response flow from Frontend to Backend.
• Data update/insertion flows from scraper/population modules to databases.
• Integration calls from Backend to external AI & vector database services.
• Data requests from Frontend → Backend API.
• Processing calls from Backend → Chat history DB and External Services.
• Data flows from Scraper and Populate modules → Databases.
• Rectangles for application modules (Frontend, Backend).