Preparing your design workspace

Loading the problem and your saved attempt…

Design a Return Drop-Store Booking System

Model how a customer finds an eligible nearby drop store, reserves a slot, and hands over a return package.

Design and implement a return drop-store booking system. A customer should be able to book time at a nearby store and physically bring a return package there; your design should also support finding the nearest eligible stores from the customer's location.

For this exercise, assume a customer starts one return with a package size and location, searches stores within a service radius, places a five-minute hold on one available fixed-duration slot, and confirms that hold as a booking.

Each preloaded store has fixed coordinates, a maximum accepted package size, and a schedule of fixed-duration slots; a store is eligible only when it is within the radius, supports the package, and has a compatible slot. At the appointment, a clerk validates the booking and accepts the package.

Each slot has capacity for one package and each return may have at most one active booking.

Before evaluating a new hold for a return, the command lazily expires any prior expired hold for that return and releases its old slot; it also expires a stale hold owned by another return on the requested slot and clears that other return's active-booking link.

A still-live hold or confirmed booking keeps its return or slot busy. Cancellation succeeds only while the injected current time is strictly before the confirmed slot's start; at or after the start it returns CancellationWindowClosed without changing the booking, return, slot, or active index.

Acceptance atomically marks both the booking ACCEPTED and the return terminal HANDED_OFF while keeping the appointment slot consumed. An identical acceptance retry with its original idempotency key replays Accepted, but a later new-key hold or acceptance for the handed-off return is rejected.

For this exercise, assume every mutating request carries a stable idempotency key from one process-wide namespace shared by all returns, slots, and operations.

The first request to atomically claim a key binds it to one request fingerprint before any booking lookup or mutation; an identical concurrent or later retry returns the same typed result, while reuse for a different operation or input returns IdempotencyConflict before lifecycle validation and without changing domain state.

Distance is straight-line distance, and the system is in memory and single-process. Route planning, payments, customer authentication, notifications, and shipping after store handoff are out of scope.