A Retrieval-Augmented Generation (RAG) system designed to answer questions about course materials using semantic search and AI-powered responses. This is a full-stack web application that enables users to query course materials and receive intelligent, context-aware responses using ChromaDB for vector storage and Anthropic's Claude for AI generation.
The application consists of both frontend and backend components:
Backend (Python/FastAPI):
app.py: Main FastAPI application with API routes and static file servingrag_system.py: Main orchestrator coordinating document processing, vector storage, and AI responsesvector_store.py: ChromaDB-based vector storage with dual collections (course catalog and content)ai_generator.py: Anthropic Claude API integration with tool-based search capabilitiesdocument_processor.py: Handles document ingestion and chunkingsearch_tools.py: Implements tool-based search systemsession_manager.py: Manages conversation history
Frontend (HTML/CSS/JS):
- Single-page application with chat interface
- Real-time course statistics display
- Markdown rendering for AI responses
- Responsive design with sidebar for course information
- Backend: Python 3.13+, FastAPI, Uvicorn
- Frontend: HTML, CSS, JavaScript (ES6)
- AI Service: Anthropic Claude (claude-sonnet-4-20250514)
- Vector Store: ChromaDB
- Embeddings: Sentence Transformers (all-MiniLM-L6-v2)
- Package Manager: uv
- Testing: pytest
- Python 3.13 or higher
- uv (Python package manager)
- Anthropic API key
-
Install uv:
curl -LsSf https://astral.sh/uv/install.sh | sh -
Install dependencies:
uv sync
-
Set up environment: Create a
.envfile in the root directory:ANTHROPIC_API_KEY=your_anthropic_api_key_here
Quick Start:
chmod +x run.sh
./run.shManual Start:
cd 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
Run all tests:
uv run pytestRun specific test markers:
uv run pytest -m "unit"- Python follows Black formatting with 88-character line length and 4-space indentation
- Use snake_case for Python modules/functions and PascalCase for classes
- Frontend JavaScript uses camelCase helpers and ES6 style
- CSS selectors use kebab-case
- Maintain full type annotations throughout codebase
backend/: FastAPI service with modules for rag_system, vector_store, document processing, etc.frontend/: Static client files (index.html, script.js, style.css)docs/: Course material documents for the RAG systembackend/tests/: Pytest suites following naming conventiontest_*.pyscripts/: Utility scripts for formatting, linting, and other automation
- Use
isortwith Black profile for organizing imports - Group first-party modules under
backend
- Use pytest markers:
@pytest.mark.unit,integration,api,slow - Mock external services (Anthropic, Chroma) for deterministic test runs
- Place new tests in
backend/testsdirectory withtest_*.pynaming
- Write short, imperative commit messages focused on one change set
- Separate concerns like dependency updates or static asset changes into individual commits
- Include behavior summary and linked issues in PRs
- Run
./scripts/lint.shanduv run pytestbefore submitting changes
- Store secrets in an untracked
.envfile - Configuration managed through
backend/config.pydataclass - Document new configuration flags in both config.py defaults and README
Install development dependencies:
uv sync --group devFormat code (modifies files):
./scripts/format.shLint code (read-only):
./scripts/lint.sh- Course documents (PDF, DOCX, TXT) in
docs/directory are loaded on startup - DocumentProcessor chunks content and extracts course metadata
- VectorStore stores metadata and content in separate ChromaDB collections
- User queries trigger AI generation with access to search tools
- AI uses CourseSearchTool to find relevant content and generates responses
- Frontend displays responses with source attribution