Skip to main content

Bookings & State Machine

The Scheduler service (zs-bullmq) manages two state machines that drive meeting space availability and booking lifecycle.

Room State Machine

Tracks the immediate physical state of a meeting room.

StateMeaning
freeRoom is empty and available
upcomingA booking is about to start
occupiedRoom is currently in use
cleaningPost-meeting cleaning period

Space State Machine

Tracks the scheduling status of a meeting space, accounting for business hours and booking windows.

States

StateMeaning
available_nowFree with no upcoming booking
available_atFree now but has an upcoming booking
reservedBooking start time reached; waiting for check-in
in-maintenanceSpace is in maintenance mode
not_availableOutside business hours

Events

EventTrigger
BOOKING_CREATEDNew booking is confirmed
START_TIME_REACHEDBooking start time arrives
USER_CHECKS_INUser checks into the space
NO_SHOW_TIMEOUTUser fails to check in within grace period
USER_CHECKS_OUTUser ends their session early
END_TIME_REACHEDBooking end time arrives
BOOKING_CANCELLEDBooking is cancelled
ADMIN_DISABLEAdmin puts space in maintenance
ADMIN_ENABLEAdmin re-enables the space
DAY_STARTBusiness hours begin
DAY_ENDBusiness hours end

Scheduler Queues

The Scheduler uses three BullMQ queues:

QueuePurpose
meetingSchedulerState transition jobs (delayed, fire at exact times)
statusUpdateQueueExternal status HTTP posts back to ZenCore
webhookDeliveryQueueOutbound webhook delivery with retry

Booking Lifecycle

  1. Create — User creates a booking via API or UI
  2. Schedule — ZenCore sends scheduling jobs to BullMQ
  3. T-15 minbooking.start webhook fires; ZenEdge issues magic links and device credentials
  4. T-0START_TIME_REACHED event; space moves to reserved
  5. Check-in — User checks in; room moves to occupied
  6. End — Booking time expires or user checks out; room enters cleaning
  7. Reset — Cleaning period ends; room returns to free

Next Steps