NNabeel Hassan

Blog · November 16, 2026 · 8 min read

Building a Live Leaderboard for a Mobile or Sports App: Ranks, Ties, Real-Time Sync and Corrections

By Nabeel Hassan — AI Engineer · ICPC World Finalist

TL;DR: A live leaderboard is not a sorted list with a refresh button. It is a small real-time system with five decisions you have to make on purpose: who is allowed to write a score (only the backend), how ranks and ties are defined (in writing, before launch), which time window the board covers (and in which time zone), how clients get updates (push a version, let them fetch, and reconcile on reconnect), and what happens when a score is wrong (corrections are normal, so design for them). Get those right and the board stays fast and trusted. Skip them and you get two phones showing two different winners, which is the one failure a leaderboard cannot survive.

At RAQTS, where I lead engineering as CTO, the product is a sports-tech platform that connects players and facilities. It spans a Unity interactive layer called Lumo, React Native mobile apps, and a Next.js web portal, and live leaderboards tie them together. This post is the engineering detail: how I build a leaderboard that many screens watch at once, on any stack.

Why "just sort the scores" breaks

The first version of every leaderboard is a database query: select scores, order by points, limit 50. It works in the demo. It starts failing the moment three things are true at the same time: scores change while people watch, people watch on more than one kind of device, and someone cares who is in first place.

The failures look like this:

None of these are UI problems. They are data and systems problems, and they are cheaper to design out than to patch.

Decision 1: only the backend writes scores

The rule I hold on every project with a ranking: clients submit events, the backend decides scores. A Unity experience, a mobile app or a portal can report that something happened, a session completed, a result was entered. The server validates it, computes the points, writes the score, and is the only thing that ever says what someone's rank is.

Three reasons:

  1. Consistency. If each client computes rank from its own partial view, they will disagree. One authority means one answer.
  2. Cheating and mistakes. Anything a client can write directly, a modified client can write too. Even without bad actors, buggy old app versions in the wild will send bad data, which I covered in keeping a mobile backend compatible with old app versions.
  3. Auditability. If every score change is an event with who, what and when, you can rebuild the board from history and answer "why did my rank drop?" with facts.

In practice that means a score submission endpoint that is idempotent (a retried request on a flaky mobile connection must not count twice), validates against rules the server owns, and appends to a score history before updating the current standings.

Decision 2: define ranks and ties in writing

Before writing ranking code, I write the ranking rules as a short spec and get the founder to agree to it. It is usually one paragraph, and it saves weeks of "that looks wrong" later. The questions:

Decision 3: pick the windows and time zones up front

Most products want more than one board: today, this week, this season, all time, per facility, per friend group. Each is a separate slice, and each needs a precise definition of when it starts and ends.

My defaults:

For that last point, a sorted set in Redis is the classic tool, and Redis is part of the stack I reach for regularly. Each window is one sorted set keyed like board:facility:{id}:week:{yyyy-ww}, the member is the player and the score is the points. Reading the top 50, or a single player's rank, or the five players around them, is a fast lookup instead of a sort. If the stack is already on Firebase or Postgres, the same idea works with a standings table updated on write and indexed on score. The data store matters less than the principle: compute rank when scores change, not every time someone looks.

Decision 4: how clients stay in sync

"Live" sets an expectation of seconds, not minutes. But pushing the full board to every connected client on every score change is wasteful and fragile. The pattern I prefer is simpler:

  1. Each board has a version number that increments on every change.
  2. The server pushes a small notification ("board X is now version 1042") over whatever real-time channel the stack has: WebSockets, Firebase's real-time listeners, or server-sent events for the web.
  3. The client fetches the board when it sees a version newer than the one it has, and ignores notifications about versions it already has.
  4. On reconnect, the client always refetches and compares versions, because it cannot know what it missed while the phone was in a tunnel or the app was in the background.

This keeps the push messages tiny, makes missed messages harmless, and gives every client the same converge-to-latest behaviour. With real-time off, a fetch on open gives the same answer, just later: it degrades to slow, not wrong.

Two details that matter on mobile and in Unity:

Decision 5: corrections are normal, design for them

On a real sports product, scores are entered by people and devices, and some will be wrong. The question is not whether you will need corrections but whether they are a clean operation or a database edit at midnight.

What a correction needs:

What I test before a leaderboard ships

A leaderboard looks finished long before it is. Before launch I check:

Backend checks are cheap to automate; the client ones are a short pass on real devices, the same mindset as error monitoring for a small product: you want to know about a broken board before the facility does.

The short version

A trustworthy live leaderboard comes down to a few rules: the server is the only writer, ranks and ties are defined in plain words, windows follow the venue's clock, clients converge on a versioned board instead of trusting push messages, and corrections run through the same path as everything else. It is a few extra days of work up front, and it is what lets a room full of players and a facility manager look at different screens and agree on who is winning.

If you are earlier in the product journey, the leaderboard is often also your activation moment: seeing your name on the board is when a lot of players decide the app is for them. That is one more reason to make it right.


I lead engineering as a fractional CTO and build cross-platform products across Unity, React Native, Next.js and real-time backends, along with production AI agents, for startups in the US, UK and Europe. If you are building something where many people watch the same live data and it has to be right, read more about my background or book a call.

FAQ

Should the app or the server calculate leaderboard ranks?

The server. Clients should submit events such as a completed session, and the backend validates them, computes points and owns the ranking. If each client computes rank from its own view, two screens will disagree, and anything a client can write directly a modified or outdated client can also write.

How should a leaderboard handle ties?

Decide in writing before launch: shared rank (1, 2, 2, 4), dense rank (1, 2, 2, 3), or a deterministic tie-breaker such as whoever reached the score first, then user ID. The key is determinism, so the order never flickers between refreshes or differs between devices.

How do you keep a live leaderboard in sync across devices?

Give each board a version number, push a small notification when it changes over WebSockets, Firebase listeners or server-sent events, and have clients fetch the board when they see a newer version. Always refetch on reconnect, since a phone cannot know what it missed while offline.

What is the best data structure for a leaderboard?

A precomputed standings structure per window, updated when scores change rather than sorted on every read. A Redis sorted set per board is the classic choice because top N, a single player's rank and their neighbours are fast lookups; a standings table indexed on score works too on Postgres or Firebase.

Building something in this space?

I take on AI-agent, automation and product work directly — scoped fast, shipped fast.

Book a discovery call →

Keep reading