AI-Powered Code Police β Automated Code Review, Self-Healing Bugs & Blockchain Attestation
Live Demo Β· Features Β· Tech Stack Β· Getting Started Β· Architecture
- Introduction
- Features
- Tech Stack
- Architecture
- Getting Started
- Project Structure
- API Reference
- Deployment
- Contributors
Protocol Zero is a full-stack AI-powered DevOps platform that acts as an autonomous code quality guardian for your GitHub repositories. It combines real-time AI code review, autonomous bug detection & fixing, and immutable blockchain audit trails β all in a single, unified dashboard.
Connect any GitHub repository, and Protocol Zero will:
- Review every push & pull request with multi-dimensional AI analysis (security, performance, bugs, readability, test coverage).
- Autonomously heal broken code β clone, scan, fix, test, and submit Pull Requests, all without human intervention.
- Record every AI fix on-chain via a Solidity smart contract on Ethereum Sepolia, creating a tamper-proof compliance log.
"Enough Building, time for redemption."
Webhook-driven AI code review that watches every commit in real-time.
- Automated Analysis β Triggered on every
pushandpull_requestevent via GitHub webhooks - Multi-Dimensional Review β Each file is analyzed for security vulnerabilities, performance issues, bugs, readability, and test coverage
- Auto-Fix Pull Requests β Critical and high-severity issues trigger automatic fix PRs with AI-generated patches
- Email Reports β Rich HTML email digests summarizing findings and linking directly to auto-fix PRs
- Custom Rules β Define your own rules (e.g., "No console.log in production", "Enforce async/await over .then()")
- Full Repository Scan β On-demand full-repo analysis with parallel processing (5 files concurrently) and multi-layer caching (in-memory + Redis)
- Repository Health Analytics β Health scores, language breakdown, commit activity, contributor stats, PR metrics, documentation presence, and AI-powered executive summaries
A multi-agent autonomous pipeline that clones your repo, finds bugs, writes fixes, runs tests, and opens a PR.
-
Multi-Agent Architecture β 5 specialized agents working in concert:
Agent Role Orchestrator Coordinates the entire healing loop with up to 3 retry attempts Bug Scanner (The Scout) AI-powered scanning for SYNTAX, LINTING, RUNTIME, LOGIC, IMPORT, TYPE, and DEPENDENCY bugs Fix Engineer Generates complete fixed file contents using Gemini AI Test Runner Auto-detects framework (Jest, Vitest, Mocha, pytest, Go, Cargo, etc.) and runs tests Repo Manager Git operations β fork, clone, branch, commit, push, create PR -
Live Streaming via SSE β Watch the healing process in real-time with a live timeline, bug table, file tree, and score breakdown
-
Automatic PR Creation β Creates a PR with branch name
TEAM_LEADER_AI_Fixand[AI-AGENT]commit prefix -
Score Breakdown β Weighted 0β100 score with per-category analytics and animated visualizations
-
5-Minute Timeout β Safety guard to prevent runaway sessions
Immutable, tamper-evident audit trail for every AI code fix.
- On-Chain Attestations β Every fix is recorded as a Solidity
Attestationstruct containing: session ID, bug category, file path, line number, error message, fix description, test results (before & after), commit SHA, and timestamp - ComplianceLog Smart Contract β Deployed on Ethereum Sepolia testnet (
Solidity 0.8.24) - Etherscan Verification β Every attestation links directly to its transaction on Etherscan for independent verification
- Read-Only Public Auditing β Anyone can query the contract to audit the AI agent's fix history
- Graceful Degradation β Blockchain features are optional; the platform works fully without blockchain configuration
A comprehensive, feature-rich dashboard with a premium dark UI.
- Home Dashboard β Greeting, stats cards, code review counts, recent activity feed
- Code Police Panel β Connect repos, view analysis results, manage project settings, explore issues, trigger full scans
- Self-Healing Panel β Submit healing requests, view session history, live session streaming with timeline & attestation log
- Notifications Center β In-app notifications for code analysis completions, critical issues, auto-fix PRs, and repo connections
- Settings β Analytics overview, project management, activity history, integrated Clerk profile
- Admin Panel β Email-gated admin dashboard with total user/project/analysis stats, user management, and activity logs
- SaaS Usage Tracking β Free and Pro tier limits with monthly resets
| Layer | Technology |
|---|---|
| Framework | Next.js 16 (App Router) Β· React 19 Β· TypeScript 5.9 |
| AI | Google Gemini (2.5 Flash Lite, 2.0 Flash) via LangChain |
| Authentication | Clerk (OAuth Β· GitHub Social Connection) |
| Database | Firebase / Firestore (primary) Β· Redis (L2 cache) |
| Blockchain | Solidity 0.8.24 Β· Hardhat Β· ethers.js v6 Β· Sepolia Testnet |
| GitHub Integration | Octokit Β· Webhooks Β· Bot Token (PAT) |
| Nodemailer (SMTP) Β· Resend | |
| UI Components | Radix UI Β· Framer Motion Β· Tailwind CSS v4 Β· Recharts |
| 3D / Animations | Spline 3D Β· cobe (globe) Β· tsparticles Β· canvas-confetti |
| Forms & Validation | React Hook Form Β· Zod v4 |
| State Management | Zustand Β· TanStack React Query Β· SWR |
| Deployment | Vercel Β· Netlify Β· Render |
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β PROTOCOL ZERO β
ββββββββββββββββ¬βββββββββββββββ¬βββββββββββββββ¬βββββββββββββββββββββ€
β Landing β Dashboard β Admin β API Layer β
β Page β (Protected) β (Gated) β 31 Endpoints β
ββββββββββββββββ΄βββββββββββββββ΄βββββββββββββββ΄βββββββββββββββββββββ€
β MIDDLEWARE β
β Clerk Auth Β· Route Protection β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β AI AGENTS β
β βββββββββββββββββββββββ ββββββββββββββββββββββββββββββββ β
β β CODE POLICE β β SELF-HEALING ENGINE β β
β β βββββββββββββββββ β β ββββββββββββββββββββββββββ β β
β β β Analyzer β β β β Orchestrator β β β
β β β Fix Generator β β β β Bug Scanner (Scout) β β β
β β β PR Creator β β β β Fix Engineer β β β
β β β Email Service β β β β Test Runner β β β
β β β Analytics β β β β Repo Manager β β β
β β β Cache Layer β β β β Progress Emitter (SSE) β β β
β β βββββββββββββββββ β β ββββββββββββββββββββββββββ β β
β βββββββββββββββββββββββ ββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β DATA & SERVICES β
β ββββββββββββββ ββββββββββ ββββββββββββββ βββββββββββββββββββ β
β β Firestore β β Redis β β GitHub API β β Sepolia (EVM) β β
β β (Primary) β β (Cache)β β (Webhooks) β β ComplianceLog β β
β ββββββββββββββ ββββββββββ ββββββββββββββ βββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- Node.js β₯ 18.x
- npm or yarn or pnpm
- Git
- A Google Cloud account with Gemini API access
- A Clerk account (clerk.com)
- A Firebase project with Firestore enabled
- (Optional) A GitHub Personal Access Token with
reposcope for the self-healing bot - (Optional) An Alchemy or Infura account for Sepolia RPC access
# Clone the repository
git clone https://github.com/zaidkhan-sudo/protocol_zero.git
cd protocol_zero
# Install dependencies
npm installCreate a .env.local file in the root directory:
# βββββββββββββββββββββββββββββββββββββββββββββββββββ
# REQUIRED
# βββββββββββββββββββββββββββββββββββββββββββββββββββ
# Google Gemini AI
GEMINI_API_KEY=your_gemini_api_key
# Clerk Authentication
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_...
CLERK_SECRET_KEY=sk_test_...
# βββββββββββββββββββββββββββββββββββββββββββββββββββ
# FIREBASE (Required for full functionality)
# βββββββββββββββββββββββββββββββββββββββββββββββββββ
# Server-side (Firebase Admin) β choose ONE method:
# Method 1: Individual keys
FIREBASE_PROJECT_ID=your-project-id
FIREBASE_CLIENT_EMAIL=your-service-account@your-project.iam.gserviceaccount.com
FIREBASE_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----"
# Method 2: Service account JSON file path
# FIREBASE_SERVICE_ACCOUNT_PATH=./path/to/service-account.json
# Method 3: Base64-encoded service account JSON
# FIREBASE_ADMIN_SERVICE_ACCOUNT=base64_encoded_json
# Client-side (Firebase SDK)
NEXT_PUBLIC_FIREBASE_API_KEY=your_api_key
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=your-project.firebaseapp.com
NEXT_PUBLIC_FIREBASE_PROJECT_ID=your-project-id
NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET=your-project.firebasestorage.app
NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID=123456789
NEXT_PUBLIC_FIREBASE_APP_ID=1:123456789:web:abc123
# βββββββββββββββββββββββββββββββββββββββββββββββββββ
# GITHUB
# βββββββββββββββββββββββββββββββββββββββββββββββββββ
GITHUB_BOT_TOKEN=ghp_... # PAT with repo scope (self-healing bot)
GITHUB_CLIENT_ID=your_github_oauth_id # GitHub OAuth app
# βββββββββββββββββββββββββββββββββββββββββββββββββββ
# BLOCKCHAIN (Optional β Sepolia Testnet)
# βββββββββββββββββββββββββββββββββββββββββββββββββββ
SEPOLIA_RPC_URL=https://eth-sepolia.g.alchemy.com/v2/...
DEPLOYER_PRIVATE_KEY=0x...
COMPLIANCE_CONTRACT_ADDRESS=0x...
NEXT_PUBLIC_SEPOLIA_RPC_URL=https://eth-sepolia.g.alchemy.com/v2/...
# βββββββββββββββββββββββββββββββββββββββββββββββββββ
# EMAIL (Optional β SMTP via Nodemailer)
# βββββββββββββββββββββββββββββββββββββββββββββββββββ
EMAIL_HOST=smtp.gmail.com
EMAIL_PORT=587
EMAIL_USER=your_email@gmail.com
EMAIL_PASS=your_app_password
# βββββββββββββββββββββββββββββββββββββββββββββββββββ
# OTHER
# βββββββββββββββββββββββββββββββββββββββββββββββββββ
CLERK_WEBHOOK_SECRET=whsec_... # Svix webhook verification
NEXT_PUBLIC_APP_URL=http://localhost:3000
ADMIN_EMAILS=admin@example.com # Comma-separated admin emails
REDIS_URL=redis://localhost:6379 # Optional L2 cache# Start the development server
npm run devOpen http://localhost:3000 to see the app.
Other scripts:
npm run build # Production build (with env validation)
npm run start # Start production server
npm run lint # Run ESLint
npm run lint:fix # Auto-fix lint errors
npm run type-check # TypeScript type checkingTo deploy the ComplianceLog contract to Sepolia:
# Ensure SEPOLIA_RPC_URL and DEPLOYER_PRIVATE_KEY are set in .env
npx hardhat compile
npx hardhat run scripts/deploy.ts --network sepoliaAfter deployment, update COMPLIANCE_CONTRACT_ADDRESS in your environment with the deployed contract address.
protocol_zero/
βββ contracts/ # Solidity smart contracts
β βββ ComplianceLog.sol # On-chain audit trail contract
βββ scripts/
β βββ deploy.ts # Hardhat deployment script
β βββ validate-env.js # Pre-build env validation
βββ src/
β βββ app/
β β βββ page.tsx # Landing page
β β βββ layout.tsx # Root layout (Clerk + fonts)
β β βββ providers.tsx # Client providers (React Query)
β β βββ api/ # 31 API route handlers
β β β βββ auth/ # GitHub OAuth status
β β β βββ code-police/ # Analysis, issues, analytics, auto-fix
β β β βββ self-healing/ # Start session, SSE stream, attestations
β β β βββ webhooks/ # GitHub & Clerk webhooks
β β β βββ dashboard/ # Dashboard stats
β β β βββ admin/ # Admin endpoints (gated)
β β β βββ github/ # Repo listing & connection
β β β βββ notifications/ # Mark read, delete
β β β βββ projects/ # Unified CRUD
β β β βββ user/ # Init & usage tracking
β β β βββ health/ # Health check
β β βββ dashboard/ # Protected dashboard pages
β β β βββ code-police/ # Code Police UI
β β β βββ self-healing/ # Self-Healing UI
β β β βββ notifications/ # Notification center
β β β βββ settings/ # User settings
β β β βββ admin/ # Admin panel
β β βββ sign-in/ # Clerk sign-in
β β βββ sign-up/ # Clerk sign-up
β βββ components/
β β βββ code-police/ # Code Police components
β β βββ self-healing/ # Self-Healing components (7)
β β βββ dashboard/ # Dashboard shell
β β βββ layout/ # Header, Footer, Hero sections
β β βββ ui/ # 44 reusable UI components
β βββ lib/
β β βββ agents/
β β β βββ code-police/ # Analyzer, Fix Generator, PR Creator, etc.
β β β βββ self-healing/ # Orchestrator, Bug Scanner, Fix Engineer, etc.
β β βββ blockchain/ # Ethers.js attestation service
β β βββ firebase/ # Admin SDK + Client SDK init
β β βββ utils/ # Shared utilities
β βββ types/ # TypeScript type definitions
βββ artifacts/ # Compiled contract ABIs
βββ typechain-types/ # Auto-generated contract typings
βββ hardhat.config.ts # Hardhat / Sepolia config
βββ middleware.ts # Clerk route protection
βββ firebase.json # Firebase project config
βββ package.json
| Endpoint | Method | Description |
|---|---|---|
/api/health |
GET |
Health check β reports service status |
| Auth & User | ||
/api/auth/github/status |
GET DELETE |
Check/disconnect GitHub OAuth |
/api/user/init |
POST |
Initialize user document in Firestore |
/api/user/usage |
GET POST |
Usage stats & plan management |
| Code Police | ||
/api/code-police/projects |
GET POST |
List/create projects |
/api/code-police/projects/[id] |
GET PATCH DELETE |
Manage individual project |
/api/code-police/analyze |
POST |
Trigger commit analysis |
/api/code-police/analyze-repo |
POST |
Full repository analysis |
/api/code-police/issues |
GET POST |
Fetch issues / generate auto-fix PR |
/api/code-police/analytics |
GET |
Repository health analytics |
/api/code-police/disconnect |
POST |
Disconnect repository |
| Self-Healing | ||
/api/self-healing/start |
POST |
Start autonomous healing session |
/api/self-healing/stream/[sessionId] |
GET |
SSE live progress stream |
/api/self-healing/sessions |
GET |
List all sessions |
/api/self-healing/sessions/[id] |
GET |
Session details |
/api/self-healing/sessions/[id]/fail |
POST |
Mark session as failed |
/api/self-healing/attestations/[sessionId] |
GET |
On-chain attestation records |
| Webhooks | ||
/api/webhooks/github |
POST |
GitHub push/PR webhook handler |
/api/webhooks/clerk |
POST |
Clerk user lifecycle sync |
| GitHub | ||
/api/github/repos |
GET |
List user's GitHub repos |
/api/github/connect |
POST |
Connect repo + create webhook |
| Dashboard & Admin | ||
/api/dashboard/stats |
GET |
Aggregated dashboard statistics |
/api/admin/stats |
GET |
Admin-only platform stats |
/api/admin/users |
GET |
Admin-only user list |
/api/admin/users/[userId] |
GET PATCH |
Admin user management |
/api/admin/projects |
GET |
Admin project list |
/api/admin/activities |
GET |
Admin activity log |
/api/notifications |
PATCH DELETE |
Manage notifications |
/api/projects |
GET POST PATCH DELETE |
Unified project CRUD |
# Install Vercel CLI
npm i -g vercel
# Deploy
vercel --prodSet all environment variables in the Vercel dashboard under Settings β Environment Variables.
The project includes a netlify.toml with pre-configured build settings and the @netlify/plugin-nextjs plugin.
# Install Netlify CLI
npm i -g netlify-cli
# Deploy
netlify deploy --prodThe live instance runs on Render. Configure a new Web Service pointing to the repository with:
- Build Command:
npm install && npm run build - Start Command:
npm start
![]() Zaid Khan |
![]() Mohnish Pamnani |
![]() Anurag Mishra |
![]() Shivang Jaiswal |
LinkedIn Β· Live Demo Β· GitHub
Built with π‘οΈ by the Protocol Zero Team




