A Retrieval-Augmented Generation (RAG) system designed to answer questions about course materials using semantic search and AI-powered responses.
This application is a full-stack web application that enables users to query course materials and receive intelligent, context-aware responses. It uses ChromaDB for vector storage, Anthropic's Claude for AI generation, and provides a web interface for interaction.
- Python 3.13 or higher
- uv (Python package manager)
- An Anthropic API key (for Claude AI)
- For Windows: Use Git Bash to run the application commands - Download Git for Windows
-
Install uv (if not already installed)
curl -LsSf https://astral.sh/uv/install.sh | sh -
Install Python dependencies
uv sync
-
Set up environment variables
Create a
.envfile in the root directory:ANTHROPIC_API_KEY=your_anthropic_api_key_here
Use the provided shell script:
chmod +x run.sh
./run.shcd backend
uv run uvicorn app:app --reload --port 8000The application will be available at:
- Web Interface:
http://localhost:8000 - API Documentation:
http://localhost:8000/docs
graph TD
A["👤 User Frontend<br/>HTML/CSS/JavaScript"] -->|Enters Query| B["🌐 FastAPI Backend<br/>app.py"]
B -->|1. Route Query| C["RAGSystem<br/>Main Orchestrator"]
D["📚 Course Documents<br/>docs/ folder"] -->|Load & Process| E["DocumentProcessor<br/>Chunking & Preprocessing"]
E -->|Store Chunks| F["VectorStore<br/>ChromaDB"]
C -->|2. Search| F
F -->|3. Return Relevant Context| C
C -->|4. Add History| G["SessionManager<br/>Conversation Memory"]
G -->|5. Retrieve Chat History| C
C -->|6. Generate Response| H["AIGenerator<br/>Anthropic Claude API"]
H -->|7. Stream Response| C
C -->|8. Return JSON| B
B -->|Display Answer| A
style A fill:#e1f5ff
style B fill:#fff3e0
style C fill:#f3e5f5
style D fill:#e8f5e9
style E fill:#e8f5e9
style F fill:#fce4ec
style G fill:#f1f8e9
style H fill:#ede7f6
| Component | Purpose |
|---|---|
| RAGSystem | Orchestrates the entire query pipeline |
| DocumentProcessor | Chunks course materials into searchable segments |
| VectorStore | Stores embeddings in ChromaDB for semantic search |
| AIGenerator | Interfaces with Claude API for answer generation |
| SessionManager | Maintains conversation history for context |
| ToolManager | Abstracts search tools for flexible integration |
- User Query: User submits a question via the web interface
- Backend Processing: FastAPI routes the request to RAGSystem
- Semantic Search: VectorStore performs semantic search across stored chunks
- Context Retrieval: Relevant course materials are retrieved (max 5 results)
- Conversation History: SessionManager provides prior conversation context
- AI Generation: Claude processes query + context + history to generate answer
- Response: Answer is streamed back to frontend and displayed