AI-powered GitHub App for automated pull request code reviews using Gemini AI and GitOps principles.
AutoPR is an internal developer productivity tool built by lab68dev that automatically reviews Pull Requests as soon as they’re opened or updated.
When a new PR event is received from GitHub, the app:
- Fetches the diff of the PR,
- Sends the code changes to Google Gemini for intelligent review feedback,
- Posts a summarized AI review as a GitHub comment directly on the PR thread.
This enables faster, more consistent reviews, and helps teams maintain high code quality even with fast CI/CD cycles.
| Layer | Technology |
|---|---|
| Backend Framework | FastAPI |
| AI Engine | Google Gemini API |
| Version Control | GitHub App Integration |
| Async HTTP | HTTPX |
| Language | Python 3.10+ |
| Auth / Security | GitHub App JWT + Webhook Signature Verification |
| Infra (optional) | Docker, ngrok, GitHub Actions |
✅ Automated PR Review via Gemini AI
✅ Secure GitHub App Integration (JWT Auth + Webhooks)
✅ Diff-based review for context-aware analysis
✅ Smart comment posting back to PRs
✅ Easy local development with ngrok tunnel
✅ Modular service structure for clean scaling
GitHub Repo → Webhook (PR Opened/Updated)
↓
FastAPI Backend
↓
Gemini AI Review Engine (diff analysis)
↓
GitHub PR Comment with Feedback
Folders:
app/
├── main.py # FastAPI entrypoint
├── services/
│ ├── github_client.py # Auth + GitHub API
│ └── gemini_client.py # AI review logic
└── utils/
└── verify_webhook.py # HMAC verification
git clone https://github.com/lab68dev/autopr.git
cd autoprpip install -r requirements.txtCopy .env.example → .env, then fill in your details:
GITHUB_APP_ID=123456
GITHUB_PRIVATE_KEY_PATH=./private-key.pem
GITHUB_WEBHOOK_SECRET=your_webhook_secret
GEMINI_API_KEY=your_gemini_api_key
ORG_NAME=lab68devuvicorn app.main:app --reloadAccess:
- http://127.0.0.1:8000 → Home
- http://127.0.0.1:8000/docs → API Docs
Expose your FastAPI server to the internet for GitHub webhooks:
ngrok http 8000Then copy the public URL into your GitHub App’s Webhook URL (e.g. https://abcd-1234.ngrok.io/api/v1/webhook).
AutoPR ensures secure webhook communication:
- HMAC SHA-256 signature verification (
X-Hub-Signature-256) - JWT-based GitHub App authentication
- Token-scoped GitHub API access for each installation
- Secrets stored in
.env(ignored by.gitignore)
GITHUB_APP_ID=123456
GITHUB_PRIVATE_KEY_PATH=./private-key.pem
GITHUB_WEBHOOK_SECRET=xxxxxxxxxxxxxxxxxxxx
GEMINI_API_KEY=xxxxxxxxxxxxxxxxxxxx
ORG_NAME=lab68dev
- Edit backend code in
app/main.py - All external API calls are async (
httpx.AsyncClient) - Add AI behavior in
gemini_client.py - Verify webhook signature logic in
utils/verify_webhook.py
To test your webhook locally, use:
curl -X POST http://127.0.0.1:8000/api/v1/webhook \
-H "X-GitHub-Event: pull_request" \
-H "X-Hub-Signature-256: sha256=..." \
-d "@sample_payload.json"docker build -t lab68dev-autopr .
docker run -p 8000:8000 --env-file .env lab68dev-autopr🤖 AutoPR Review (Gemini) ✅ Functionality looks solid
⚠️ Consider adding error handling for network requests 💡 Suggest using async context manager for file IO
This project is intended for internal use by lab68dev. Contact your team admin for deployment or usage rights.
lab68dev Engineering Team Built with ❤️ and Gemini AI.