How mirzasayzz/prpilot works
1. Overall shape
PRPilot is a Python GitHub App deployed as Vercel serverless functions. Its core job is to react to GitHub Pull Request webhooks, analyze changed code with AI, and post a review comment back to the PR.
2. Primary runtime boundary
The backend lives under api/ and is the operational entry point in production:
- api/webhook.py handles GitHub webhook traffic
- api/config.py serves repository/app configuration
- api/index.py is the health check
vercel.json is the deployment/routing layer that exposes these functions.
3. GitHub event flow
The main data flow is: GitHub PR event → webhook endpoint → signature verification → repository/config lookup → diff fetch → AI analysis → synthesized review → GitHub comment.
The GitHub-facing integration is split between github/client.py and github/webhook_handler.py, which likely isolate API calls and payload/event parsing from the rest of the app.
4. State and persistence
Persistent configuration is backed by Supabase/Postgres, with schema in db/schema.sql and database access in db/client.py.
The database stores installation/repository configuration and encrypted credentials needed for automated reviews.
5. Secret handling
The security boundary is important: agents/key_manager.py indicates API keys are encrypted before storage and decrypted only at runtime. The README says the encryption is AES-256 with a base64-encoded application encryption key supplied via environment variables.
6. AI analysis subsystem
The agents/ package is the main intelligence layer. It contains:
- base.py for shared agent behavior
- style_agent.py
- security_agent.py
- performance_agent.py
- logic_agent.py
These run as specialized analyzers over the same code diff, each producing domain-specific findings.
7. LLM abstraction
agents/llm_client.py is the provider boundary for model access. The README positions Gemini 2.0 Flash as the primary model, and the client layer appears to support provider abstraction/fallback so the rest of the system does not depend on a specific LLM vendor.
8. Review synthesis
After all agents finish, their outputs are combined into a single review artifact. The architecture described in the README implies a synthesis step that deduplicates findings, normalizes severity/content, and formats the result as Markdown before it is posted to GitHub.
9. User-facing configuration
public/index.html and public/config.html are static UI assets served separately from the webhook path. They support the landing page and repository/app configuration experience, while the actual automation remains server-side.
10. Local/test path
The repo also includes a non-GitHub execution path for validation:
- test_local.py runs the agents locally
- test_samples/sample_code.py provides a sample input
- docs/TESTING_GUIDE.md documents end-to-end verification
This makes the agent pipeline testable without deploying the GitHub App.
11. Operational dependencies
The architecture depends on three external systems that shape the design:
- GitHub for webhooks, PR diffs, and posting comments
- Supabase for persistent configuration/storage
- Google AI Studio/Gemini for code analysis
Vercel provides the serverless execution environment, which influences the stateless request/response design.
12. Diagram boundaries to show
An accurate architecture diagram should separate:
- GitHub event source and comment sink
- Vercel serverless API layer
- Database/configuration storage in Supabase
- The four parallel AI agents
- The LLM provider boundary
- Local testing utilities as a separate, non-production path
Main entry points: webhook.py Webhook · base.py Agent base · client.py DB client · llm_client.py LLM client
Components 25
Vercel API
Serverless entrypoints and deployment routing
- Webhook · Receives GitHub PR webhooks and starts the review flow
api/webhook.py - Config API · Serves repository and app configuration
api/config.py - Install API · Handles GitHub App installation setup
api/install.py - Health check · Simple operational endpoint
api/index.py - Vercel routing · Exposes the API functions in production
vercel.json
GitHub integration
Webhook parsing and GitHub API access
- Event parser · Normalizes GitHub webhook payloads and event flow
github/webhook_handler.py - GitHub client · Fetches diffs and posts review comments
github/client.py
AI analysis
Agent pipeline and model access
- Review pipeline · Coordinates diff analysis, synthesis, and publishing
- Agent base · Common agent behavior and interfaces
agents/base.py - Style · Checks readability and code style
agents/style_agent.py - Security · Finds security issues in changes
agents/security_agent.py - Performance · Flags performance regressions and inefficiencies
agents/performance_agent.py - Logic · Detects functional bugs and correctness issues
agents/logic_agent.py - LLM client · Abstracts Gemini and other model providers
agents/llm_client.py - Key manager · Encrypts and decrypts stored API keys at runtime
agents/key_manager.py
Persistence
Database schema and access layer
User UI
Static pages for app and configuration
- Landing page · Public-facing entry page
public/index.html - Config page · Repository and app configuration UI
public/config.html
Local validation
Non-production execution and sample input
- Local runner · Runs the agent pipeline outside GitHub
test_local.py - Sample input · Example code used for local testing
test_samples/sample_code.py - Testing guide · Documents end-to-end validation steps
docs/TESTING_GUIDE.md
Other components
- GitHub · Webhook source, PR diff source, and comment sink
- Supabase · Postgres-backed persistence for config and secrets
- Gemini · Primary AI model provider
Connections 30
- Vercel routing → Webhook: routes · Deployment exposes the webhook handler
- Vercel routing → Config API: routes · Deployment exposes configuration endpoint
- Vercel routing → Install API: routes · Deployment exposes install endpoint
- Vercel routing → Health check: routes · Deployment exposes health endpoint
- Webhook → Event parser: parses · Webhook handler normalizes incoming GitHub events
- Webhook → DB client: loads config · Reads installation and repository settings
- Webhook → Review pipeline: starts · Kicks off analysis and review generation
- Config API → DB client: serves config · Fetches persisted configuration for the UI and app
- Install API → DB client: stores install · Persists installation state and settings
- Event parser → GitHub client: uses · Delegates GitHub API interactions
- Review pipeline → GitHub client: fetches diff / posts review · Reads PR changes and publishes the final comment
- Review pipeline → Agent base: coordinates · Shares common agent behavior and execution flow
- Agent base → Style: runs · Executes the style review pass
- Agent base → Security: runs · Executes the security review pass
- Agent base → Performance: runs · Executes the performance review pass
- Agent base → Logic: runs · Executes the logic review pass
- Style → LLM client: calls · Uses model access for analysis
- Security → LLM client: calls · Uses model access for analysis
- Performance → LLM client: calls · Uses model access for analysis
- Logic → LLM client: calls · Uses model access for analysis
- Review pipeline → Key manager: decrypts · Protects stored API keys at runtime
- DB client → Schema: implements · Database access follows the defined schema
- DB client → Supabase: persists · Stores and retrieves application state
- LLM client → Gemini: invokes · Primary model provider boundary
- Landing page → Config page: links · Static UI provides navigation to configuration
- Local runner → Sample input: loads · Uses sample input for local validation
- Local runner → Review pipeline: exercises · Runs the analysis pipeline without GitHub
- Testing guide → Local runner: documents · Explains local and end-to-end verification
- Webhook → GitHub: receives from · Incoming webhook requests originate from GitHub
- GitHub client → GitHub: calls · Posts comments and fetches pull request data