Back

How We Built an Offline-First Snooker Club ERP: PWA, Real-Time Elo Ratings & “Who Lost” Billing

Table of Contents

The Hidden Software Complexity of a Snooker Lounge

To an outside observer, a snooker or pool club seems simple: customers pick a table, play a game, drink a beverage, and pay before leaving.

When you inspect the operational reality of managing a commercial snooker lounge, however, you discover a uniquely demanding set of software requirements that generic retail POS systems completely fail to handle.

In this engineering deep dive, we walk through the real-world technical decisions, state architecture, and UI paradigms we designed at CodXpert to build “The Commons”: a resilient, offline-first snooker club ERP that handles power failures, competitive Elo ratings, and automated loser-pays debt reconciliation.

The Three Hard Problems Traditional Web Apps Cannot Solve in a Club

Problem 1: The Zero-Downtime Requirement during Power Cuts:

Snooker lounges experience occasional electrical power fluctuations. When electricity drops, Wi-Fi routers turn off instantly. A traditional cloud application immediately freezes or loses unsaved timer state, resulting in customer disputes over how many minutes were played.

Problem 2: The "Who Lost" Billing State Machine:

Unlike normal restaurants where parties split a bill evenly or pay individually, snooker has a universal social convention: the player who loses the frame pays the table fee. Traditional shopping carts do not support multi-player competitive debt routing.

Problem 3: Player Engagement & Visit Frequency:

  • Without persistent rankings, casual players play once a month. The software needed an incentive engine to turn casual visitors into everyday competitive club members.

Technical Deep Dive: Designing the Offline-First Architecture

To guarantee that counter staff can operate without internet, we built The Commons as an Offline-First Progressive Web App (PWA).

Here is how the data flow functions:

  1. Service Worker Pre-Caching: The entire application shell (HTML, bundled JavaScript, CSS, fonts, and sound effects) is stored in the browser Cache Storage API via sw.js. The app boots in under 200 milliseconds even when the device is in airplane mode.
  2. Client-Side Primary State (IndexedDB via Dexie.js): All operational state (tables, active timers, player profiles, café inventory, unpaid tabs) resides in local IndexedDB storage. Every click, timer tick, and menu addition writes to local storage first.
  3. Background Cloud Synchronization: A background sync worker monitors network status. When an internet connection is established, the queue pushes delta changes to the cloud PostgreSQL database and listens for remote updates over secure WebSockets.
pwa_online_test
power_outage_autopause

Engineering the Power Cut Auto-Pause Engine

One of our most appreciated features is the connection-aware timer pause mechanism.

Because Wi-Fi routers in clubs drop power the instant mains electricity fails, our client application continuously listens to browser network state events (window.onoffline) and ping heartbeats:

  1. When a disconnection event occurs, the system records the exact timestamp and automatically transitions all active tables into a “Power Paused” state.
  2. The UI updates with high-contrast amber warnings to inform staff that the table timers are safely locked.
  3. When power returns and the network reconnects, managers tap a single “Resume All” button. The exact duration of the power cut is subtracted from the billing clock, ensuring zero overbilling and 100 percent customer trust.
players_leaderboard_updated
who_lost_modal

The "Who Lost Pays" Billing State Machine

In standard e-commerce, an order has one buyer and one payment. In The Commons, an active match involves two or four players, a ticking hourly table rate, and in-game food orders.

When a match concludes, the operator taps “End Match”. The system renders a dedicated modal:

  1. The operator selects the losing player.
  2. The system computes the exact elapsed table minutes, converts it to currency based on table rate tier, adds any food ordered during that frame, and posts the debit to the loser account ledger.
  3. If players agree to split the bill, the operator toggles “Split Tab”, dividing the amount equally across participants in one click.

Real-Time Dynamic UPI QR Code Generation

To eliminate manual cash handling and ledger reconciliation errors, we built an on-the-fly UPI QR generation engine.

When a player is ready to settle their outstanding dues:

  1. The system constructs a standardized UPI intent URL containing the club Virtual Payment Address (VPA), merchant name, exact payable balance, and invoice transaction reference.
  2. A client-side QR renderer generates an SVG QR code directly on the counter terminal or member mobile screen.
  3. The player scans using Google Pay, PhonePe, or Paytm. Because the exact amount is locked into the QR code, there is zero possibility of underpayment or typos.
member_upi_qr_verified

Gamification Engineering: The Commons Rating (CR) Elo Algorithm

players_leaderboard_updated

To drive repeat customer engagement, we implemented the Elo rating system originally developed for international chess.

Every registered player starts with a base rating of 1000 points. After every competitive frame, the system updates ratings using this formula:

New Rating = Old Rating + K * (Actual Score – Expected Score)

Where K is set to 32. If a novice player defeats a top-tier lounge champion, they gain a massive point surge, while the favorite loses points accordingly.

Players unlock badges across six competitive tiers (Bronze to Master) and 43 achievement badges (such as “Century Break”, “Comeback King”, and “10-Match Win Streak”). This gamified system turned casual weekend visitors into daily lounge regulars.

Key Takeaways for Software Builders & Club Owners

  1. Design for the physical environment: Software for sports lounges must anticipate noise, rush hours, power cuts, and casual staff.
  2. Offline-first is mandatory for operational venues: Never build a cloud-only POS for a business whose physical revenue stops if the internet drops.
  3. Gamification creates compounding retention: Simple leaderboards and tier badges transform a standard venue into a passionate gaming community.

FAQs (Frequently Asked Questions)

An offline-first snooker club ERP is a management system that allows club staff to manage table timers, player records, café orders, and billing even without an active internet connection. In The Commons, CodXpert uses a Progressive Web App (PWA) with IndexedDB local storage to keep operations running and synchronize records with the cloud when connectivity returns.

Offline-first PWA development helps snooker and billiard clubs avoid operational interruptions caused by Wi-Fi disconnections or power failures. The Commons uses service worker caching and IndexedDB to maintain local application data, while background synchronization sends pending updates to the cloud PostgreSQL database when the connection is restored.

 

The automated “Who Lost” billing workflow lets counter staff select the losing player when a match ends. The system calculates the table charges based on elapsed playing time and configured rates, adds any in-game café orders, and records the amount in the selected player’s account ledger. Staff can also use the split-tab option to divide the bill among participants.

An Elo rating system tracks player performance by adjusting ratings after competitive matches. In The Commons, each player starts with 1,000 points, and ratings are updated using a K-factor of 32. Players can progress through six ranking tiers, from Bronze to Master, and earn achievement badges. This gamification approach gives club members more reasons to compete and return.

Build Custom Business Software with CodXpert

Do you run a sports club, entertainment venue, or hospitality business that needs custom management software? CodXpert designs, engineers, and deploys high-performance web applications tailored to your exact operational workflows.

shadab alam

Shadab Alam

Founder of CodXpert • Co-Founder of Anterpreneur & Niagara Print Express

Shadab Alam is an entrepreneur, technology strategist, and the Founder of CodXpert, as well as Co-Founder of Anterpreneur and Niagara Print Express (NPE). With expertise in software engineering, artificial intelligence, SEO, digital transformation, and business strategy, he empowers businesses to innovate, automate processes, and accelerate sustainable growth through modern technology and data-driven solutions.

Shadab Alam
Shadab Alam
https://codxpert.com
Shadab Alam is the Founder & CEO of CodXpert, a technology and digital solutions company focused on web development, software, automation, AI, SEO and business solutions. He works with businesses to build practical digital products, streamline operations and turn technology into measurable business outcomes.

This website stores cookies on your computer. Cookie Policy

Need Help?