Skip to content

gauravxdev/CodeReviewAgent

Repository files navigation

πŸ€– AI Agent Code Review

An advanced AI-powered code review platform that leverages Google Gemini 1.5 Pro to provide comprehensive code analysis. Built with modern web technologies for developers who want to improve code quality, catch bugs early, and follow best practices.

AI Code Review Banner Next.js TypeScript Convex

✨ Features

πŸš€ Core Functionality

  • GitHub Integration - Fetch and analyze any public repository
  • AI-Powered Reviews - Google Gemini 1.5 Pro provides expert-level feedback
  • Interactive Code Viewer - Syntax highlighting with clickable line comments
  • Real-time Processing - Instant analysis without database dependencies
  • Smart Caching - 7-day localStorage cache for faster re-visits

🎨 User Experience

  • Responsive Design - Works seamlessly on desktop, tablet, and mobile
  • Dark/Light Mode - Automatic theme detection with manual toggle
  • Smooth Animations - Framer Motion powered transitions
  • 3D Visual Effects - Interactive background elements

πŸ”§ Developer Features

  • Multiple AI Models - Fallback system ensures reliability
  • TypeScript First - Full type safety throughout the application
  • Component Library - Reusable UI components built on Radix UI
  • Modern Architecture - Next.js 15 with App Router

πŸ›  Tech Stack

Frontend Architecture

Backend & AI

UI Components

πŸš€ Quick Start

Prerequisites

Installation

  1. Clone and install

    git clone https://github.com/gauravxdev/CodeReviewAgent.git
    cd ai-agent-code-review
    npm install
  2. Set up environment variables

    # Create .env.local
    GOOGLE_GENERATIVE_AI_API_KEY=your_gemini_api_key_here
  3. Initialize Convex backend

    npx convex dev
  4. Start development server

    npm run dev
  5. Open your browser Navigate to http://localhost:3000

πŸ“± How It Works

1. Repository Input (/code)

  • Enter any GitHub repository URL (e.g., facebook/react)
  • Supports both full URLs and owner/repo format
  • Smart filtering excludes large files and config directories
  • Files cached locally for 7 days

2. Code Analysis (/codereview)

  • Three-panel interface: File list | Code viewer | AI review
  • Resizable panels for optimal viewing
  • Interactive highlighting - click on highlighted lines for detailed feedback
  • Syntax highlighting for 20+ programming languages

3. AI Processing

  • Primary: Google Gemini 1.5 Pro for comprehensive analysis
  • Fallback: Pattern-based review system for reliability
  • Real-time: No database storage, instant results
  • Smart prompting: Context-aware analysis based on file type

πŸ— Architecture Overview

graph TB
    A[πŸ‘€ User] --> B[🌐 Next.js Frontend]
    B --> C[πŸ“± GitHub API]
    B --> D[⚑ Convex Backend]
    D --> E[πŸ€– Google Gemini AI]
    
    B --> F[πŸ’Ύ Local Storage]
    F --> G[πŸ“… 7-day Cache]
    
    D --> H[πŸ”„ Fallback System]
    
    subgraph "🎨 Frontend Features"
        I[πŸ“₯ Repository Fetcher]
        J[πŸ‘οΈ Code Viewer]
        K[πŸ“Š Review Display]
        L[⚑ Interactive UI]
    end
    
    B --> I
    B --> J
    B --> K
    B --> L
Loading

πŸ“ Project Structure

