Healthcare booking

Slot locking and double booking are solved at the architecture level, not patched at the application level.

Try the live demo →

The client-side state model

Healthcare booking SPAs load available slots into client state. The user selects a slot, the UI marks it as selected, and the booking is submitted. The problems:

  • Double booking. Two users see the same slot as available. Both select it. Both submit. The server must handle the race, but the SPA gave both users a UI that promised the slot was available.
  • Slot staleness. The slot list loaded minutes ago. Slots booked by others since load are still shown as available. The user selects a slot that no longer exists.
  • Optimistic booking. The SPA may mark a slot as booked before server confirmation. If the server rejects (slot taken, payment failed), the UI must unwind a state the user believed was confirmed.

What moves to the server under SAUI

  • Slot availability: computed from current bookings on every projection request
  • Slot locking: a SlotLocked event is appended when a user begins booking; released on completion or timeout
  • Double booking prevention: the gateway validates slot availability atomically before appending the SlotBooked event

The lock-then-book sequence is handled entirely by server-side actions. The client never holds a representation of slot availability; it receives a projection of current truth on each request.

What stays on the client

  • Calendar navigation UI state (current month view)
  • Time zone display preference (UI-only, no business meaning)
  • Form focus state

Security and correctness properties gained

Double booking is structurally prevented by the gateway atomic validation. Slot staleness is eliminated; the projection is computed from current bookings, not a cached snapshot. The lock timeout is server-enforced: an abandoned booking flow releases the slot automatically via a scheduled action.

Next: SaaS dashboards