A gamified GitHub Pull Request tracking and leaderboard system with real-time updates, streak tracking, weekly challenges, and achievement badges.
- 📊 PR & Review Tracking - Automatic daily fetching of merged PRs and code reviews
- 🏅 Progressive Badge System - Awards at 1, 10, 50, 100, 500, 1000 milestones
- 💵 Bill/Vonette Awards - Custom reward system for top contributors
- 📈 Historical Data - Time-series contribution and review tracking
- 👥 Multi-Timeframe Leaderboards - All-Time, Quarterly, and 4 category views (PRs, reviews, points, streaks)
- 🏆 Quarterly Competition - Fresh quarterly leaderboards with automatic reset and winner archiving
- 📜 Hall of Fame - Historical archive of past quarterly champions and top 3 contributors
- Live Updates - Leaderboard updates without page refresh
- Toast Notifications - Real-time alerts for:
- Badge awards
- Challenge completions
- Streak milestones
- PR merges
- Broadcast System - Updates pushed to all connected clients
- Auto-reconnection - Handles network interruptions gracefully
-
🔥 Workweek Streak Tracking
- Tracks both PR merges and code reviews as contributions
- Business day streaks (Mon-Fri) - weekends don't break streaks!
- Streak continues across weekends (Friday → Monday = streak maintained)
- Streak badges: Week Warrior (7d), Monthly Master (30d), Quarter Champion (90d), Year-Long Hero (365d)
- Streak leaderboard with real-time updates
- Smart notifications for streak milestones and breaks
-
⭐ Points System
- Base points for PRs (10pts) and reviews (5pts)
- Label-based bonuses:
- Bug fix: +5 bonus
- Feature: +10 bonus
- Documentation: base points
- Points history with timestamps
- Points leaderboard
-
🎯 Weekly Challenges
- Auto-generated every Monday (3 new challenges)
- Challenge types: PR merges, code reviews, streaks, points
- Difficulty levels: Easy, Medium, Hard
- Real-time progress tracking
- Challenge leaderboards
- Point rewards: 100-500 pts based on difficulty
- Achievement system for completions
- 🌓 Dark Mode - Theme toggle with persistence
- 🎭 Design System - 60+ CSS custom properties (design tokens)
- ✨ Smooth Animations - fadeIn, slideInUp, scaleIn transitions
- 🃏 Card Components - Modern card-based layouts with hover effects
- 🔔 Toast System - 5 notification types (success, info, warning, error, achievement)
- 📱 Responsive Design - Mobile-first approach with breakpoints
- 🎛️ Utility Classes - Comprehensive spacing, color, and layout utilities
- Jest Framework - ES modules support
- 69 Test Cases covering:
- Unit tests for streak service (24 tests)
- Unit tests for challenge service (27 tests)
- Integration tests for WebSocket (18 tests)
- 75-80% Coverage for gamification features
- Mock Implementations for external dependencies
- Node.js >= 18.0.0
- PostgreSQL database (local or Neon)
- GitHub Personal Access Token with repo access
- Clone the repository
git clone https://github.com/yourusername/game-ops.git
cd game-ops- Set up PostgreSQL database
Option A: Local PostgreSQL
# Install PostgreSQL (macOS)
brew install postgresql@15
brew services start postgresql@15
# Create database
createdb game_opsOption B: Neon (Cloud PostgreSQL - Recommended)
- Sign up at neon.tech
- Create a new project
- Copy the connection string
- Set up environment variables
cd app
cp .env.example .envEdit .env and add your credentials:
# GitHub API
GITHUB_TOKEN=your_github_token_here
# PostgreSQL Database (use one)
DATABASE_URL=postgresql://user:password@localhost:5432/game_ops
# OR for Neon:
DATABASE_URL=postgresql://user:[email protected]/game_ops?sslmode=require
# Session & App Config
SESSION_SECRET=your_random_secret_here
NODE_ENV=development
PORT=3000
# Optional: Enable Prisma query logging for debugging
PRISMA_LOGGING=true
LOG_LEVEL=debug- Install dependencies and initialize database
npm install
# Run Prisma migrations to set up database schema
npx prisma migrate deploy
# Generate Prisma Client
npx prisma generate
# (Optional) Seed initial data
npm run seed- Start the application
npm startThe app will be available at http://localhost:3000
# Build and run with Docker Compose (includes PostgreSQL)
docker-compose up --build
# Access points:
# - Application: http://localhost:3000
# - PostgreSQL: localhost:5432 (use pgAdmin or similar)Prisma Studio - Visual database browser:
cd app
npx prisma studio
# Opens at http://localhost:5555Migrations:
# Create a new migration after schema changes
npx prisma migrate dev --name description_of_changes
# Apply migrations in production
npx prisma migrate deploy
# Reset database (development only - WARNING: deletes all data)
npx prisma migrate reset-
View Your Stats
- Navigate to the homepage to see the main leaderboard
- Find your username to view your PR count, reviews, badges, and streak
-
Join Challenges
- Visit
/challengespage - Browse active weekly challenges
- Click "Join Challenge" to participate
- Track your progress in real-time
- Visit
-
Track Your Streak
- Make daily contributions to build your streak
- Earn streak badges at 7, 30, 90, and 365-day milestones
- View your current and longest streak on your profile
-
Earn Points
- Merge PRs: 10 points base
- Review code: 5 points
- Add labels to PRs for bonuses:
bugorfixlabel: +5 pointsfeatureorenhancementlabel: +10 points
-
Access Admin Dashboard
- Navigate to
/admin(requires authentication)
- Navigate to
-
Manual Operations
- Trigger PR fetch manually
- Award badges manually
- View system statistics
-
Monitor Challenges
- View all active and expired challenges
- See participant counts and progress
- Backend: Express.js with ES modules
- Database: PostgreSQL (Neon) with Prisma ORM
- Real-time: Socket.IO for WebSocket communication
- GitHub: Octokit REST API for PR/review data
- Scheduling: node-cron for automated tasks
- Frontend: EJS templates, vanilla JavaScript, modern CSS
- Authentication: GitHub OAuth via Passport.js
- Testing: Jest with ES modules
app/
├── scoreboard.js # Server entry point with Socket.IO
├── controllers/ # Request handlers
├── services/ # Business logic (contributor, streak, challenge, achievement)
├── lib/ # Prisma client singleton with logging
├── prisma/ # Prisma schema and migrations
├── routes/ # API endpoints
├── utils/ # Utilities (socketEmitter, logger)
├── views/ # EJS templates
├── public/ # Static assets (CSS, JS, images)
└── __tests__/ # Unit and integration tests
Contributor:
- Basic info: username, githubId, avatar, bio
- Statistics: prCount, reviewCount, points, currentStreak, longestStreak
- Badges: milestone tracking flags (bill/vonette awards)
- Relations: One-to-many with Contribution, Badge, Achievement
- Quarterly tracking: quarterlyPRs, quarterlyReviews, quarterlyPoints
Contribution:
- Tracking: type (PR/REVIEW), date, url, repository, title
- Metadata: labels[], size, isBugFix, isFeature
- Points: calculated points for each contribution
- Relation: Many-to-one with Contributor
Badge:
- Badge info: name, type, description, imageUrl
- Award tracking: contributorId, awardedAt
- Relation: Many-to-one with Contributor
Achievement:
- Achievement data: name, description, icon, category
- Progress: currentValue, targetValue, isCompleted
- Metadata: completedAt, pointsAwarded
- Relation: Many-to-one with Contributor
Challenge:
- Metadata: title, description, type, target, difficulty
- Status: active, expiresAt
- Points: reward points based on difficulty
- Participants: JSON array with progress tracking
- Timestamps: createdAt, updatedAt
QuarterSettings:
- System type: calendar, fiscal, academic, custom
- Configuration: Q1 start month (1-12)
- Singleton pattern for single configuration
QuarterlyWinner:
- Quarter identification: quarterKey (YYYY-QX format)
- Winner details: username, avatar, quarterlyStats
- Top 3 contributors: rank, username, stats
- Metadata: totalParticipants, archivedAt
Required:
GITHUB_TOKEN- GitHub PAT with repo accessDATABASE_URL- PostgreSQL connection stringSESSION_SECRET- Session encryption keyNODE_ENV- 'development' or 'production'
Optional:
PORT- Server port (default: 3000)GITHUB_CLIENT_ID- OAuth app IDGITHUB_CLIENT_SECRET- OAuth app secretGITHUB_CALLBACK_URL- OAuth callbackPRISMA_LOGGING- Enable detailed query logging ('true'/'false')LOG_LEVEL- Application log level (error/warn/info/debug)
Database Connection String Format:
# Local PostgreSQL
DATABASE_URL=postgresql://username:password@localhost:5432/database_name
# Neon (recommended for production)
DATABASE_URL=postgresql://username:[email protected]/database_name?sslmode=require
# Connection pool tuning (optional)
DATABASE_URL=postgresql://user:pass@host:5432/db?connection_limit=20&pool_timeout=20Edit app/config/points-config.js to customize point values:
export const POINTS = {
PR_MERGED: 10,
PR_REVIEWED: 5,
BUG_FIX_BONUS: 5,
FEATURE_BONUS: 10,
DOCUMENTATION_BONUS: 0
};GET /api/contributors- Get all contributorsGET /api/contributors/:username- Get specific contributorGET /api/contributors/:username/stats- Get detailed stats
GET /api/challenges- Get active challengesGET /api/challenges/:id- Get specific challengePOST /api/challenges/join- Join a challengeGET /api/challenges/:id/leaderboard- Get challenge rankingsGET /api/challenges/user/:username- Get user's challenges
GET /api/streaks/leaderboard- Get streak rankingsGET /api/streaks/:username- Get user's streak stats
GET /api/leaderboard/all-time- Get all-time rankings by total pointsGET /api/leaderboard/quarterly- Get current quarter rankingsGET /api/leaderboard/quarterly/:quarter- Get specific quarter rankingsGET /api/leaderboard/hall-of-fame- Get past quarterly winners
GET /api/admin/quarter-config- Get quarter configurationPOST /api/admin/quarter-config- Update quarter system (requires auth)
GET /api/admin/pr-range-info- Get PR fetch range and database statisticsGET /api/admin/duplicate-check- Check for duplicate PRs/reviewsPOST /api/admin/fix-duplicates- Repair duplicate data (requires auth)
Server → Client:
leaderboard-update- Leaderboard data changedpr-update- New PR mergedbadge-awarded- Badge awarded to userstreak-update- Streak continuedstreak-broken- Streak brokenchallenge-progress- Challenge progress updatedchallenge-completed- Challenge completed
For detailed API documentation, see docs/API.md (coming soon).
- Fetch yesterday's merged PRs
- Award milestone badges
- Verify and update contributor streaks
- Award streak badges
- Check for new quarter and reset if needed
- Archive top 3 contributors to Hall of Fame
- Reset all quarterly stats to 0
- Broadcast quarter change notifications
- Generate 3 new weekly challenges
- Mark expired challenges
cd app
npm test # Run all tests
npm run test:watch # Watch mode
npm run test:coverage # With coverage report- Unit Tests: 157 passing
- Contributor service (badge awards, points)
- Streak service (24 tests - tracking, badges, notifications)
- Challenge service (27 tests - creation, joining, progress)
- Quarterly service (leaderboards, resets, archiving)
- Badge service (awards, milestones)
- Achievement service (tracking, awarding)
- Duplicate detection (6 tests - PR/review deduplication)
- Integration Tests: 37 test cases
- API endpoints (18 tests)
- WebSocket communication (19 tests)
- Coverage: ~80% for core features
import { PrismaClient } from '@prisma/client';
const prisma = new PrismaClient();
afterEach(async () => {
await prisma.contributor.deleteMany();
});
it('should award streak badge', async () => {
const contributor = await prisma.contributor.create({
data: { username: 'test', currentStreak: 7 }
});
const badges = await checkStreakBadges(contributor);
expect(badges).toHaveLength(1);
expect(badges[0].name).toBe('Week Warrior');
});- Real-time updates with Socket.IO
- Streak tracking system
- Points system with bonuses
- Weekly challenges
- Modern UI with dark mode
- Comprehensive testing
- PR range visibility and duplicate detection
- Data integrity validation and repair tools
- Multi-timeframe leaderboards (All-Time, Quarterly, Hall of Fame)
- Configurable quarter calculation (Calendar, Fiscal, Academic, Custom)
- Automatic quarter boundary detection and reset
- Winner archiving to Hall of Fame
- Historical data backfill (27 quarters archived from 2019-2025)
- Modern Hall of Fame UI with compact cards
- Quarterly stats tracking per contributor
- Admin quarter configuration panel
- Team challenges
- Custom achievement creation
- Analytics dashboard with time-series visualizations
- Mobile app (React Native)
- Integration with Slack/Discord
- Multi-repository support
- Organization-wide leaderboards
- Custom badge designs
- Advanced analytics
- SSO integration
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow ES module syntax
- Write tests for new features
- Update documentation
- Follow existing code style
- Test with
npm testbefore committing
This project is licensed under the MIT License - see the LICENSE file for details.
- GitHub API - For providing comprehensive PR and review data
- Prisma - For powerful and type-safe database access
- PostgreSQL - For reliable relational data storage
- Neon - For serverless PostgreSQL hosting
- Socket.IO - For real-time communication
- Express.js - For robust server framework
- Jest - For comprehensive testing
For questions, issues, or feature requests:
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Email: [email protected]
- Architecture Guide: CLAUDE.md - Detailed architecture and implementation details
- Prisma Monitoring: docs/PRISMA_MONITORING.md - Database monitoring and optimization
- API Documentation: docs/API.md - Complete API reference
- Deployment Guide: docs/DEPLOYMENT.md - Production deployment instructions
- Phase Summaries: DoNotCommit/ - Detailed development phase summaries
Built with ❤️ by Luis Rodriguez and Claude Code
Last Updated: January 2025 - Migrated to Prisma/PostgreSQL (Neon)