Design a Live Cricket Score App
🏏 What is a live cricket score app? It is what millions of fans open during a match to see the score. A scorer at the ground types in what happened on every ball. The app turns that into the live score, a line of commentary per ball, the result when the match ends, and player stats that grow over a whole season.
Interviewers ask for this one under several names: Cricbuzz, ESPNcricinfo, or simply "a cricket scoreboard". They are the same design. The heart of it is one stream of ball events that several features read: the scoreboard, the commentary, the schedule's live status and the player rankings. We cover the ball-by-ball scoring and the commentary in the main design, the schedule and the stats and rankings as queries on top of it, and real-time push to fans, scorer mistakes and new kinds of rankings in Extensibility.
You do not need to know much cricket to follow along. Two teams take turns to bat. The batting team scores runs; the bowling team bowls balls in groups of six, called overs, and tries to get batters out (a wicket). An innings ends when the overs run out or the batting team has lost all its wickets. The second team then tries to score more than the first.
Requirements
"Design a live cricket score app like Cricbuzz. A scorer enters every ball. Fans see the live score, ball-by-ball commentary, the match schedule, and player stats and rankings."
The questions below pin down how much cricket we actually have to model.
Clarifying Questions
You: Which format? Test matches last five days and have four innings.
Interviewer: Limited overs only, like T20 or one-day matches. Two innings, and the number of overs per innings is set per match.
You: What does the scorer enter for each ball?
Interviewer: Runs off the bat from 0 to 6, a wicket, a wide or a no-ball. A wide or a no-ball gives the batting team one extra run and has to be bowled again. Leave out byes, run outs and runs scored off a no-ball.
You: Should we enforce cricket's rules, like a bowler not bowling two overs in a row?
Interviewer: No. The scorer is trusted. Record what they tell you.
You: Who bats first? Do we model the toss?
Interviewer: No toss. The home team bats first.
You: Where does the commentary text come from?
Interviewer: Generate a short line from each ball: who bowled to whom, and what happened. Human commentators can come later.
You: What do "stats" and "rankings" mean here?
Interviewer: Career runs and wickets per player, across all matches. Rankings are the top run scorers and the top wicket takers. Official rating points are out of scope.
You: Does the app push updates to fans, or do they ask?
Interviewer: For the design, fans ask for the score. Keep in mind that many features react to every ball.
The last answer is a hint. Every ball has to update the score, add a commentary line and change two players' stats, and the interviewer just told you more consumers are coming. That is a strong signal for one event per ball with several listeners, which we will build in the Implementation section.
💡 Interview tip: In a domain you do not know well, say so and ask for the rules you need. "I know cricket roughly; can you confirm when an innings ends?" is a fine question. Inventing rules and coding them confidently is much worse.
Final Requirements
- Teams are registered with a batting order of 2 to 11 players. Matches are scheduled between two teams with a start time and a number of overs per innings. The home team bats first.
- A scorer records each ball of a match: runs off the bat (0 to 6), a wicket, a wide or a no-ball. Wides and no-balls add one run and do not count towards the over.
- The first two players in the order open the batting; after a wicket, the next player comes in. Batters swap ends after an odd number of runs and at the end of every over.
- An innings ends when the team is all out, its overs are used up, or (in the second innings) it passes the first team's score. The app then reports the result: won by runs, won by wickets, or a tie.
- Anyone can see a match's live score or result, and the latest commentary lines, newest first.
- Anyone can list the matches starting in a time range, in start order.
- Anyone can see a player's career runs and wickets, and the top players by runs or by wickets.
Out of scope
- Test matches, the toss, rain rules and super overs.
- Byes, leg byes, run outs and runs scored off no-balls.
- Checking the rules of the game (bowler limits, field restrictions).
- Pushing updates to fans and the servers behind that (see Extensibility and /system-design/live-scores).