Skip to content
·11 min read

Build a Booking and Scheduling System With AI Coding Tools

How to create an appointment booking app with calendar views, time slots, confirmations, and reminders

Share

A customer needs to see an open time, reserve it, and receive the same appointment details as the person they booked. The hardest part is keeping that promise when two people choose the same time or one person moves an appointment after a reminder has already been scheduled.

If you need one host to share available times, start by deciding whether a scheduling tool can handle your booking flow. That comparison covers availability, the host’s calendar, and what happens when someone moves or cancels. Build the reservation logic yourself when the booking needs to follow rules in your own app, such as reserving a room and an instructor together.

Why Booking Systems Are Perfect AI Projects

A booking app is small enough to build in layers. Start with one provider and one appointment length. Get the server to confirm a reservation, then show available times and add messages. Ask your coding tool to explain what it checks when it saves a booking. A working calendar screen cannot tell you whether the database would accept two reservations for the same slot.

Step 1, Design Your Data Model

Every booking system revolves around three core objects: providers (the people or resources being booked), availability (when those providers are open), and bookings (the actual appointments). Get this right and the rest of the build becomes significantly easier.

Open your AI coding tool and start with this prompt:

Create a database schema for a booking system with these tables:

1. providers - id, name, email, timezone, created_at
2. availability - id, provider_id, day_of_week (0-6), start_time, end_time
3. bookings - id, provider_id, customer_name, customer_email, start_time, end_time, status (pending/confirmed/cancelled), created_at

Link each booking to its provider and index provider_id and start_time.
Require a valid time range and define which statuses reserve the slot.
Store booked instants as timezone-aware timestamps.

This schema handles the fundamental question every booking system must answer: "Is this time slot available?" To check availability, you query the availability table for the provider's open hours on that day, then subtract any existing bookings. The result is the list of open slots.

One decision you need to make early is your slot duration. Most booking systems use fixed slots (30 minutes, 60 minutes) rather than letting customers pick arbitrary times. Fixed slots simplify conflict detection enormously. Instead of checking whether two time ranges overlap, you just check whether a specific slot already has a booking.

Key Takeaway

Decide which bookings reserve a slot and what happens to them on cancellation before building the calendar. The calendar and the server should use the same rules.

Step 2, Build the Calendar View

The calendar is the centerpiece of your booking system. Customers need to see available dates, pick one, and then see available time slots for that day. This is a two-step selection process: date first, then time.

Prompt your AI tool:

Build a booking calendar component that:
- Shows a monthly calendar grid with navigation arrows
- Highlights dates that have available slots in teal
- Grays out past dates and fully booked dates
- When a date is clicked, shows available time slots below the calendar
- Each time slot is a clickable button showing the time in the user's local timezone

The AI will generate a calendar using date-fns or dayjs for date math. The calendar queries your availability endpoint for each visible month and visually distinguishes available from unavailable dates.

The two-step booking flow: pick a date from the calendar, then choose an available time slot.

A common question is whether to load all availability upfront or fetch it per month. For most booking systems with a small number of providers, loading the current month plus the next month on initial render works well. The data is small (just arrays of time ranges) and the user experience feels instant. If you are building a marketplace with hundreds of providers, you will want to fetch per-provider and per-month, but that optimization can wait.

Step 3, Handle Time Slots and Conflict Detection

This is where booking systems get tricky. You need to generate available time slots from the provider's availability, subtract existing bookings, and present what remains. All while accounting for the fact that the provider might be in New York and the customer might be in Tokyo.

Here is the prompt:

Create an API endpoint GET /api/availability/:providerId?date=2026-04-10 that:
1. Looks up the provider's availability for that day of the week
2. Generates 30-minute time slots within the available window
3. Removes any slots that overlap with existing bookings
4. Returns the remaining slots with times in UTC

Keep recurring hours in the provider’s named time zone, such as America/New_York. Convert each offered slot to a specific instant for the selected date, then return that instant for display in the customer’s time zone. The offset can change with daylight saving time. Keep the provider’s time zone separately from the saved booking instants so you can display and regenerate availability correctly.

For conflict detection, the query is straightforward: find any booking for this provider where the existing booking's start time is before the new booking's end time AND the existing booking's end time is after the new booking's start time. If that query returns any rows, the slot is taken.

SELECT id FROM bookings
WHERE provider_id = $1
  AND status != 'cancelled'
  AND start_time < $2  -- new booking end time
  AND end_time > $3    -- new booking start time

If this query returns results, the slot is not available. This overlap detection works regardless of slot duration and handles edge cases like back-to-back bookings correctly.

