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
77 changes: 77 additions & 0 deletions .github/workflows/claude-code-review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Claude Code Review

on:
pull_request:
types: [opened, synchronize]
# Optional: Only run on specific file changes
# paths:
# - "src/**/*.ts"
# - "src/**/*.tsx"
# - "src/**/*.js"
# - "src/**/*.jsx"

jobs:
claude-review:
# Optional: Filter by PR author
# if: |
# github.event.pull_request.user.login == 'external-contributor' ||
# github.event.pull_request.user.login == 'new-developer' ||
# github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR'

runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
issues: read
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Run Claude Code Review
id: claude-review
uses: anthropics/claude-code-action@beta
with:
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}

# Optional: Specify model (defaults to Claude Sonnet 4, uncomment for Claude Opus 4.1)
# model: "claude-opus-4-1-20250805"

# Direct prompt for automated review (no @claude mention needed)
direct_prompt: |
Please review this pull request and provide feedback on:
- Code quality and best practices
- Potential bugs or issues
- Performance considerations
- Security concerns
- Test coverage

Be constructive and helpful in your feedback.

# Optional: Use sticky comments to make Claude reuse the same comment on subsequent pushes to the same PR
# use_sticky_comment: true

# Optional: Customize review based on file types
# direct_prompt: |
# Review this PR focusing on:
# - For TypeScript files: Type safety and proper interface usage
# - For API endpoints: Security, input validation, and error handling
# - For React components: Performance, accessibility, and best practices
# - For tests: Coverage, edge cases, and test quality

# Optional: Different prompts for different authors
# direct_prompt: |
# ${{ github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR' &&
# 'Welcome! Please review this PR from a first-time contributor. Be encouraging and provide detailed explanations for any suggestions.' ||
# 'Please provide a thorough code review focusing on our coding standards and best practices.' }}

# Optional: Add specific tools for running tests or linting
# allowed_tools: "Bash(npm run test),Bash(npm run lint),Bash(npm run typecheck)"

# Optional: Skip review for certain conditions
# if: |
# !contains(github.event.pull_request.title, '[skip-review]') &&
# !contains(github.event.pull_request.title, '[WIP]')
56 changes: 56 additions & 0 deletions .github/workflows/claude-mentions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Claude Mentions Handler

on:
issue_comment:
types: [created]
pull_request_review_comment:
types: [created]
issues:
types: [opened]
pull_request:
types: [opened]

jobs:
claude-mention:
# Only run if the comment mentions @claude
if: |
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
(github.event_name == 'issues' && contains(github.event.issue.body, '@claude')) ||
(github.event_name == 'pull_request' && contains(github.event.pull_request.body, '@claude'))

runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
issues: write
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Respond to Claude mention
id: claude-response
uses: anthropics/claude-code-action@beta
with:
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}

# Optional: Specify model (defaults to Claude Sonnet 4, uncomment for Claude Opus 4.1)
# model: "claude-opus-4-1-20250805"

# Enable interactive mode for mentions
mention_mode: true

# Optional: Allow Claude to use specific tools when responding
# allowed_tools: "Read,Grep,Bash(ls),Bash(cat)"

# Optional: Custom system prompt for mentions
system_prompt: |
You are Claude, an AI assistant helping with code and technical questions.
When mentioned with @claude, respond helpfully to the user's question or request.
Be concise but thorough in your responses.
If asked to review code, provide constructive feedback.
If asked technical questions, provide clear explanations with examples when helpful.
64 changes: 64 additions & 0 deletions .github/workflows/claude.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Claude Code

on:
issue_comment:
types: [created]
pull_request_review_comment:
types: [created]
issues:
types: [opened, assigned]
pull_request_review:
types: [submitted]

jobs:
claude:
if: |
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
issues: read
id-token: write
actions: read # Required for Claude to read CI results on PRs
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Run Claude Code
id: claude
uses: anthropics/claude-code-action@beta
with:
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}

# This is an optional setting that allows Claude to read CI results on PRs
additional_permissions: |
actions: read

# Optional: Specify model (defaults to Claude Sonnet 4, uncomment for Claude Opus 4.1)
# model: "claude-opus-4-1-20250805"

# Optional: Customize the trigger phrase (default: @claude)
# trigger_phrase: "/claude"

# Optional: Trigger when specific user is assigned to an issue
# assignee_trigger: "claude-bot"

# Optional: Allow Claude to run specific commands
# allowed_tools: "Bash(npm install),Bash(npm run build),Bash(npm run test:*),Bash(npm run lint:*)"

# Optional: Add custom instructions for Claude to customize its behavior for your project
# custom_instructions: |
# Follow our coding standards
# Ensure all new code has tests
# Use TypeScript for new files

# Optional: Custom environment variables for Claude
# claude_env: |
# NODE_ENV: test

96 changes: 96 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# CLAUDE.md

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

## Essential Commands

### Development Setup
```bash
# Install dependencies
uv sync

# Add new dependencies
uv add package_name

# Set up environment variables
cp .env.example .env
# Edit .env to add your ANTHROPIC_API_KEY
```

### Running the Application
```bash
# Quick start (recommended)
chmod +x run.sh
./run.sh

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

### Development Commands
```bash
# Run from backend directory
cd backend && uv run uvicorn app:app --reload --port 8000

# Test API endpoints directly
curl http://localhost:8000/api/courses
curl -X POST http://localhost:8000/api/query -H "Content-Type: application/json" -d '{"query":"your question here"}'
```

## Architecture Overview

This is a **RAG (Retrieval-Augmented Generation) System** with a three-layer architecture:

### Core RAG Pipeline
1. **Document Processing**: Course transcripts → chunked text with metadata
2. **Vector Storage**: ChromaDB stores embeddings for semantic search
3. **AI Generation**: Claude API generates contextual responses using retrieved content
4. **Tool Integration**: AI can dynamically search the knowledge base using tools

### Key Components

**RAGSystem (`rag_system.py`)** - Central orchestrator that coordinates:
- Document processing and chunking
- Vector storage operations
- AI response generation with tool access
- Session management for conversation history

**Tool-Based Search Architecture** - The system uses a tool-based approach where:
- `ToolManager` registers and manages available tools
- `CourseSearchTool` performs content searches within course materials
- `CourseOutlineTool` retrieves complete course structures with lesson lists
- Claude API calls tools dynamically during response generation
- Tools return sources that are tracked and returned to frontend with links

**Data Models** (`models.py`):
- `Course`: Contains title, instructor, lessons list
- `CourseChunk`: Text chunks with course/lesson metadata for vector storage
- `Lesson`: Individual lessons with titles and optional links

### Configuration (`config.py`)
Key settings:
- `CHUNK_SIZE: 800` - Text chunk size for vector storage
- `CHUNK_OVERLAP: 100` - Overlap between chunks
- `MAX_RESULTS: 5` - Vector search result limit
- `MAX_HISTORY: 2` - Conversation memory depth

### Data Flow
1. Course documents in `docs/` are processed into `CourseChunk` objects
2. Chunks are embedded and stored in ChromaDB (`./chroma_db/`)
3. User queries trigger tool-based searches via Claude API
4. Retrieved chunks provide context for AI response generation
5. Session history maintains conversation continuity

### Frontend Integration
- FastAPI serves both API endpoints (`/api/*`) and static frontend files
- Frontend communicates via `/api/query` for chat and `/api/courses` for statistics
- CORS configured for development with live reload support

## Environment Requirements

Required environment variable:
```
ANTHROPIC_API_KEY=your_anthropic_api_key_here
```

The system expects course documents in `docs/` folder as `.txt`, `.pdf`, or `.docx` files.
Loading