Design Vaccination Centre Reservations
Model centre availability and slot reservations that protect both place capacity and shared doses under concurrency.
Design the low-level objects and contracts for choosing a vaccination centre,viewing availability and booking a slot without overbooking or promising doses that are unavailable.
For this exercise, assume one in-memory process with concurrent callers,one clinic day and one vaccine per centre. Each slot has a nonnegative remaining capacity; all slots at a centre share a nonnegative dose stock. Each confirmed booking consumes one place from the chosen slot and one centre dose together,or neither.
A successful booking returns a stable booking ID. Unknown centre/slot IDs or either exhausted resource reject without changing any state. Availability returns a coherent snapshot,but viewing it reserves nothing and it may be stale before booking. Different centres have independent stock.
Design the object model,operation contracts and interactions,including two callers competing for the last centre dose through different slots. No implementation code is required. For this exercise, assume inputs are valid identifiers and distinct calls are distinct booking attempts.
Person-based eligibility/limits,request-retry deduplication,healthcare records,payments,authentication,persistence and UI are outside scope.
For the follow-up, assume a booking is active or cancelled before the clinic starts. Cancellation restores its slot place and dose together exactly once. Repeated or concurrent cancellation returns already cancelled without changing counters; unknown booking IDs also leave state unchanged.
Explain the extension and controlled tests,including cancellation racing with a new booking.