Step 4, Build the Booking Confirmation Flow

When a customer chooses a slot, the server must make the final decision. Two people can see the same time as free and submit it together. An availability query helps explain a conflict. A separate read followed by an insert can still let both requests through, even when each runs in an ordinary transaction.

For fixed, aligned slots, a database uniqueness rule can prevent two active bookings for the same provider and start time. If appointments can overlap even with different start times, use a rule that prevents overlapping time ranges for that provider. In PostgreSQL this can be an exclusion constraint, a rule the database checks before allowing an overlapping reservation. Ask your coding tool to show how the rule excludes cancelled bookings and allows back-to-back appointments when you have no buffer.

Ask your coding tool to implement this flow:

1. Validate the requested slot against the provider’s current schedule.
2. Save the booking using the database rule that prevents double bookings.
3. If the database rejects a conflict, show that the time was just taken and refresh the choices.
4. Queue the customer confirmation and provider notice only after the booking is saved.
5. Return the saved booking even if sending the email has to be retried.

The confirmation should include the full date, time and time zone and a link to manage the booking. Require the right account or an expiring, unguessable link to authorize a cancellation. Show a confirmation screen before changing anything, since email systems can open links automatically.

Step 5, Add Email Reminders

Schedule reminder records when a booking is saved, with a due time such as 24 hours or one hour before the appointment. A job that runs every 15 minutes can miss a five-minute lookup window entirely. Have each run look for reminders already due that still have time to be useful. Skip reminders for cancelled appointments and replace the old reminders when an appointment moves.

Give each reminder a unique key made from the booking, its schedule revision and the kind of reminder. Increase the revision each time the booking moves, even if it returns to its original time. Have the worker claim pending work and check that the reminder still matches the booking’s current revision before sending.

If a send fails before the provider accepts it, the worker can retry while the reminder is still useful. If the connection drops after you submit the send, the provider might already have accepted it. Retry the same request with the same key only when the provider supports that protection and its retry window is still open. Otherwise, look for the original attempt in the provider’s records. If you still cannot tell whether it was accepted, leave it for review and skip the automatic resend.

Every booking triggers a chain of automated communications, from confirmation through reminders to the appointment itself.

Step 6, Handle Edge Cases That Break Booking Systems

Try these three cases before sharing the booking page.

Cancellations and rescheduling. Keep the original time if the replacement cannot be saved. Make the booking change together with cancelling or replacing its pending reminders. Check that old links and emails still lead to the current booking state.

Buffer time. Add 10-15 minutes of configurable buffer between slots. Expand each booking by the buffer amount before checking overlaps.

Booking limits. Add minimum_notice (e.g., 2 hours) and maximum_advance_days (e.g., 30 days) fields to prevent last-minute and far-future bookings.

Apply the same buffer and booking limits when the server saves the reservation. Hiding a slot in the calendar only changes what the page offers.

Testing Your Booking System

Use a disposable copy with fictional bookings. Before opening it, verify its database, calendar, email and scheduled-job connections. Use a test calendar and a mail catcher you control, and confirm that no fallback points at live systems. If you cannot confirm the connections, rehearse the expected results on paper.

  1. Open the same free slot in two browsers and submit both reservations at nearly the same time. Check that only one is saved and only that booking queues confirmations.
  2. Move an appointment to a time that was just taken. The original appointment should remain in place, and its reminders should still be scheduled.
  3. Cancel a booking and check that its slot becomes available and its pending reminders are skipped.
  4. Try a date near a daylight saving change and one near midnight. Verify the displayed date and time in both the customer’s and the provider’s time zones.
  5. Let a reminder become due between two scheduled runs. Make the test mail connection fail before it accepts the send. Check that the worker leaves the reminder pending, then picks up the same due record on the next run.
  6. If your isolated mail setup supports retry keys, simulate losing the response after the provider accepts a send. Retry the same request with the same key within the documented window. Check for one accepted send in the provider records. If the test setup lets you inspect delivery too, verify that exactly one message reached the test inbox. If you cannot demonstrate that retry protection, rehearse this case on paper.
  7. Move a fictional booking from one time to another and then back again. Check that each move creates a new revision and only the latest revision has an active reminder.

What This Means For You

Start with one appointment length and two fictional customers. Before polishing the calendar, confirm that only one of them can reserve the same time. Once that works, test moving a booking and sending its reminders. Each stage has a result you can check before adding more rules.

PJ
Pranay Joshi

20+ years building products at scale. VP of Product & Engineering, startup founder, and AI coach. Helping dreamers turn ideas into reality with vibe coding.