This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
# Quick start (recommended)
./run.sh
# Manual start
cd backend && uv run uvicorn app:app --reload --port 8000# Install dependencies
uv sync
# Set up environment variables (required)
echo "ANTHROPIC_API_KEY=your_key_here" > .env- Web Interface: http://localhost:8000
- API Documentation: http://localhost:8000/docs
This is a RAG (Retrieval-Augmented Generation) system for course materials built with FastAPI backend and vanilla JavaScript frontend.
The system follows a tool-based RAG pattern where:
- Claude AI autonomously decides when to search course materials using tool calling
- Structured document processing parses course documents into hierarchical chunks (course → lesson → content)
- Vector storage enables semantic search through ChromaDB with sentence transformers
- Session management maintains conversation context across queries
Backend (backend/):
app.py- FastAPI server serving both API endpoints and static frontendrag_system.py- Main orchestrator coordinating all componentsai_generator.py- Anthropic Claude integration with tool execution handlingdocument_processor.py- Parses structured course documents into searchable chunksvector_store.py- ChromaDB vector database with semantic searchsearch_tools.py- Tool definitions for Claude's autonomous search capabilitiessession_manager.py- Conversation history managementconfig.py- Centralized configuration with environment variable loading
Document Processing Pipeline: Course documents must follow this structure:
Course Title: [title]
Course Link: [url]
Course Instructor: [instructor]
Lesson 0: Introduction
Lesson Link: [lesson_url]
[lesson content...]
Documents are processed into:
- Metadata extraction (course title, instructor, links)
- Lesson structure parsing (lesson numbers, titles, content)
- Sentence-based chunking (800 chars with 100 char overlap)
- Context enhancement (each chunk includes course/lesson metadata)
- Frontend sends query via
/api/queryendpoint - RAG System builds prompt with conversation history
- AI Generator calls Claude with available search tools
- Claude decides whether to use
search_course_contenttool - Search Tool queries vector store with optional course/lesson filters
- Vector Store performs semantic search and returns contextual results
- Claude synthesizes final response from search results
- Frontend displays answer with source attribution
Key settings in config.py:
CHUNK_SIZE: 800- Text chunk size for vector storageCHUNK_OVERLAP: 100- Character overlap between chunksMAX_RESULTS: 5- Maximum search results returnedMAX_HISTORY: 2- Conversation messages to rememberANTHROPIC_MODEL: claude-sonnet-4-20250514EMBEDDING_MODEL: all-MiniLM-L6-v2
Uses ChromaDB with two collections:
course_catalog- Course metadata for name resolutioncourse_content- Searchable content chunks with course/lesson context
Course documents are auto-loaded from docs/ folder on startup.
Claude has access to search_course_content tool with parameters:
query(required) - What to search forcourse_name(optional) - Course filter with fuzzy matchinglesson_number(optional) - Specific lesson filter
The tool system enables Claude to autonomously search when needed rather than always searching for every query.
- always to use uv to run the server do not use pip directly
- make sure to use uv to manage all dependencies