Projects / AI/ML / 2024
CodeSage AI - Review Assistant
LLM-Powered Code Analysis
50+ PRs Analyzed
15 detected Vulnerabilities
<2s Response Time
85% RAG Precision
10K+ indexed Code Files
Claude + GPT-4 LLMs
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.
Implementation
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.
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
Features
- RAG architecture with pgvector semantic code search
- Claude 3.5 Sonnet + GPT-4 Turbo LLM integration
- Real-time streaming responses via Server-Sent Events
- GitHub webhook integration for automated PR analysis
- Security vulnerability detection (SQL injection, XSS, auth issues)
- Code smell detection (complexity, duplication, naming)
- Automated refactoring suggestions with diff generation
- Vector embeddings using sentence-transformers
- Custom coding standards validation
- Interactive dashboard built with React 18 + TypeScript
- LangChain for LLM orchestration and prompt templating
- Cost optimization via intelligent caching and batching
Results
- 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
Technologies
- Python 3.11+
- FastAPI 0.109
- Anthropic Claude 3.5 API
- OpenAI GPT-4 Turbo
- PostgreSQL 16 + pgvector
- Redis 7.2
- React 18
- TypeScript 5.x
- Docker 24.0
- LangChain
- sentence-transformers
- GitHub Webhooks
- Prometheus + Grafana
- OpenTelemetry