One room, one booking.
How SETSPACE stops double bookings, keeps three time zones straight and adds the right tax.

The database says no.
Two people can press Pay on the same Saturday morning in the same second. Checking availability in the app first only narrows the gap; it never closes it.
So Postgres holds the rule. An exclusion constraint refuses any two live bookings for one studio whose time ranges overlap. The loser of a race gets SQLSTATE 23P01, which the API turns into a 409 with the three nearest free slots.
Proved by npm run test:db: two parallel inserts, exactly one wins.
ALTER TABLE bookings ADD CONSTRAINT bookings_no_overlap
EXCLUDE USING gist (
studio_id WITH =,
tstzrange(start, "end", '[)') WITH &&
)
WHERE (status IN ('hold', 'requested', 'confirmed'));A hold, not a lock.
Continuing to payment inserts a hold row that the constraint already guards. It lasts ten minutes. Stale holds flip to expired before the next insert, so no cron job is needed to free a slot.
Request-to-book studios authorise the card and capture only when the host accepts.
Three time zones, one calendar.
Toronto and Montréal run on Eastern time, Calgary on Mountain, Vancouver on Pacific. Each studio stores its IANA zone; bookings are UTC instants, and every hour on screen is the studio's own local hour.
Unit tests cover spring-forward and fall-back days in each zone.
// Local wall-clock hour → UTC instant, in the studio's own zone.
// Two passes, so a DST jump between guess and answer is caught.
const wall = Date.UTC(y, m, d, hour);
const first = wall - offset(tz, wall);
return new Date(wall - offset(tz, first));Tax follows the province.
Prices are in Canadian dollars before tax. Checkout adds the studio province's sales tax on the booking and the service fee; hosts are paid the booking minus fee and tax.
| Province | Tax |
|---|---|
| Ontario | HST 13% |
| Québec | GST 5% + QST 9.975% |
| British Columbia | GST 5% |
| Alberta | GST 5% |
Who can see what.
Booking numbers run in order, so a guest's link carries a random token; without it, or the guest's or host's session, the page is a 404. The REST API never lets anyone create a booking, and sign-up can't grant itself a role.
- Next.js 15App Router, server components, server actions for sign-in.
- Payload CMS 3Runs inside the Next app: admin, auth, access rules, migrations.
- Postgres 17The exclusion constraint, and the single source of truth.
- Stripe, test modePayment Element, manual capture for requests, refunds by policy.
- Leaflet + OpenStreetMapReal maps, neighbourhood circles instead of door pins.
- Plain CSSTokens, light and dark, scroll-driven parallax with no script.
Book a room and try to break it.
Every account, studio and booking is seed data. Stripe runs in test mode.