Engineering

We audited our own booking flow

Before we asked anyone to trust us with real money at scale, we read our own booking and payment code against the live database, looking for the ways it could quietly be wrong.

Published
Read
6 min

The scariest bugs in a booking system are not the ones that crash. A crash is loud; someone notices; you fix it. The scary ones are the quiet mismatches — a payment marked paid that never confirmed, two people holding the same slot, a number that is off by a rupee in a place nobody checks. So before leaning harder on real money, we sat down and audited our own booking flow against the live database, on the hunt for exactly those.

It is an uncomfortable thing to do on purpose. You are reading your own code with the assumption that it is lying to you, checking the parts you were proudest of first, because pride is where you stop looking. But it is the only honest way to earn the sentence 'you can trust us with the money,' and that sentence is the whole product.

What held

The core held, and it held for good reasons rather than luck. Two people cannot end up in the same slot, because the database itself refuses to store overlapping bookings — the guarantee lives in Postgres, not in hopeful application code that a race condition can slip past. A payment is captured exactly once, because every path that could mark a booking paid funnels through a single winner-takes-it step. And pricing is snapshotted at the moment of booking, so what you were charged can never drift because a setting changed later.

Why we trust the database over the app

Application code runs many times, on many servers, racing each other. A rule enforced in the app is a rule you hope holds under load. A rule enforced by the database — a no-overlap constraint, a uniqueness guarantee — is a rule that physically cannot break, no matter how many requests arrive at once. For anything involving money or a shared slot, we push the guarantee down to where it cannot be raced.

That last point is worth dwelling on, because it is the difference between a booking system that works in a demo and one that works on a busy Friday. When fifty people try for the same slot at once — which is not hypothetical for a popular host — the winner is decided by the database, once, and the other forty-nine get a clean 'taken,' not a double-booking to apologise for on Monday.

What we found to fix

It was not a clean bill. The audit turned up a stack of things worth fixing — none catastrophic, several embarrassing. A paid-but-unconfirmed booking had no automatic second attempt to nudge it over the line. A cancelled paid booking did not raise a flag for a refund. A reminder cron, under the wrong timing, could double-send. None of these were on fire; all of them were the kind of quiet wrong that erodes trust one small confusion at a time.

The value of writing them all down — with a severity next to each, verified against the real database rather than assumed — is that a list you can see is a list you can burn down. Deferred work that lives only in your head is deferred forever. Deferred work with a number next to it is a plan.

Read your own code as if it is lying to you, and check the parts you are proudest of first. Pride is exactly where you stopped looking.

The bit worth keeping

We publish this for the same reason we publish the security work nobody claps for: a thing written down in public is a thing you can be held to. The booking flow is sound where it counts, honest where it is not yet perfect, and the not-yet-perfect list is short and shrinking. That is the most truthful thing we can say, and we would rather say it than a slogan.

Common questions

How does Book A Sloth prevent double-booking the same slot?

The no-overlap rule is enforced by the database itself, not by application code. Postgres physically refuses to store two overlapping bookings for a host, so even under a rush of simultaneous requests only one can win the slot.

Can I be charged the wrong price if a host changes their rates?

No. Pricing is snapshotted at the moment you book, so what you were quoted is what you pay. A later change to the host’s rates cannot alter a booking that already exists.

Does a payment ever get captured twice?

No. Every path that can mark a booking paid — the checkout, the payment webhook, the reconciler — routes through a single step that only one of them can win, so capture happens exactly once.

Want this for your own bookings?

Set up your page, sync your calendar, and start getting paid at 0% commission.

Become a host