Code Fox is an intelligent, AI-powered code review assistant designed to streamline your development workflow. By connecting directly with your GitHub repositories, Code Fox automatically analyzes pull requests, providing instant, context-aware feedback to help maintain code quality and catch issues early.
- π€ AI-Powered Code Reviews: Leverages advanced LLMs (via Vercel AI SDK) to provide deep, meaningful code analysis on every PR.
- π§ RAG Context Awareness: Utilizes Pinecone and Retrieval-Augmented Generation (RAG) to understand the full context of your codebase, not just the diff.
- π Seamless GitHub Integration: Connects easily with your GitHub account to import repositories and monitor pull requests automatically.
- π Interactive Dashboard: A comprehensive overview of your repositories, review history, and coding activity.
- π³ Subscription Management: Integrated with Polar.sh for seamless subscription handling and usage limits.
- β‘ Real-time Updates: Powered by Inngest for reliable background job processing and event handling.
- Framework: Next.js 16 (App Router)
- Language: TypeScript
- Styling: Tailwind CSS v4
- UI Components: Radix UI, Lucide React, Shadcn UI
- Database: PostgreSQL (via Prisma ORM)
- Authentication: Better Auth
- AI & Vector: Vercel AI SDK, Pinecone
- Background Jobs: Inngest
- Payments: Polar.sh
- State Management: TanStack Query
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Frontend β
β (Next.js 16 App Router + React 19 + TypeScript) β
β β
β βββββββββββββββββββ ββββββββββββββββββββ ββββββββββββββββ β
β β Pages / UI β β TanStack Query β β Shadcn UI β β
β β (dashboard, β β (Server State β β + Radix UI β β
β β repos, reviews)β β Management) β β Components β β
β βββββββββββββββββββ ββββββββββββββββββββ ββββββββββββββββ β
β β β β
β ββββββββββββββββ β
β β β
β [Next.js Server Actions] β
βββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββ
β
ββββββββββββββββββΌβββββββββββββββββ
β β β
ββββββββββββΌβββββββ βββββββββΌββββββββ ββββββββΌβββββββββββ
β Auth Layer β β API Routes β β Inngest Jobs β
β (Better Auth β β /api/auth β β (Background β
β + GitHub OAuth)β β /api/inngest β β Processing) β
β β β /api/webhooksβ β β
ββββββββββββ¬βββββββ βββββββββ¬ββββββββ ββββββββ¬βββββββββββ
β β β
ββββββββββββββββββΌβββββββββββββββββ
β
ββββββββββββββββββΌβββββββββββββββββ
β β β
ββββββββββββΌβββββββ βββββββββΌββββββββ ββββββββΌβββββββββββ
β PostgreSQL β β Pinecone β β External APIs β
β (Prisma ORM) β β (Vector DB β β - GitHub API β
β Users, Repos, β β for RAG) β β - Google Geminiβ
β Reviews, Usage β β β β - Polar.sh β
βββββββββββββββββββ βββββββββββββββββ βββββββββββββββββββ
CodeFox uses a Pinecone-backed Semantic Code RAG pipeline to retrieve repository context before generating pull request reviews.
π Detailed Benchmark Report: View Metrics
- 100% Hit Rate across 2 evaluation datasets.
- 95.2% Recall for repository-scale semantic code retrieval.
- 2.32s Average Retrieval Latency.
- Full Repository Indexing using Pinecone vector embeddings.
- Context-Aware PR Reviews powered by Retrieval-Augmented Generation (RAG).
The relational schema and table relationships for this project are fully documented and can be viewed interactively here: π View CodeFox Database Documentation
- GitHub Webhook: A
pull_requestevent (openedorsynchronize) is sent to/api/webhooks/github - Trigger Review: The webhook handler calls
reviewPullRequest()asynchronously via Inngest - RAG Context: Relevant code snippets are retrieved from Pinecone using embeddings
- AI Analysis: PR diff + codebase context is sent to Google Gemini via Vercel AI SDK
- Post & Save: The generated review is posted as a GitHub comment and saved to PostgreSQL
- Dashboard Update: TanStack Query refetches updated stats and reviews on the dashboard
codeFox/
βββ prisma/
β βββ schema.prisma # DB models: User, Repository, Review, UserUsage
β βββ migrations/ # Prisma migration history
βββ src/
β βββ app/
β β βββ globals.css # Global styles (Tailwind v4)
β β βββ layout.tsx # Root layout
β β βββ page.tsx # Landing / home page
β β βββ (auth)/
β β β βββ login/page.tsx # Login page
β β βββ api/
β β β βββ auth/[...all]/ # Better Auth handler
β β β βββ inngest/ # Inngest event endpoint
β β β βββ webhooks/github/ # GitHub webhook receiver
β β βββ dashboard/
β β βββ layout.tsx # Dashboard shell with sidebar
β β βββ page.tsx # Main dashboard (stats + charts)
β β βββ repository/ # GitHub repo import & management
β β βββ reviews/ # AI-generated review listing
β β βββ settings/ # Profile & connected repos
β β βββ subscriptions/ # Plan & usage management
β βββ components/
β β βββ app-sidebar.tsx # Main navigation sidebar
β β βββ ai-elements/ # Custom AI interaction components
β β βββ providers/
β β β βββ query-provider.tsx # TanStack Query setup
β β β βββ theme-providers.tsx
β β βββ ui/ # Shadcn UI component library
β βββ inngest/
β β βββ client.ts # Inngest client configuration
β β βββ functions/
β β βββ index.ts # Registers: indexRepo, generateReview
β β βββ review.ts # Core review generation job
β βββ lib/
β β βββ auth.ts # Better Auth configuration
β β βββ auth-client.ts # Client-side auth helpers
β β βββ db.ts # Prisma client instance
β β βββ pinecone.ts # Pinecone vector DB client
β β βββ utils.ts # Shared utilities
β βββ hooks/
β β βββ use-mobile.ts
β βββ modules/ # Feature-specific business logic
β βββ ai/
β β βββ actions/index.ts # reviewPullRequest() server action
β β βββ lib/rag.ts # RAG retrieval logic
β βββ auth/
β β βββ components/ # LoginUI, Logout
β β βββ dashboard/ # Stats actions + ContributionGraph
β β βββ github/lib/ # GitHub API helpers (Octokit)
β β βββ utils/auth-utils.ts
β βββ payment/
β β βββ actions/ # Subscription server actions
β β βββ config/polar.ts # Polar.sh client config
β β βββ lib/subscription.ts
β βββ repository/
β β βββ actions/ # Connect / disconnect repo actions
β β βββ components/ # RepositorySkeleton
β β βββ hooks/ # useRepositories, useConnectRepository
β βββ review/
β β βββ actions/ # Fetch reviews server actions
β βββ settings/
β βββ actions/ # Profile update actions
β βββ components/ # ProfileForm, RepositoryList, SettingsPageClient
| Variable | Description | Required |
|---|---|---|
DATABASE_URL |
PostgreSQL connection string | β Yes |
BETTER_AUTH_SECRET |
Secret key for Better Auth sessions | β Yes |
BETTER_AUTH_URL |
Base URL of the application | β Yes |
GITHUB_CLIENT_ID |
GitHub OAuth App client ID | β Yes |
GITHUB_CLIENT_SECRET |
GitHub OAuth App client secret | β Yes |
GOOGLE_GENERATIVE_AI_API_KEY |
Google Gemini API key for AI reviews | β Yes |
PINECONE_API_KEY |
Pinecone API key for vector storage | β Yes |
INNGEST_EVENT_KEY |
Inngest event key for background jobs | β Yes |
INNGEST_SIGNING_KEY |
Inngest signing key for webhook verification | β Yes |
POLAR_ACCESS_TOKEN |
Polar.sh access token for subscriptions | β Yes |
The application handles various error scenarios gracefully:
- Unauthenticated Access:
requireAuth()in the dashboard layout redirects unauthenticated users to the login page. - GitHub Webhook Errors: The webhook handler wraps processing in try/catch and returns a 500 with a JSON error without leaking stack traces.
- Failed AI Reviews: Review generation errors are caught and logged; the PR review job fails gracefully without crashing the server.
- Repository Disconnect: Mutation errors in the settings page surface user-friendly toast messages via Sonner.
- Subscription Limits: Usage is tracked per user (
UserUsagemodel) and enforced before allowing new repo connections or reviews. - Database Cascades: Deleting a user cascades to sessions, accounts, repositories, and reviews β preventing orphaned records.
- Strict TypeScript: Full type safety across the entire codebase with no implicit
any. - Modular Architecture: Feature logic is isolated in
modules/β each feature owns its actions, components, and hooks. - Server Actions: Data mutations use Next.js Server Actions instead of ad-hoc API routes, keeping the client lean.
- TanStack Query: All server state is managed with
useQueryanduseMutationwith proper cache invalidation after every mutation. - Prisma ORM: Type-safe database access with auto-generated types from the schema.
- Component Separation: No business logic in JSX β components delegate to server actions and hooks.
- Tailwind CSS v4: Utility-first styling with CSS variables for consistent theming across light/dark modes.
- Public Repositories Only: OAuth scope does not currently cover private repositories.
- Usage Caps by Tier: Free-tier users are limited in the number of repositories they can connect and reviews they can generate (tracked via
UserUsage). - No Streaming Reviews: AI reviews are generated in full before being posted β no real-time streaming to the dashboard.
- Single LLM Provider: Only Google Gemini is supported via Vercel AI SDK; no fallback provider.
- Webhook-Only Trigger: Reviews are only triggered on
pull_requestopenedorsynchronizeevents β no manual trigger from the dashboard yet.
- Next.js Server Actions over REST: Reduces API boilerplate and keeps data-fetching co-located with the UI.
- Inngest for Background Jobs: Chosen over raw queues for its built-in retry logic, observability dashboard, and easy local development with
inngest-cli. - Pinecone for RAG: Managed vector DB avoids infrastructure overhead while enabling context-aware reviews.
- Polar.sh for Payments: Handles subscription tiers and webhook-based status sync without building a billing system from scratch.
- Manual review trigger from the dashboard (without waiting for a webhook)
- Streaming AI review output to the UI in real time
- Review status badge on the PR (pending / completed / failed)
- Dark mode polish across all dashboard pages
- Support for private repositories via expanded GitHub OAuth scopes
- Multi-provider LLM support (OpenAI, Anthropic) with user-selectable models
- Per-file review breakdown instead of a single diff-level review
- Configurable review rules and custom prompts per repository
- GitHub App installation flow (instead of per-user OAuth)
- Team workspaces with shared repositories and review history
- Analytics dashboard with review quality metrics over time
- Webhook event support for
pushevents and branch protection rules
Overview of your coding activity and review status.

