How prash-kr-meena/github-bot-rabbithole works
This is a local-development GitHub webhook integration project consisting of two Python bots:
• Issue Bot (issue_bot.py): listens for Issue Comment webhook events; reacts to the /greet command by posting a reply via the GitHub API.
• PR Bot (pr_bot.py): listens for Pull Request webhook events; clones the repo for context, calls Anthropic Claude to generate a review, and posts review comments back to GitHub.
Both run locally as lightweight HTTP servers (very likely Flask) and rely on ngrok to expose local ports to GitHub Webhooks.
File-structure analysis (use this to derive components)
Top-level files indicate a small, script-oriented architecture (no packages/modules directory):
• Runtime entrypoints
• issue_bot.py — webhook handler + issue comment logic
• pr_bot.py — webhook handler + PR review logic
• PR review logic
• pr_review.py — likely encapsulates “analyze PR / call Anthropic / format review comments”
• Testing & diagnostics
• run_tests.py — orchestrates end-to-end checks
• test_* scripts — GitHub auth, ngrok connectivity, webhook simulation for each bot
• Security/config utilities
• generate_secret.py — webhook secret generation for signature verification
• .env referenced in README (not in tree, but assumed local)
• Docs
• NGROK_SETUP.md, PR_TESTING.md, TESTING.md
• Dependencies
• requirements.txt (implies Flask + GitHub API client + Anthropic client + requests, etc.)
README-derived architecture & runtime behavior
Key operational facts to reflect:
• Issue bot runs on localhost:5000, webhook path /webhook, GitHub event type: issue_comment
• PR bot runs on localhost:5001, webhook path /webhook, GitHub event type: pull_request
• ngrok forwards public HTTPS → local HTTP.
• Both require:
• GitHub PAT for calling GitHub REST APIs (posting comments/reviews)
• Webhook secret for validating webhook signatures (HMAC)
• PR bot additionally requires:
• ANTHROPIC_API_KEY, base URL, model selection.
Anthropic API (Claude) (PR bot only)
Local runtime (your machine)
Issue Bot Service (issue_bot.py, port 5000)
• Webhook endpoint: /webhook
• Command parser: /greet
• GitHub API client: “post issue comment”
• Webhook signature validator (secret)
PR Bot Service (pr_bot.py, port 5001)
• Webhook endpoint: /webhook
• PR event handler
• Repo cloning workspace (local filesystem temp dir)
• Diff/patch extraction
• AI review generator (via pr_review.py)
• GitHub API client: “create PR review / review comments”
• Webhook signature validator (secret)
Config/secrets
Environment Variables / .env
• GITHUB_TOKEN (PAT), WEBHOOK_SECRET
• ANTHROPIC_* (PR bot only)
Optional but useful (for completeness)
Test Harness (run_tests.py + test_*.py)
• not part of runtime path, but part of developer workflow and validation
GitHub → ngrok: Webhook delivery (HTTPS)
• event: issue_comment
GitHub → ngrok: Webhook delivery (HTTPS)
• event: pull_request (opened/synchronize/etc.)
GitHub → User-visible result: review comments appear on PR diff
• Developer runs: python run_tests.py → invokes test_github_auth.py, test_ngrok.py, test_bot.py, test_pr_bot.py
• These scripts may simulate webhook payloads directly to localhost endpoints.
Architectural patterns/principles actually present
Call these out visually or as annotations:
• Event-driven webhook architecture (GitHub events trigger handlers)
• Two independent services (Issue Bot and PR Bot are separate deployables/ports)
• Tunnel-based ingress for local development (ngrok)
• External API orchestration (GitHub REST + Anthropic)
• Security boundary: webhook signature verification + PAT-based outbound auth
• Workspace-based analysis for PR bot (clone repo locally for full context)
Relevant technologies (don’t guess too much, but include what’s strongly implied)
• Python 3.6+
• GitHub API (REST endpoints for issues/comments and PR reviews)
• Anthropic Claude (PR bot) with model/base URL from README
• git command usage (PR bot clone)
PR bot pipeline (the “meat” of the system)
• fetch PR → clone → compute changed files/patch → LLM review → map review to diff positions → post inline review comments
GitHub Review Publisher
This is where “separating into as many components as possible” pays off for accuracy.