Replit Agent prompt to build a booking / scheduling app
Scheduling apps live or die on the double-booking race, so this prompt puts the overlap guard in Postgres and makes Replit Agent prove it with concurrent requests from the shell. Around that core it specs timezone-aware slot rendering, tokenized cancellation, and an admin week view. You get a booking flow that holds when two visitors want the same slot.
Last updated
Build a booking app in this Repl for a single provider taking appointments. React frontend, Express API, the built-in Postgres database. Plan first, list your assumptions about working hours and slot length, and let me correct them before building. Data: availability_rules for weekly working hours, bookings with starts_at and ends_at stored in UTC, and an overlap guard enforced in Postgres, via an exclusion constraint or an equivalent unique scheme, so two confirmed bookings can never collide. The database enforces this, not the request handler. Booking flow: a public page showing the next two weeks as day columns, open slots computed from the rules minus existing bookings, rendered in the visitor's browser timezone with that timezone named on screen. Picking a slot asks for name and email, then confirms with a cancellation link containing a random token. No account required. Cancellation: the tokenized link shows the booking with a cancel button, and cancelling frees the slot immediately. Expired or bogus tokens get one neutral message, no detail leaked. Admin: behind Replit Auth, a week view of confirmed bookings, blocking out time, and edits to weekly rules that affect only future slots. Race handling: two people grabbing the same slot must resolve as one success and one clear already-taken message that refreshes the grid. Prove it by firing two concurrent requests from the workspace shell and pasting both responses. Empty state: a week with no availability says when the next opening is, not just an empty grid. Done when: I book a slot in the webview, watch it vanish for a second visitor, cancel through the token link, and see it reappear.
Same task in other tools
Questions about this prompt
How is double booking actually prevented?
By a constraint in Postgres, not an availability check in the route handler, since two simultaneous requests can both pass a check. The prompt demands proof: two concurrent shell requests where exactly one succeeds and the loser gets a clear message.
Can this handle multiple providers or rooms?
Add a provider_id column to the rules and bookings tables and include it in the overlap guard so collisions are scoped per provider. The public page then needs a provider picker and the admin week view a provider filter.
Visitors see slots at the wrong times, what is the usual cause?
Times stored in local time instead of UTC, or converted twice on the way to the screen. The spec stores UTC and renders in the browser timezone with the zone named on screen, so a mismatch is visible immediately.