LIVE · Google PlayCase study · Kridaz

Kridaz: booking a sports court with money involved, and no double-bookings.

Two players can tap the same 6:30 slot at the same second. I built the Flutter app and the Supabase backend so that only one of them can ever pay for it.

Role
Flutter app, Supabase backend, Next.js admin
Users
Players · venue owners · admins
Stack
Flutter · Riverpod · Supabase · Razorpay
Kridaz app icon
The problem

Bookings, payments and refunds have to agree, even when the network doesn't.

Players pay part online and part at the venue, repeat bookings weekly and cancel late. Owners need today's bookings and revenue. A payment that succeeds while the app is offline must still end up as a booking.

How it works

The database is the referee; the app and the webhook just ask it.

  1. Flutter app
    player + owner roles
  2. Supabase Postgres
    slot holds · constraints
  3. Razorpay
    checkout · webhooks
BOOKPick slot → atomic hold in Postgres → Razorpay checkout → webhook confirms payment → booking + QR entry pass + invoice
RECOVERPayment succeeded but the app closed → webhook and a reconcile job finish the booking; safe retries never charge twice
Key decisions

Trade-offs I made on purpose.

  1. 01

    Block double-booking in the database, not the app

    A Postgres exclusion constraint on court and time range means two overlapping bookings cannot both be saved, whatever the client does.

  2. 02

    Webhook is the source of truth for payments

    The app's success screen is not trusted on its own. The booking is confirmed when Razorpay's signed webhook arrives.

  3. 03

    One app, two roles

    Players and venue owners share one Flutter codebase and one backend; role-based screens keep the release process single.

  4. 04

    Phone OTP sign-in

    Players in the target market sign in with a phone number, not an email and password.

From the code
// bookings_wallet_money_path.sql
alter table public.court_slots
  add constraint court_slots_no_overlap
  exclude using gist (
    court_id with =,
    tstzrange(starts_at, ends_at, '[)') with &&
  )
  where (status in ('available', 'held', 'booked', 'blocked'));
Need this on your team?Let's talk