Skip to content

Repository files navigation

Code Fox 🦊

Live Demo

Code Fox Logo

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.

πŸš€ Key Features

  • πŸ€– 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.

πŸ› οΈ Tech Stack

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                          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     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“ˆ Retrieval Performance Metrics

CodeFox uses a Pinecone-backed Semantic Code RAG pipeline to retrieve repository context before generating pull request reviews.

πŸ“„ Detailed Benchmark Report: View Metrics

Highlights

  • 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).

πŸ—„οΈ Database Architecture

The relational schema and table relationships for this project are fully documented and can be viewed interactively here: πŸ‘‰ View CodeFox Database Documentation

Data Flow

  1. GitHub Webhook: A pull_request event (opened or synchronize) is sent to /api/webhooks/github
  2. Trigger Review: The webhook handler calls reviewPullRequest() asynchronously via Inngest
  3. RAG Context: Relevant code snippets are retrieved from Pinecone using embeddings
  4. AI Analysis: PR diff + codebase context is sent to Google Gemini via Vercel AI SDK
  5. Post & Save: The generated review is posted as a GitHub comment and saved to PostgreSQL
  6. Dashboard Update: TanStack Query refetches updated stats and reviews on the dashboard

πŸ“‚ Project Structure

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

βš™οΈ Environment Variables

Required Variables

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

🚧 Error Handling

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 (UserUsage model) and enforced before allowing new repo connections or reviews.
  • Database Cascades: Deleting a user cascades to sessions, accounts, repositories, and reviews β€” preventing orphaned records.

🎨 Code Quality Features

  • 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 useQuery and useMutation with 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.

πŸ”„ Tradeoffs & Limitations

Current Limitations

  1. Public Repositories Only: OAuth scope does not currently cover private repositories.
  2. 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).
  3. No Streaming Reviews: AI reviews are generated in full before being posted β€” no real-time streaming to the dashboard.
  4. Single LLM Provider: Only Google Gemini is supported via Vercel AI SDK; no fallback provider.
  5. Webhook-Only Trigger: Reviews are only triggered on pull_request opened or synchronize events β€” no manual trigger from the dashboard yet.

Design Decisions

  • 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.

πŸš€ Future Improvements

Short Term

  • 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

Medium Term

  • 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

Long Term

  • 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 push events and branch protection rules

πŸ“Έ Screenshots

Dashboard

Overview of your coding activity and review status. Dashboard Page

Repositories

Manage your connected GitHub repositories. Repository Page

Reviews

Detailed AI-generated feedback on your pull requests. Reviews Page

Settings

Configure your preferences and account details. Settings Page

Subscriptions

Manage your plan and usage limits. Subscription Page

🏁 Getting Started

Prerequisites

  • Node.js (v18+)
  • pnpm, npm, or bun
  • PostgreSQL database
  • GitHub OAuth App credentials
  • Pinecone API Key
  • Google AI API Key (Gemini)

Installation

  1. Clone the repository:

    git clone https://github.com/Vanshgargji/codeFox.git
    cd codeFox
  2. Install dependencies:

    npm install
    # or
    pnpm install
    # or
    bun install
  3. Set up Environment Variables: Create a .env file 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"
  4. Database Setup: Run the Prisma migrations to set up your database schema.

    npx prisma generate
    npx prisma migrate dev
  5. Run the Development Server:

    npm run dev
    # or
    pnpm dev
    # or
    bun dev

    Open http://localhost:3000 with your browser to see the result.

  6. Run Inngest Dev Server: In a separate terminal, run Inngest to handle background jobs.

    npx inngest-cli@latest dev

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the project
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

About

CodeFox is an AI-driven code review platform that integrates seamlessly with GitHub to provide intelligent, automated feedback on repositories. Built with Next.js, Inngest, and Google Gemini, it helps developers maintain high code quality with automated analysis and usage-based subscriptions.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages