This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Start the application:
./run.shThis starts the FastAPI server on port 8000 with auto-reload enabled. Requires ANTHROPIC_API_KEY in .env file.
Manual start (for development):
cd backend && uv run uvicorn app:app --reload --port 8000Install dependencies:
uv syncCode Quality Commands:
# Format code automatically
./scripts/format.sh
# Run all quality checks
./scripts/lint.sh
# Run individual quality checks
uv run black --check backend/ main.py # Check formatting
uv run isort --check-only backend/ main.py # Check import sorting
uv run flake8 backend/ main.py # Lint code
uv run mypy backend/ main.py # Type checking
# Fix formatting issues
uv run black backend/ main.py # Auto-format with Black
uv run isort backend/ main.py # Auto-sort imports
# Advanced quality script with options
python scripts/quality_check.py --fix # Run all checks and fix issues
python scripts/quality_check.py --check black # Run only Black checkAccess points:
- Web Interface:
http://localhost:8000 - API Documentation:
http://localhost:8000/docs
This is a Retrieval-Augmented Generation (RAG) chatbot system for course materials with a tool-based architecture where the AI can intelligently choose when to search vs. use general knowledge.
- Frontend (
frontend/) - Simple HTML/CSS/JS chat interface - FastAPI Backend (
backend/app.py) - RESTful API server with CORS - RAG System (
backend/rag_system.py) - Main orchestrator - AI Generator (
backend/ai_generator.py) - Claude API integration with tool calling - Search Tools (
backend/search_tools.py) - Tool-based semantic search - Vector Store (
backend/vector_store.py) - ChromaDB integration
Tool-Based AI Architecture:
- AI receives tool definitions and decides when to use them
CourseSearchToolperforms semantic search only when needed- Two-stage Claude API calls: tool decision → tool execution → final response
Session Management:
- Conversation history maintained per session (
backend/session_manager.py) - Sessions created automatically, limited message history (configurable)
Document Processing Pipeline:
DocumentProcessorchunks course materials with sentence-based splittingCourse,Lesson,CourseChunkmodels structure the data- ChromaDB stores both metadata and content chunks separately
Configuration System:
- Centralized config in
backend/config.py - Environment variable support via python-dotenv
- Configurable chunk sizes, embedding models, conversation history
Frontend-Backend Communication:
/api/query- POST endpoint for user queries, returns{answer, sources, session_id}/api/courses- GET endpoint for course analytics- Session persistence maintained through
session_id
AI-Search Integration:
ToolManagerregisters available tools for Claudesearch_course_contenttool performs vector similarity search- Sources tracked automatically and returned to UI
Vector Search Chain:
- Query → ChromaDB semantic search → sentence-transformers embedding
- Results formatted with course/lesson context
- Supports course name and lesson number filtering
Core Models (backend/models.py):
Course- Full course with lessons and metadataLesson- Individual lesson with number and titleCourseChunk- Text chunks for vector storage with course/lesson context
Search Results (backend/vector_store.py):
SearchResultsdataclass wraps ChromaDB responses- Handles empty results and error states
Required .env file:
ANTHROPIC_API_KEY=your_api_key_here
Data Location:
- Course documents:
docs/folder (TXT/PDF/DOCX supported) - Vector database:
./chroma_db(auto-created) - Documents loaded automatically on server startup
Single Page Application:
- Pure HTML/CSS/JS (no framework)
- Markdown rendering for AI responses with
marked.js - Real-time course statistics display
- Session-based conversation continuity
Key Features:
- Auto-scrolling chat interface
- Collapsible sources display
- Loading states and error handling
- Suggested questions for user guidance
- always use uv to manage python packages, do not use pip directly
- don't run the server using ./run.sh I will start it myself
- use uv add to add requirements to pyproject.toml this way pyproject.toml and uv.lock will remain in sync, don't directly edit these files, instead use the relevant uv commands such as uv add
- claude-history i populated by another agent and it stores Claude Code chat history with a hook, DO NOT UPDATE, READ or do anything with claude-history and its contents, they are managed by another agent, you can always commit the claude-history files if they appear in the staged area don't worry about that