This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
# Install dependencies
uv sync
# Add new dependencies
uv add package_name
# Set up environment variables
cp .env.example .env
# Edit .env to add your ANTHROPIC_API_KEY# Quick start (recommended)
chmod +x run.sh
./run.sh
# Manual start
cd backend && uv run uvicorn app:app --reload --port 8000# Run from backend directory
cd backend && uv run uvicorn app:app --reload --port 8000
# Test API endpoints directly
curl http://localhost:8000/api/courses
curl -X POST http://localhost:8000/api/query -H "Content-Type: application/json" -d '{"query":"your question here"}'This is a RAG (Retrieval-Augmented Generation) System with a three-layer architecture:
- Document Processing: Course transcripts → chunked text with metadata
- Vector Storage: ChromaDB stores embeddings for semantic search
- AI Generation: Claude API generates contextual responses using retrieved content
- Tool Integration: AI can dynamically search the knowledge base using tools
RAGSystem (rag_system.py) - Central orchestrator that coordinates:
- Document processing and chunking
- Vector storage operations
- AI response generation with tool access
- Session management for conversation history
Tool-Based Search Architecture - The system uses a tool-based approach where:
ToolManagerregisters and manages available toolsCourseSearchToolperforms content searches within course materialsCourseOutlineToolretrieves complete course structures with lesson lists- Claude API calls tools dynamically during response generation
- Tools return sources that are tracked and returned to frontend with links
Data Models (models.py):
Course: Contains title, instructor, lessons listCourseChunk: Text chunks with course/lesson metadata for vector storageLesson: Individual lessons with titles and optional links
Key settings:
CHUNK_SIZE: 800- Text chunk size for vector storageCHUNK_OVERLAP: 100- Overlap between chunksMAX_RESULTS: 5- Vector search result limitMAX_HISTORY: 2- Conversation memory depth
- Course documents in
docs/are processed intoCourseChunkobjects - Chunks are embedded and stored in ChromaDB (
./chroma_db/) - User queries trigger tool-based searches via Claude API
- Retrieved chunks provide context for AI response generation
- Session history maintains conversation continuity
- FastAPI serves both API endpoints (
/api/*) and static frontend files - Frontend communicates via
/api/queryfor chat and/api/coursesfor statistics - CORS configured for development with live reload support
Required environment variable:
ANTHROPIC_API_KEY=your_anthropic_api_key_here
The system expects course documents in docs/ folder as .txt, .pdf, or .docx files.