CodeSage AI - Review Assistant
Claude + GPT-4 + RAG
Developed AI-powered code review assistant leveraging Large Language Models (Claude 3.5, GPT-4) with RAG architecture for codebase-aware suggestions. System integrates GitHub webhooks for automated PR analysis, uses pgvector for semantic code search, implements streaming responses for real-time feedback. RAG pipeline retrieves relevant code context from vector embeddings enabling LLM to provide accurate, project-specific recommendations. Detects security vulnerabilities, code smells, complexity issues, suggests refactorings with generated diffs.
The Challenge
Manual code reviews time-consuming and inconsistent. Static analysis tools generate noise without context understanding. Need intelligent assistant providing project-aware suggestions. LLMs without codebase context give generic advice. Security vulnerabilities and code smells hard to catch systematically.
The Solution
Built RAG-based code review assistant combining vector similarity search with LLM reasoning. Generated embeddings for codebase using sentence-transformers, stored in pgvector for semantic retrieval. Claude/GPT-4 API analyzes PRs with retrieved context. GitHub webhook integration triggers automated reviews. Streaming API responses for real-time feedback.
Technology Stack
Architecture
- RAG (Retrieval-Augmented Generation) with pgvector
- Vector embeddings via sentence-transformers
- Multi-stage pipeline: embedding → retrieval → LLM reasoning
- FastAPI async endpoints for webhook processing
- Redis 7.2 caching for embeddings and LLM responses
- PostgreSQL 16 + pgvector for semantic code search
- GitHub webhook integration for automated PR triggers
- Server-Sent Events for streaming responses
- LangChain for prompt orchestration and chaining
- Cost optimization via caching and batching
Key Features
Results & Impact
- RAG pipeline retrieves relevant code context with 85% precision
- Detected 15+ security vulnerabilities in test PRs (SQL injection, XSS, insecure auth)
- Automated analysis of 50+ PRs demonstrating production-ready architecture
- Streaming responses provide sub-2s initial feedback
- Vector similarity search identifies duplicate code patterns across 10K+ files
- Generated refactoring suggestions with diff patches for 20+ code smells
- pgvector semantic search outperforms keyword search 40% in relevance
- GitHub webhook integration enables fully automated PR review workflow