Design Cricbuzz — Live Cricket Score Platform
HardReal World SystemsObserver PatternLive UpdatesPub-SubReal-timeSports Domain
Problem Statement
Design a live cricket score platform like Cricbuzz that tracks ongoing matches in real-time and notifies subscribers of score updates, wickets, milestones, and match results.
Design Requirements
Functional Requirements
- Multiple simultaneous matches (Test, ODI, T20) running in parallel
- Ball-by-ball score updates: runs scored, wicket fell, extras, over completion
- Match state: innings, batting/bowling teams, current batsmen, current bowlers
- Scorecard: per-batsman (runs, balls, 4s, 6s, SR), per-bowler (overs, runs, wickets, economy)
- Commentary feed: auto-generated ball-by-ball commentary string
- Subscribe/unsubscribe to a match — receive push notifications on key events (wicket, milestone, over)
- Milestone detection: 50s, 100s, 5-wicket hauls, hat-tricks
- Match result: target calculation, win by runs/wickets, tie/super over
- Points table update after match completion
- Search matches by status (LIVE, UPCOMING, COMPLETED), team, or date
Non-Functional Requirements
- Thread-safe concurrent match updates
- Singleton CricbuzzSystem
- Observer pattern for real-time subscriber notifications
Key Entities
- Match: id, type (TEST/ODI/T20), team1, team2, venue, status, innings[], currentInnings
- Innings: battingTeam, bowlingTeam, balls[], totalRuns, totalWickets, overs
- Ball: over, ball, bowler, batsman, runs, isWicket, wicketType, extras, commentary
- Batsman: player, runs, balls, fours, sixes, isOut, dismissalInfo
- Bowler: player, overs, maidens, runsConceded, wickets
- Player: id, name, country, role (BATSMAN/BOWLER/ALL_ROUNDER/WK)
- Team: id, name, country, players, captain, wicketKeeper
- Subscriber: userId, matchId, notificationPreferences (ALL / WICKETS_ONLY / MILESTONES)
- CricbuzzSystem: Singleton; manages matches, teams, players, subscriptions
Design Patterns to Apply
- Observer: subscribers notified on every ball, wicket, milestone
- Strategy: different scoring rules for TEST vs ODI vs T20
- Factory: create different match types
- Singleton: CricbuzzSystem as the central registry
!Constraints
- Each over has exactly 6 legal deliveries (wides/no-balls don't count)
- Test match: 2 innings per team; ODI: 50 overs; T20: 20 overs per side
- A batsman is out only once per innings
- Wicket types: BOWLED, CAUGHT, LBW, RUN_OUT, STUMPED, HIT_WICKET
- Thread-safe ball-by-ball updates
- Subscribers only notified for their chosen match and preference level
Output
Run or submit your code to see output here.