ai-agent-code-review/
β”œβ”€β”€ πŸ“± app/                       # Next.js App Router
β”‚   β”œβ”€β”€ πŸ”Œ api/                   # API endpoints
β”‚   β”œβ”€β”€ πŸ“ code/page.tsx          # Repository input
β”‚   β”œβ”€β”€ πŸ” codereview/page.tsx    # Review interface
β”‚   └── 🏠 page.tsx               # Landing page
β”œβ”€β”€ 🧩 components/                # React components
β”‚   β”œβ”€β”€ 🎨 ui/                    # Reusable UI library
β”‚   β”œβ”€β”€ πŸ“„ code-review.tsx        # Review display
β”‚   β”œβ”€β”€ πŸ‘οΈ file-content.tsx       # Code viewer
β”‚   └── πŸ–₯️ review-client.tsx      # Main interface
β”œβ”€β”€ ⚑ convex/                    # Backend functions
β”‚   β”œβ”€β”€ πŸ€– agent.ts               # AI integration
β”‚   └── πŸ”„ fallbackReview.ts      # Backup system
└── 🎨 components/ui/             # Component library
    β”œβ”€β”€ πŸ”˜ button.tsx             # Button variants
    β”œβ”€β”€ πŸ“‹ card.tsx               # Card layouts
    └── πŸ’¬ dialog.tsx             # Modal dialogs

πŸš€ Development

Available Commands

# Development
npm run dev          # Start dev server with Turbopack
npx convex dev       # Start Convex backend

# Production
npm run build        # Build for production
npm run start        # Start production server

# Code Quality
npm run lint         # Run ESLint

Adding Features

  1. UI Components β†’ components/ui/
  2. Feature Components β†’ components/
  3. API Routes β†’ app/api/
  4. Backend Logic β†’ convex/
  5. New Pages β†’ app/

Code Style

  • TypeScript strict mode with explicit typing
  • ESLint with Next.js and TypeScript rules
  • Tailwind CSS for styling with custom design tokens
  • Path aliases using @/ prefix
  • Functional components with hooks

πŸ”§ Configuration

Environment Variables

# Required
CONVEX_DEPLOYMENT=your-convex-deployment-url
NEXT_PUBLIC_CONVEX_URL=https://your-convex-url.convex.cloud
GOOGLE_GENERATIVE_AI_API_KEY=your-google-gemini-api-key
GEMINI_API_KEY=your-gemini-api-key
NEXT_PUBLIC_GITHUB_TOKEN=your-github-token
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=your-clerk-publishable-key
CLERK_SECRET_KEY=your-clerk-secret-key

Supported Languages

The AI can review code in 20+ languages including:

  • JavaScript/TypeScript
  • Python, Java, C++
  • Go, Rust, Swift
  • HTML/CSS, SQL
  • And many more...

πŸš€ Deployment

Vercel (Recommended)

Deploy with Vercel

  1. Connect your GitHub repository
  2. Add environment variables
  3. Deploy automatically

Other Platforms

  • Netlify: Build command npm run build, publish .next
  • Railway: Add GOOGLE_GENERATIVE_AI_API_KEY
  • Self-hosted: Use npm run build && npm start

Don't forget to deploy your Convex backend:

npx convex deploy

🀝 Contributing

We welcome contributions! Here's how to get started:

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Make your changes following the code style guidelines
  4. Test thoroughly with npm run build
  5. Submit a pull request

Development Guidelines

  • Follow TypeScript strict mode
  • Add proper type definitions
  • Include JSDoc comments for complex functions
  • Test on multiple screen sizes
  • Ensure accessibility compliance

πŸ“– Documentation

πŸ› Troubleshooting

Common Issues

API Key Problems

# Verify your environment variables
echo $GOOGLE_GENERATIVE_AI_API_KEY

Convex Connection Issues

# Restart Convex development server
npx convex dev --clear

Build Errors

# Check TypeScript errors
npm run build
# Fix linting issues
npm run lint

πŸ“„ License

This project is licensed under the MIT License. See LICENSE for details.

πŸ™ Acknowledgments

  • Google AI for the Gemini API
  • Convex for the amazing backend platform
  • Vercel for Next.js and deployment
  • Radix UI for accessible components
  • Tailwind CSS for the styling system

πŸ“ž Support

  • πŸ› Bug Reports: GitHub Issues
  • πŸ“§ Contact: Open an issue for support

Made with ❀️ for developers who care about code quality

⭐ Star this repo if you find it helpful!

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •