This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is a Course Materials RAG (Retrieval-Augmented Generation) chatbot - a full-stack web application that answers questions about course materials using semantic search and Claude AI.
Always use UV to run the server and manage dependencies, never pip.
# Install dependencies
uv sync
# Run the application (starts FastAPI server on port 8000)
./run.sh
# Or manually:
cd backend && uv run uvicorn app:app --reload --port 8000
# Web interface: http://localhost:8000
# API docs: http://localhost:8000/docsCopy .env.example to .env and set ANTHROPIC_API_KEY.
Frontend (script.js)
→ POST /api/query
→ app.py endpoint
→ rag_system.query()
→ ai_generator.generate_response() [calls Claude API with tools]
→ Claude decides whether to use search_course_content tool
→ If tool used: search_tools.py → vector_store.py → ChromaDB
→ Response + sources returned to frontend
- rag_system.py: Central orchestrator that coordinates all subsystems
- ai_generator.py: Claude API integration with tool-use support. Claude decides when to search (tool_choice: auto)
- search_tools.py: Tool definitions for Claude's function calling.
CourseSearchToolwraps vector store searches - vector_store.py: ChromaDB wrapper with two collections:
course_catalog: Course metadata for semantic course name resolutioncourse_content: Document chunks for content search
- document_processor.py: Parses course documents, identifies lessons, chunks text with sentence-aware splitting
- session_manager.py: Conversation history management per session
Key settings: CHUNK_SIZE=800, CHUNK_OVERLAP=100, MAX_RESULTS=5, MAX_HISTORY=2
Course: Title, link, instructor, lessonsLesson: Number, title, linkCourseChunk: Text chunk with course/lesson metadata
Vanilla HTML/CSS/JS in frontend/. Uses marked.js for markdown rendering. No build step required.
Sample documents in docs/ are auto-loaded on server startup by app.py lifespan handler.