[FEAT] Add real-time metric updates via GitHub webhooks
Summary
Instead of users manually refreshing the dashboard, configure a GitHub webhook so push events instantly trigger metric cache invalidation and the dashboard auto-refreshes.
Motivation
Currently metrics show stale data until the user clicks refresh. A webhook makes DevTrack feel live.
Architecture
GitHub push event → POST /api/webhooks/github → invalidate cache → broadcast via Server-Sent Events → client refreshes widget
Acceptance Criteria
- [ ] New endpoint:
POST /api/webhooks/github— validates HMAC-SHA256 signature (X-Hub-Signature-256) - [ ] Handles
pushevent: extracts repo and username, marks that user's metrics as stale - [ ] New endpoint:
GET /api/metrics/events— Server-Sent Events stream per authenticated user - [ ] Dashboard widgets subscribe to SSE and re-fetch on
invalidateevent - [ ] Settings page: webhook setup instructions (URL + secret) for users to configure in their GitHub settings
- [ ] Requires
GITHUB_WEBHOOK_SECRETenv var (document in.env.example) - [ ] Graceful degradation: if SSE not connected, polling fallback every 5 min
Security
- HMAC validation is non-negotiable — reject any request without valid signature
- Never expose the webhook secret to the client
Files to Touch
- New:
src/app/api/webhooks/github/route.ts - New:
src/app/api/metrics/events/route.ts src/app/dashboard/settings/page.tsx.env.example
Hi @Priyanshu-byte-coder , I’d like to work on this issue under GSSOC 26.
This looks like a really interesting backend/infrastructure feature, especially around webhooks, SSE, and real-time cache invalidation.
My approach would be to:
- Implement
POST /api/webhooks/githubwith proper HMAC-SHA256 signature validation usingX-Hub-Signature-256 - Handle GitHub push events and mark the corresponding user metrics/cache as stale
- Create an SSE endpoint (
GET /api/metrics/events) for real-time dashboard refresh events - Update dashboard widgets to listen for invalidate events and re-fetch data
- Add webhook setup instructions and required environment variables documentation
- Ensure graceful fallback polling if SSE is unavailable
I’ll also make sure the webhook secret remains server-side only and invalid requests are rejected securely.
Please assign this issue to me if it’s available. Thanks!
Hi @Priyanshu-byte-coder,
I would like to work on this issue.
Proposed implementation approach:
-
Add a secure GitHub webhook endpoint at:
POST /api/webhooks/github -
Validate incoming webhook requests using:
X-Hub-Signature-256with HMAC-SHA256 verification againstGITHUB_WEBHOOK_SECRET -
Handle GitHub
pushevents by:- extracting repository + GitHub username
- invalidating the corresponding cached dashboard metrics
- marking affected metric groups as stale
-
Implement a Server-Sent Events endpoint at:
GET /api/metrics/events -
Use authenticated SSE streams so connected dashboard clients receive realtime invalidation events and automatically re-fetch updated metrics.
-
Add graceful degradation:
- if SSE is unavailable/disconnected, dashboard falls back to polling every 5 minutes
-
Update the dashboard settings page with:
- webhook setup instructions
- webhook URL guidance
- secret configuration guidance for GitHub repository settings
-
Add
GITHUB_WEBHOOK_SECRETto.env.example
Additional focus areas:
- secure signature verification
- preventing unauthorized webhook execution
- lightweight SSE connection management
- proper cleanup of disconnected streams
- minimal and maintainable cache invalidation logic
- preserving existing dashboard behavior when realtime updates are unavailable
I’ll keep the implementation modular, production-safe, and aligned with the existing Next.js API architecture and caching flow.
Hi @Priyanshu-byte-coder, I would like to work on this issue under GSSoC 2026. I’m interested in implementing the real-time metric updates feature using GitHub webhooks and would love to contribute to this enhancement. Please assign this issue to me. Thanks!
/assign
Hey @maria-453 — this issue was assigned a while back with no recent activity. Unassigning so it's available for Hacktoberfest contributors. Still working on it? Comment and we'll reassign you.
Assigned to @Priyanshu-byte-coder! You have 7 days to open a PR. No PR after 7 days = auto-unassigned so others can pick it up. Good luck!