Skip to content

techyMk/codexa-ai

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

31 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Codexa

AI code review on every GitHub pull request

Catches bugs, security issues, and bad patterns before merge β€” without slowing your CI.

CI Next.js FastAPI Supabase Vercel Render License: MIT

Live demo Β· Install bot Β· Docs


Codexa

Codexa is a GitHub App that auto-reviews every pull request with AI. It catches bugs, security issues, and bad patterns before merge, and posts findings as a single review comment with file, line, severity, and concrete fix suggestions β€” plus a status check that can block merges on critical issues.

  • Frontend β€” Next.js 15 (App Router) + Tailwind + Framer Motion β†’ Vercel
  • Backend β€” FastAPI + httpx + structlog β†’ Render (Docker)
  • AI β€” Gemini 2.0 Flash (primary) β†’ Groq Llama 3.3 70B (fallback) β€” both free
  • DB / Auth β€” Supabase (Postgres + GitHub OAuth) β€” free
  • CI/CD β€” GitHub Actions

Total monthly cost on default tier: $0.


Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     PR opened      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   GitHub     β”‚ ─────────────────▢ β”‚ FastAPI        β”‚
β”‚   (PR + App) β”‚   webhook (HMAC)   β”‚ /webhooks/...  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                    β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
       β–²                                    β”‚ background task
       β”‚ comment posted                     β–Ό
       β”‚                            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
       β”‚                            β”‚ AIRouter       β”‚
       β”‚                            β”‚  β”œ Gemini      β”‚
       β”‚                            β”‚  β”” Groq (fb)   β”‚
       β”‚                            β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚                                    β–Ό
       β”‚                            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
       └────────────────────────────│ render comment β”‚
                                    β”‚ + log Supabase β”‚
                                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

The Next.js dashboard reads from /reviews and /reviews/stats to show activity.


Repository layout

codexa/
β”œβ”€β”€ backend/                  # FastAPI service
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ main.py           # FastAPI factory
β”‚   β”‚   β”œβ”€β”€ config.py         # Pydantic settings
β”‚   β”‚   β”œβ”€β”€ core/             # logging, security (HMAC, JWT)
β”‚   β”‚   β”œβ”€β”€ routes/           # /webhooks/github, /reviews, /healthz
β”‚   β”‚   β”œβ”€β”€ services/
β”‚   β”‚   β”‚   β”œβ”€β”€ ai/           # gemini.py, groq.py, router.py, parser.py
β”‚   β”‚   β”‚   β”œβ”€β”€ github.py     # diff fetch, comment post, token cache
β”‚   β”‚   β”‚   └── reviewer.py   # orchestrates a single review
β”‚   β”‚   └── db/supabase.py    # service-role client
β”‚   β”œβ”€β”€ requirements.txt
β”‚   └── Dockerfile
β”œβ”€β”€ frontend/                 # Next.js 15
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ page.tsx          # landing
β”‚   β”‚   β”œβ”€β”€ login/            # GitHub OAuth via Supabase
β”‚   β”‚   β”œβ”€β”€ auth/callback/    # OAuth callback handler
β”‚   β”‚   └── dashboard/        # overview, reviews, settings
β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”œβ”€β”€ landing/          # hero, features, how-it-works, pricing, cta
β”‚   β”‚   β”œβ”€β”€ ui/               # button, badge
β”‚   β”‚   └── navbar.tsx
β”‚   β”œβ”€β”€ lib/supabase/         # client, server, middleware
β”‚   └── middleware.ts         # protects /dashboard
β”œβ”€β”€ supabase/migrations/001_init.sql
β”œβ”€β”€ .github/workflows/        # ci.yml, deploy.yml
β”œβ”€β”€ render.yaml               # backend deploy descriptor
└── docker-compose.yml        # local backend

Local development

1. Prereqs

  • Node 20+, Python 3.12+, Docker (optional)
  • A free Supabase project, a Gemini API key, a Groq API key
  • A GitHub App (instructions below)

2. Clone and configure

git clone <repo> codexa && cd codexa
cp .env.example .env
cp backend/.env.example backend/.env
cp frontend/.env.local.example frontend/.env.local

