A lightweight, production-style Flask application that listens to GitHub Webhooks (Push, Pull Request, Merge events), stores normalized activity data in MongoDB, and displays repository activity on a clean UI that refreshes every 15 seconds.
This project is designed to closely mirror real-world GitHub integrations and is suitable for assignments, interviews, and portfolio demonstrations.
-
Capture GitHub repository activities using GitHub Webhooks
-
Handle the following events:
- PUSH
- PULL REQUEST (Opened)
- MERGE (PR Closed & Merged)
-
Store only the required fields in MongoDB
-
Display the latest repository activities on a UI
-
UI refreshes automatically every 15 seconds
GitHub Repository
│
│ Webhook Events
▼
Flask Webhook API ─────▶ MongoDB
│
│ REST API (/events)
▼
Flask UI (Polling every 15s)
- Decoupled & scalable
- Realistic webhook handling
- Clean separation of concerns
- Easy to extend (auth, queues, caching)
github-webhook-tracker/
│
├── app/
│ ├── __init__.py # Flask app factory
│ ├── db.py # MongoDB initialization
│ │
│ ├── routes/
│ │ ├── webhook.py # GitHub webhook endpoint
│ │ └── ui.py # UI & events API
│ │
│ └── templates/
│ └── index.html # UI page
│
├── main.py # Application entry point
├── requirements.txt
├── .env
├── .gitignore
└── README.md
GitHub Trigger: push
Displayed Format:
{author} pushed to {to_branch} on {timestamp}
GitHub Trigger: pull_request with action = opened
Displayed Format:
{author} submitted pull request from {from_branch} to {to_branch} on {timestamp}
GitHub Trigger: pull_request with:
action = closedmerged = true
Displayed Format:
{author} merged branch from {from_branch} to {to_branch} on {timestamp}
git clone <your-repo-url>
cd github-webhook-trackerpython -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activatepip install -r requirements.txtCreate a .env file in root:
FLASK_ENV=development
MONGO_URI=mongodb://localhost:27017
MONGO_DB=github_eventsmongodpython run.pyOpen browser:
http://localhost:5000
- Go to GitHub Repo → Settings → Webhooks
- Payload URL:
http://<your-ngrok-url>/webhook/github
-
Content type:
application/json -
Select events:
- ✅ Push
- ✅ Pull requests
-
Save webhook
Use
ngrok http 5000for local testing
- UI fetches
/eventsAPI every 15 seconds - Displays latest repository activities
- No page reload required
Travis pushed to staging on 01 April 2021 - 09:30 PM UTC
Alice submitted pull request from feature-x to main on 02 April 2021 - 11:10 AM UTC
Bob merged branch from dev to main on 03 April 2021 - 06:45 PM UTC
- Flask App Factory Pattern
- Blueprint-based routing
- Environment-based configuration
- Circular import safe structure
- Minimal MongoDB documents
- Clean UI polling logic
- Webhook signature verification (security)
- Pagination / infinite scroll
- WebSocket-based real-time updates
- Authentication
- Dockerization
This project demonstrates:
- Real GitHub webhook integration
- Backend + Database + UI flow
- Event-driven system design
- Production-ready Flask structure