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
This section is written in ASD-STE100 (Simplified Technical English).
This system is a chatbot. It answers questions about course materials. It has a Python backend (FastAPI) and a web page (plain JavaScript).
| File | Function |
|---|---|
app.py |
Receives HTTP requests. Serves the web page. |
rag_system.py |
Controls the other parts. |
ai_generator.py |
Sends requests to Claude. |
search_tools.py |
Gives Claude a tool to search the courses. |
vector_store.py |
Stores and searches the course text (ChromaDB). |
document_processor.py |
Reads course files and splits them into chunks. |
session_manager.py |
Keeps the chat history in memory. |
config.py |
Holds all settings. |
You must start the server from the backend/ folder. The code uses relative paths.
- The browser sends the question to
POST /api/query. RAGSystemcreates a session if the request has none.AIGeneratorsends the question to Claude. The request includes the system prompt, the chat history, and the tool definitions.- Claude decides if it needs to search.
- If the question is general, Claude answers directly.
- If the question is about a course, Claude calls
search_course_content.
- If Claude calls the tool, the system runs the search in ChromaDB.
- The system sends the search results to Claude in a second request. This second request has no tools. Therefore, the system allows only one search for each question.
- Claude writes the final answer.
RAGSystemcollects the sources from the tool and sends the answer and sources to the browser.
ChromaDB has two collections. Both use the all-MiniLM-L6-v2 model to make embeddings.
course_catalog: One entry for each course. The ID is the course title. The system uses this collection to find the exact course name when a user types a partial name.course_content: Text chunks. Each chunk has the course title, the lesson number, and the chunk index.
When the server starts, it reads each file in the docs/ folder. The file format is:
Course Title: <title>
Course Link: <url>
Course Instructor: <name>
Lesson 0: <lesson title>
Lesson Link: <url>
<lesson text>
The system splits the text into chunks of 800 characters. Each chunk overlaps the previous chunk by 100 characters.
- The system skips a course if its title is already in the database. If you change a course file, delete
backend/chroma_dbto load it again. - Chat history is in memory only. The history is lost when the server stops.
- Claude can write at most 800 tokens in one answer.
- The system treats PDF and DOCX files as plain text. It does not parse them.
- Run
cd backend && uv run pytest testsfor the automated tests. They do not use the network. - Run
cd backend && uv run python live_checks.pyto check the real setup. Use this when you see "Query failed".