- What is AI Agent Code Review?
- Tech Stack Overview
- Getting Started
- Application Architecture
- Features Deep Dive
- File Structure Guide
- API Reference
- Component Library
- Development Workflow
- Deployment Guide
AI Agent Code Review is a modern web application that provides automated code reviews using Google's Gemini AI. It helps developers improve code quality by analyzing GitHub repositories and providing detailed feedback on:
- Code Quality - Organization, readability, maintainability
- Bug Detection - Logic errors, edge cases, runtime issues
- Performance - Bottlenecks and optimization opportunities
- Security - Vulnerabilities and best practices
- Best Practices - Language-specific recommendations
- GitHub Integration - Fetch any public repository
- AI-Powered Analysis - Google Gemini 1.5 Pro model
- Interactive UI - Click on highlighted lines for detailed feedback
- Real-time Processing - No database needed, instant results
- Responsive Design - Works on all devices
- Dark/Light Mode - System preference detection
- Next.js 15 - React framework with App Router
- React 19 - Latest React features
- TypeScript - Type safety and developer experience
- Tailwind CSS - Utility-first styling
- Framer Motion - Smooth animations
- Radix UI - Accessible component primitives
- Convex - Real-time backend platform
- Google Gemini AI - Advanced language model
- GitHub API - Repository data fetching
- Zod - Runtime type validation
- ESLint - Code linting
- Turbopack - Fast development builds
- TypeScript - Static type checking
- Node.js 18+ (LTS recommended)
- Google Gemini API Key (Get one here)
- Convex Account (Sign up here)
-
Clone the Repository
git clone https://github.com/IsmartGaurav/CodeReviewAgent cd CodeReviewAgent -
Install Dependencies
npm install
-
Set Up Environment Variables
# Create .env.local file GOOGLE_GENERATIVE_AI_API_KEY=your_gemini_api_key # Alternative key name also supported: # GEMINI_API_KEY=your_gemini_api_key
-
Initialize Convex
npx convex dev
This will:
- Create a new Convex project (if first time)
- Generate Convex configuration
- Start the development server
-
Start Development Server
npm run dev
-
Open Application Navigate to
http://localhost:3000
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 Review]
subgraph "Frontend Features"
I[Repository Fetcher]
J[Code Viewer]
K[Review Display]
L[Interactive UI]
end
B --> I
B --> J
B --> K
B --> L
- Repository Input - User enters GitHub URL
- GitHub Fetch - API retrieves repository files
- Local Caching - Files stored for 7 days
- AI Processing - Convex sends code to Gemini
- Review Display - Interactive results with line highlighting
// Located in: app/code/page.tsx- Input Formats:
github.com/owner/repoowner/repo
- File Filtering: Excludes large files, configs, node_modules
- Smart Caching: 7-day localStorage persistence
- Progress Tracking: Real-time fetch status
// Located in: app/codereview/page.tsx- 3-Panel Layout: Files | Code Viewer | Review Panel
- Resizable Panels: Drag to adjust widths
- Syntax Highlighting: Language-specific coloring
- Interactive Lines: Click highlighted lines for details
// Located in: convex/agent.ts- Primary AI: Google Gemini 1.5 Pro
- Fallback System: Basic pattern-based reviews
- Real-time Processing: No database storage
- Error Handling: Graceful degradation
- Hero Grid: 3D animated background
- Particle System: Mouse-interactive effects
- Smooth Animations: Framer Motion powered
- Theme System: Auto-detecting dark/light mode
ai-agent-code-review/
βββ app/ # Next.js App Router
β βββ api/ # API Routes
β β βββ files/route.ts # File handling (client storage)
β β βββ review/route.ts # Gemini AI integration
β βββ code/page.tsx # Repository input page
β βββ codereview/page.tsx # Review interface
β βββ layout.tsx # Root layout
β βββ page.tsx # Landing page
β βββ globals.css # Global styles
βββ components/ # React Components
β βββ ui/ # Reusable UI components
β β βββ button.tsx # Button variants
β β βββ card.tsx # Card layouts
β β βββ dialog.tsx # Modal dialogs
β β βββ ... # Other UI primitives
β βββ code-review.tsx # Review display
β βββ file-content.tsx # Code viewer
β βββ navbar.tsx # Navigation
β βββ review-client.tsx # Main review interface
β βββ ... # Feature components
βββ convex/ # Backend Functions
β βββ agent.ts # AI integration
β βββ fallbackReview.ts # Fallback logic
β βββ convex.config.ts # Convex setup
βββ lib/ # Utilities
β βββ utils.ts # Helper functions
βββ public/ # Static assets
βββ fonts/ # Geist font family
βββ *.svg # Icons and graphics
// GitHub API Integration
const fetchRepository = async (owner: string, repo: string) => {
const response = await fetch(`https://api.github.com/repos/${owner}/${repo}/contents`);
// Recursive file fetching with filtering
};// POST /api/review
{
"filename": "example.tsx",
"code": "const component = () => { return <div>Hello</div>; };"
}
// Response
{
"review": "# Code Review for example.tsx\n\n## Overview...",
"isFallback": false
}// convex/agent.ts
export const createCodeReviewThread = action({
args: { prompt: v.string(), code: v.string() },
handler: async (ctx, args) => {
// Gemini AI integration
const result = await thread.generateText({
prompt: `${prompt}\n\nCode:\n\`\`\`\n${code}\n\`\`\``
});
return { threadId, text: result.text };
}
});// Variants: default, destructive, outline, secondary, ghost, link
// Sizes: default, sm, lg, icon
<Button variant="default" size="lg">Get Started</Button><Card>
<CardHeader>
<CardTitle>File Content</CardTitle>
</CardHeader>
<CardContent>
{/* Content here */}
</CardContent>
</Card><Dialog open={showDialog} onOpenChange={setShowDialog}>
<DialogContent>
<DialogHeader>
<DialogTitle>Line Details</DialogTitle>
</DialogHeader>
{/* Dialog content */}
</DialogContent>
</Dialog>// components/file-content.tsx
<FileContent
selectedFile="example.tsx"
fileContent={code}
highlightedLines={[1, 5, 10]}
lineComments={{ 1: "This line has an issue" }}
onLineClick={(line, e) => showDetails(line)}
/>// components/code-review.tsx
<CodeReview
review={aiReview}
isLoading={false}
onRefresh={() => triggerNewReview()}
/># Start development
npm run dev # Next.js dev server
npx convex dev # Convex backend
# Code quality
npm run lint # ESLint checking
npm run build # Production build- UI Components: Create in
components/ui/ - Feature Components: Create in
components/ - API Routes: Add to
app/api/ - Backend Functions: Add to
convex/ - Pages: Add to
app/
- TypeScript: Strict typing required
- Imports: Use
@/path aliases - Components: Functional with explicit interfaces
- Styling: Tailwind CSS classes
- State: React hooks for local state
# Production environment
GOOGLE_GENERATIVE_AI_API_KEY=your_api_key
CONVEX_DEPLOYMENT=your_convex_deployment_url- Connect GitHub repository
- Add environment variables
- Deploy automatically on push
- Build command:
npm run build - Publish directory:
.next - Add environment variables
npm run build # Build for production
npm start # Start production servernpx convex deploy # Deploy backend functions-
API Key Errors
- Verify
GOOGLE_GENERATIVE_AI_API_KEYis set - Check API key permissions
- Verify
-
Convex Connection
- Run
npx convex devfirst - Check Convex dashboard for errors
- Run
-
GitHub Rate Limits
- Use authenticated requests for higher limits
- Implement caching (already included)
-
Build Errors
- Check TypeScript errors:
npm run build - Verify all imports are correct
- Check TypeScript errors:
- Documentation: Next.js Docs
- Convex: Convex Docs
- GitHub Issues: Report bugs in the repository
- Customize AI Prompts: Modify
convex/agent.ts - Add New Languages: Extend language detection
- Enhanced UI: Add more interactive features
- Analytics: Track usage patterns
- User Accounts: Add authentication
- Team Features: Collaborative reviews
Happy Coding! π This guide should get you started with AI Agent Code Review. For more advanced customization, dive into the source code and explore the component implementations.