Manage your connected GitHub repositories.

Detailed AI-generated feedback on your pull requests.

Configure your preferences and account details.

Manage your plan and usage limits.

- Node.js (v18+)
- pnpm, npm, or bun
- PostgreSQL database
- GitHub OAuth App credentials
- Pinecone API Key
- Google AI API Key (Gemini)
-
Clone the repository:
git clone https://github.com/Vanshgargji/codeFox.git cd codeFox -
Install dependencies:
npm install # or pnpm install # or bun install
-
Set up Environment Variables: Create a
.envfile in the root directory and add the following variables:# Database DATABASE_URL="postgresql://user:password@localhost:5432/code_fox?schema=public" # Authentication (Better Auth) BETTER_AUTH_SECRET="your_secret_key" BETTER_AUTH_URL="http://localhost:3000" # GitHub OAuth GITHUB_CLIENT_ID="your_github_client_id" GITHUB_CLIENT_SECRET="your_github_client_secret" # AI (Google Gemini) GOOGLE_GENERATIVE_AI_API_KEY="your_google_api_key" # Vector DB (Pinecone) PINECONE_API_KEY="your_pinecone_api_key" # Background Jobs (Inngest) INNGEST_EVENT_KEY="your_inngest_event_key" INNGEST_SIGNING_KEY="your_inngest_signing_key" # Payments (Polar.sh) POLAR_ACCESS_TOKEN="your_polar_access_token"
-
Database Setup: Run the Prisma migrations to set up your database schema.
npx prisma generate npx prisma migrate dev
-
Run the Development Server:
npm run dev # or pnpm dev # or bun dev
Open http://localhost:3000 with your browser to see the result.
-
Run Inngest Dev Server: In a separate terminal, run Inngest to handle background jobs.
npx inngest-cli@latest dev
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the project
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
