DEV Community

Dinnes D.
Dinnes D.

Posted on Originally published at deeve.info AI-assisted

Taking over an unfinished React Native app and making sure two people can never claim the same client

Earlier this year I took over a mobile app that its previous programmer could not finish. The client was Premier Gaming Massage, a US company whose therapists work poker rooms and tournament floors. Players want a massage without leaving their seat, so the team needed one shared, live list of waiting clients on their own phones, with no tablet at every venue.

I redesigned every screen and rebuilt the app, The List, on a new codebase rather than patching what was there. It now runs on iOS and Android from one TypeScript codebase. This post covers the parts that were harder than they look.

The problem: one list, many phones, no collisions

A client scans a QR code at the venue and joins the list. Several therapists see that list at the same time. Every client has to land in the right list, in order, and be claimed by exactly one therapist. If two therapists claim the same person, two of them walk to the same table while another client keeps waiting.

That rule cannot live in the app. Two phones can both read "next client: table 12" a few milliseconds apart and both tap Claim. If the check happens on the phone, both win.

Claims are settled in the database

The app runs on Supabase: Postgres, Auth, Realtime and Storage. A claim is not an update the phone sends. It is a database function that takes the next waiting client first in, first out, locks the row while it does so, and returns who you got. A second therapist tapping at the same moment cannot take the same client, because the database settles who got there first.

The same idea runs through the public side. When a client submits from a QR code, the entry goes through database functions that validate the input, check the venue's banned numbers, rate limit by a hashed IP address and lock against duplicates. The phone only shows the result.

Access is decided by the database, not the phone

The List shares one Supabase project with a web console the office uses. Several organizations use the same tables, so every table has row level security that keeps each one to its own organization. A therapist's phone can only ever see its own organization's venues, lists and clients, because Postgres refuses to return anything else, whatever the app asks for.

Chat photos sit in a private storage bucket for the same reason.

Testing the rules that matter

The rules that would hurt most if they broke are tenant isolation, access rules and claim order, so those are tested where they live. The database carries 102 pgTAP tests covering exactly those, with Jest tests in the app alongside. When the schema changes, the tests say whether one organization could now see another's data, or whether two claims could collide.

Informed consent on the phone

Texas requires informed consent before a session. The client reads the consent form on the therapist's phone, picks the areas to be massaged and confirms with the last seven digits of their number. The therapist checks their photo ID before the record is saved.

The rest of the app

  • Every live list at a glance. The home screen shows each live list for the therapist's venues: who is waiting, who is next and who has been served, updating the moment a client joins.
  • A list that is also the team chat. Each venue or tournament list doubles as the team's chat, with replies, reactions and photos, so the event team stays on one screen.
  • Admin in the same app. Business admins manage their organization, venues, services, staff and QR codes from an Admin tab, so running a venue does not depend on a laptop.
  • Ready for both stores. Account deletion, reporting and blocking, community rules and a privacy policy are built in, as Apple and Google require.

Stack

React Native 0.81 with TypeScript, Hermes and the new architecture. React Navigation 7 for tabs and stacks, TanStack Query for server state, Supabase for the backend. Builds ship to TestFlight and Google Play through Codemagic and GitHub Actions, and signing secrets stay out of git.

What I would tell anyone taking over a half-finished app

  1. Decide early whether to patch or rebuild. Here I rebuilt on a clean codebase rather than patching someone else's unfinished decisions.
  2. Put the rules that must never break in the database, then test them there.
  3. Treat store requirements (account deletion, reporting, privacy policy) as features from day one, not a last-week scramble.

The full case study, with screenshots, is on my portfolio: The List, iOS and Android app. The web console behind it is written up there too: The List web console.

I am Dinnes, a full-stack developer working with clients in the US, Europe and Australia. More of my work is at deeve.info.

Top comments (0)