This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is a RAG (Retrieval-Augmented Generation) chatbot for course materials. Users query course content through a web interface, and the system uses semantic search + Claude AI to generate answers.
# Install dependencies
uv sync
# Run the server (from project root)
cd backend && uv run uvicorn app:app --reload --port 8000
# Or use the convenience script
./run.shThe app runs at http://localhost:8000 with API docs at http://localhost:8000/docs.
- Frontend (
frontend/script.js) → POST/api/querywith{query, session_id} - FastAPI (
backend/app.py:56) → Routes toRAGSystem.query() - RAGSystem (
backend/rag_system.py:102) → Orchestrates the pipeline:- Gets conversation history from
SessionManager - Calls
AIGenerator.generate_response()with tools
- Gets conversation history from
- AIGenerator (
backend/ai_generator.py:43) → Two-call pattern with Claude:- First call: Claude decides whether to use
search_course_contenttool - If tool used: executes search, then second call to synthesize answer
- First call: Claude decides whether to use
- CourseSearchTool (
backend/search_tools.py:52) → Executes vector search - VectorStore (
backend/vector_store.py:61) → ChromaDB query with filters
| Component | File | Purpose |
|---|---|---|
RAGSystem |
rag_system.py |
Main orchestrator, initializes all components |
AIGenerator |
ai_generator.py |
Claude API calls, tool execution loop |
VectorStore |
vector_store.py |
ChromaDB wrapper, two collections: course_catalog + course_content |
DocumentProcessor |
document_processor.py |
Parses course files, sentence-based chunking |
CourseSearchTool |
search_tools.py |
Tool definition for Claude, formats search results |
SessionManager |
session_manager.py |
Per-session conversation history |
Course documents in docs/ follow this structure:
Course Title: [title]
Course Link: [url]
Course Instructor: [name]
Lesson 0: Introduction
Lesson Link: [url]
[content...]
Lesson 1: Topic
[content...]
All settings in backend/config.py:
CHUNK_SIZE: 800 charsCHUNK_OVERLAP: 100 charsMAX_RESULTS: 5 search resultsMAX_HISTORY: 2 conversation exchangesEMBEDDING_MODEL: all-MiniLM-L6-v2ANTHROPIC_MODEL: claude-sonnet-4-20250514
Defined in backend/models.py:
Course→ title (unique ID), lessons list, instructor, linkLesson→ number, title, linkCourseChunk→ content with course/lesson metadata for vector storage
Requires .env file with:
ANTHROPIC_API_KEY=your_key_here