Lovable prompt to build a booking / scheduling app
Scheduling apps live or die on two things, timezone correctness and what happens when two people grab the same slot. This prompt gives Lovable a unique constraint to lean on, timestamptz storage rules, and both provider and client screens, so the race ends in a polite message instead of a double booking.
Last updated
Build a booking app where providers publish availability and clients reserve slots. Roles: a role field on profiles distinguishing provider from client, with separate home screens after login. Provider side: a weekly availability editor with day rows and add-window buttons creating availability_windows rows holding weekday, start_time, end_time, and slot length, plus a blocked_dates table for one-off days off. A bookings list shows upcoming appointments with a cancel action. Client side: a provider page with a week view generated from the windows minus existing bookings and blocked dates, rendering every open slot as a button in the client's local timezone with the provider's zone noted. Choosing a slot opens a confirmation showing date, time, and duration before the insert. Double-booking: the bookings table carries a unique constraint on provider_id plus starts_at, the insert catches the conflict error, and the client sees a slot-just-taken message with the calendar refreshed. Cancellation: clients may cancel until a cutoff-hours value the provider sets, after which the button is disabled with the reason shown. Cancelled slots reopen immediately. Timezones: store starts_at as timestamptz, never as separate date and time strings, and render in the viewer's zone everywhere. States: providers with no windows see setup guidance, clients see a no-availability message with next-week navigation, and past weeks are read-only. Acceptance: two browsers booking the same slot at once produce one booking and one polite conflict, a client in one timezone viewing a provider in another sees converted times, and cancelling reopens the slot on both calendars.
Same task in other tools
Questions about this prompt
What actually prevents two clients from taking one slot?
The unique constraint on provider_id plus starts_at makes Postgres reject the second insert regardless of what either UI showed. The prompt has the client catch that error and refresh, the database is the referee.
How do I support variable appointment lengths?
Add a services table with durations, or a per-window slot length, and have Lovable generate slots from the chosen service. Conflict handling then extends to an overlap check rather than exact start equality.
Slots render an hour off for some users. Why?
Somewhere a date is being rebuilt from strings instead of the stored timestamptz, usually in the week grid. Tell Lovable to derive display times from the timestamp in the viewer's zone and never concatenate date and time text.