Fill in the values in each .env* file.

3. Create the GitHub App

Go to github.com β†’ Settings β†’ Developer settings β†’ GitHub Apps β†’ New GitHub App.

Field Value
Name Codexa (must be unique on GitHub)
Homepage URL http://localhost:3000
Webhook URL https://<your-tunnel>.ngrok.io/webhooks/github (use ngrok in dev)
Webhook secret a long random string β€” paste into GITHUB_WEBHOOK_SECRET
Repository permissions Pull requests: Read & write, Contents: Read, Metadata: Read
Subscribe to events Pull request

After creating: note the App ID, generate a private key (.pem), and install the app on a test repo. Paste the .pem contents into GITHUB_APP_PRIVATE_KEY (newlines as \n).

4. Initialize the database

In the Supabase SQL editor, run supabase/migrations/001_init.sql.

In Authentication β†’ Providers β†’ GitHub, enable GitHub OAuth and paste the OAuth client ID/secret from your GitHub App. Add http://localhost:3000/auth/callback and your production URL to the allowed redirect URLs.

5. Get free AI keys

6. Run

Two terminals:

# Backend
cd backend
python -m venv .venv && source .venv/bin/activate   # Windows: .venv\Scripts\activate
pip install -r requirements.txt
uvicorn app.main:app --reload
# Frontend
cd frontend
npm install
npm run dev

Open http://localhost:3000.

7. Test the webhook end-to-end

ngrok http 8000
# Copy the https URL into your GitHub App's webhook URL
# Open a PR in a repo where the App is installed β†’ Codexa comments within ~10s

Production deploy (free)

Backend β†’ Render

  1. Push the repo to GitHub.
  2. On Render, New + Blueprint β†’ point to your repo. It picks up render.yaml.
  3. Set the environment variables from backend/.env in the Render dashboard.
  4. Update the GitHub App webhook URL to https://<your-render-url>/webhooks/github.

Frontend β†’ Vercel

  1. Import the repo on Vercel. Set the Root Directory to frontend.
  2. Add the env vars from frontend/.env.local.example (point NEXT_PUBLIC_BACKEND_URL at Render).
  3. Deploy. Add the production domain to your Supabase OAuth allowed URLs.

Database β†’ Supabase

Already provisioned β€” just keep the project on the free tier.


How a review actually runs

  1. GitHub fires a pull_request webhook with action opened, reopened, synchronize, or ready_for_review.
  2. core/security.verify_webhook_signature validates the HMAC SHA-256 against GITHUB_WEBHOOK_SECRET.
  3. We mint a short-lived installation access token (core/security.create_app_jwt β†’ /installations/:id/access_tokens), cached for 50 min.
  4. We fetch the unified diff via Accept: application/vnd.github.v3.diff.
  5. services/ai/router.AIRouter tries Gemini first; if it raises, falls back to Groq.
  6. The model returns strict JSON: a summary plus an array of findings.
  7. We render a Markdown comment and POST to /repos/:owner/:repo/issues/:n/comments.
  8. The result is logged to the reviews table.

Tunable bits:

  • services/ai/prompt.SYSTEM_PROMPT β€” change tone, focus areas, severity rubric
  • services/ai/prompt.build_user_prompt β€” diff truncation threshold (default 60 KB)
  • services/github.render_review_comment β€” comment formatting
  • routes/webhooks._REVIEWABLE_ACTIONS β€” which PR events trigger a review

Why this stack stays free

Component Provider Free tier
Frontend Vercel 100 GB bandwidth / month
Backend Render (Docker) 750 hours / month
Database Supabase 500 MB Postgres + 50k MAU
AI #1 Google Gemini 1,500 requests / day
AI #2 Groq (Llama 3.3) Generous free tier
CI GitHub Actions 2,000 min / month (private)

If you hit Gemini's daily cap, every subsequent review automatically falls through to Groq.


License

MIT.

About

πŸ€– AI code review for every GitHub pull request. Free, open-source, and self-hostable β€” Gemini 2.0 Flash with Groq Llama 3.3 fallback. FastAPI + Next.js 15 + Supabase.

Topics

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Sponsor this project

  •  

Packages

 
 
 

Contributors