Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .claude/commands/implement-feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
You will be implementing a new feature in this codebase
$ARGUMENTS

IMPORTANT: Only do this for front-end features,
Once this feature is built, make sure to write the changes you made to file called frontend-changes
Do not ask for persmissions to modify this file, assume you can always do it
2 changes: 0 additions & 2 deletions .env.example

This file was deleted.

Binary file added .playwright-mcp/current-chat-button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .playwright-mcp/final-chat-button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .playwright-mcp/updated-chat-button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
83 changes: 83 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Development Commands

### Running the Application

```bash
# Quick start using the provided script
./run.sh

# Manual start (from backend directory)
cd backend && uv run uvicorn app:app --reload --port 8000
```

### Package Management

```bash
# Install dependencies
uv sync

# Add new dependencies
uv add <package-name>
```

### Environment Setup

Create `.env` file in root directory with:

```env
ANTHROPIC_API_KEY=your_api_key_here
```

## Architecture Overview

This is a **Retrieval-Augmented Generation (RAG) chatbot** system that answers questions about course materials using semantic search and AI generation.

### Core Components

**Backend Architecture (`/backend/`):**

- `app.py` - FastAPI server with CORS, serves frontend static files, provides `/api/query` and `/api/courses` endpoints
- `rag_system.py` - Main orchestrator that coordinates all components
- `vector_store.py` - ChromaDB wrapper for vector storage and semantic search
- `ai_generator.py` - Anthropic Claude API wrapper with tool support
- `document_processor.py` - Processes course documents into chunks
- `search_tools.py` - Tool-based search system for Claude AI
- `session_manager.py` - Manages conversation history
- `models.py` - Data models for Course, Lesson, CourseChunk
- `config.py` - Configuration settings loaded from environment

**Frontend (`/frontend/`):**

- Static HTML/CSS/JS files served by FastAPI
- Web interface for chatbot interactions

### Data Flow

1. Documents in `/docs/` are processed into chunks and stored in ChromaDB
2. User queries hit `/api/query` endpoint
3. RAGSystem uses AI with search tools to find relevant content
4. Claude generates responses using retrieved context
5. Session manager maintains conversation history

### Key Technical Details

- Uses **ChromaDB** for vector storage with `all-MiniLM-L6-v2` embeddings
- **Anthropic Claude Sonnet 4** model with function calling for search tools
- Document chunking: 800 characters with 100 character overlap
- Supports PDF, DOCX, and TXT documents
- Session-based conversation history (max 2 exchanges)
- Tool-based search approach rather than direct RAG retrieval

### Configuration

Key settings in `config.py`:

- `CHUNK_SIZE`: 800 (document chunk size)
- `CHUNK_OVERLAP`: 100 (overlap between chunks)
- `MAX_RESULTS`: 5 (search results returned)
- `MAX_HISTORY`: 2 (conversation exchanges remembered)
- `CHROMA_PATH`: "./chroma_db" (vector database location)
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ A Retrieval-Augmented Generation (RAG) system designed to answer questions about

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.


## Prerequisites

- Python 3.13 or higher
Expand All @@ -17,27 +16,31 @@ This application is a full-stack web application that enables users to query cou
## Installation

1. **Install uv** (if not already installed)

```bash
curl -LsSf https://astral.sh/uv/install.sh | sh
```

2. **Install Python dependencies**

```bash
uv sync
```

3. **Set up environment variables**

Create a `.env` file in the root directory:

```bash
ANTHROPIC_API_KEY=your_anthropic_api_key_here
ANTHROPIC_API_KEY=your_api_key_here
```

## Running the Application

### Quick Start

Use the provided shell script:

```bash
chmod +x run.sh
./run.sh
Expand All @@ -51,6 +54,6 @@ uv run uvicorn app:app --reload --port 8000
```

The application will be available at:

- Web Interface: `http://localhost:8000`
- API Documentation: `http://localhost:8000/docs`

36 changes: 36 additions & 0 deletions backend-tool-refactor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Refactor Sequential Tool Calling in @backend/ai.generator.py

Refactor @backend/ai.generator.py to support sequential tool calling where Claude can make upto 2 tool calls in separate API rounds.

Current behavior:

- Claude makes 1 tool call -> tools are removed from API params -> final response
- If Claude wants another tool call after seeing results, it can't (gets empty response)

Desired behavior:

- Each tool call should have a separate API request where Claude can reason about previous results
- Support for complex queries requiring multiple searches for comparison, multi-part questions, or when information from different courses/lessons is needed

Example flow:

1. User: "Search for a course that discusses the same topic as lesson 4 of course X"
2. Claude: get course outline for course X -> gets title of lesson 4
3. Claude uses the title to search for a course that discusses the same topic -> returns course information
4. Claude: provides complete answer

Requirements:

- Maximum 2 sequential rounds per user query
- Terminate when: (a) 2 rounds completed, (b) Claude's response has no tool_use blocks, or (c) tool call fails
- Preserve conversation context between rounds
- Handle tool execution errors gracefully

Notes:

-update the system prompt in @backend/ai_generator.py
-update test @backend/tests/test_ai_generator.py

- Write tests that verify the external behavior (API calls made, tools executed, results returned) rather than internal state details

Use two parallel subagents to brainstorm possible plans. Do not implement any code.
Loading