An intelligent automated code review system that integrates with GitHub to analyze pull request changes using AI and post inline review comments.
PR opened/synchronized
│
▼
GitHub Webhook
│
▼
processPR() ──► fetch PR files via GitHub App installation token
│
▼
parseDiff() ──► extract added lines per file
│
▼
reviewCode() ──► Groq (Llama 3.3 70B) code review
│
▼
postGitHubReview() ──► inline comments on PR
│
▼
store Review + Issues in PostgreSQL (Prisma)
- GitHub App integration — authenticates via JWT and installation tokens; no PAT required
- Webhook-driven — reviews PRs automatically on
openedandsynchronizeevents - AI-powered reviews — uses Llama 3.3 70B via Groq to identify bugs, warnings, and suggestions
- Inline PR comments — posts specific, line-level review comments on GitHub
- Review dashboard — tracks total reviews, issues found, and bugs caught per user
- Persistent storage — all reviews and issues are stored in PostgreSQL via Prisma
- Framework: Next.js 16 (App Router)
- Language: React 19
- AI: Groq SDK —
llama-3.3-70b-versatile - Database ORM: Prisma
- Database: PostgreSQL
- Auth: NextAuth.js (GitHub OAuth + GitHub App tokens)
- UI: Tailwind CSS + shadcn/ui (Radix UI)
- Client: jsonwebtoken (GitHub App JWT signing)
- Node.js >= 18
- PostgreSQL
- A GitHub App with:
- Permissions: Pull requests (Read & Write), Commit statuses (Read), Contents (Read), Metadata (Read)
- Events: Pull request, Installation
- A Groq API key
- A GitHub Personal Access Token (PAT) with
reposcope (used as fallback for posting reviews)
git clone <repo-url>
cd ai-code-reviewer
npm installnpx prisma migrate dev --name initCreate a .env file at the project root:
DATABASE_URL=postgresql://user:password@localhost:5432/ai_code_reviewer
GITHUB_CLIENT_ID=your_github_oauth_client_id
GITHUB_CLIENT_SECRET=your_github_oauth_client_secret
GITHUB_APP_ID=your_github_app_id
GITHUB_APP_PRIVATE_KEY_BASE64=base64_encoded_app_private_key
GITHUB_PAT=your_github_personal_access_token
GROQ_API_KEY=your_groq_api_key
NEXTAUTH_URL=http://localhost:3000
NEXTAUTH_SECRET=your_nextauth_secret
AUTH_SECRET=your_auth_secret
GITHUB_WEBHOOK_SECRET=your_webhook_secret
AUTH_GROQ_API_KEY=your_app_owner_groq_keynpm run devVisit http://localhost:3000.
app/
api/
auth/[...nextauth]/route.js — NextAuth GitHub OAuth handler
webhook/github/route.js — GitHub webhook receiver (PR events)
dashboard/page.js — User review dashboard
page.js — Landing page
lib/
db.js — Prisma client singleton
github.js — GitHub App JWT, installation tokens, PR file fetch, review posting
parseDiff.js — Unified diff parser, extracts added lines
aiReview.js — Groq LLM code review logic
postReview.js — Post review comments to GitHub via PAT
prisma/
schema.prisma — User, Installation, Review, Issue models
- Deploy to any Node.js host (Vercel, Railway, Render, Fly.io)
- Ensure
NEXTAUTH_URLpoints to your production domain - Configure GitHub App webhooks to point to
https://your-app.com/api/webhook/github - Expose via tunnel (e.g., ngrok) during local development:
npx ngrok http 3000MIT