KatInterview

Smart Parcel Cubby Network: Reservations and Offline Kiosks

System DesignModel answer
MediumModel answerSystem Designsystem-designconcurrencyreservations

Last updated

Design a backend for networked parcel cubbies in three sizes, preventing double booking of the last cubby and staying consistent when kiosks lose connectivity.

Design a Parcel Cubby Network

A company operates self-service parcel cubbies installed in places like residential buildings and train stations. Each site has a kiosk that controls a bank of cubbies in three sizes: Small, Medium and Large. You are asked to design the backend that lets people hold a cubby, leave a parcel in it, and collect it later.

What the service must do

  • Show how many cubbies of each size are free at a given site.
  • Let a user place a time-limited hold on one cubby of a chosen size.
  • Track every cubby as EMPTY, RESERVED or OCCUPIED.
  • Handle drop-off (RESERVED to OCCUPIED) and pickup (the cubby returns to being free).

Quality requirements

  • No double booking: two users must never end up holding the same cubby, even when they compete for the last one of a size.
  • Scale: thousands of sites worldwide.
  • Availability under flaky links: a hold should still be granted when the site's kiosk is temporarily offline, and the cubby state must stay consistent once it reconnects.

What to cover

  1. API: the main endpoints for checking availability, reserving, and confirming drop-off (and pickup).
  2. Data model: tables or entities for sites, cubbies and bookings.
  3. Concurrency control: how you prevent races when many users go for the final free cubby of one size.
  4. Architecture: a high-level design that connects the central service with the distributed kiosks.

State your assumptions about traffic, hold duration and who initiates reservations, and call out the trade-offs you are making.

Hints

Hint 1

Estimate load before designing: millions of holds per day is only hundreds of writes per second at peak. Which parts of the problem are actually hard, then?

Hint 2

Consider keeping two records: one for the cubby's current state and one for the booking's lifecycle and history. What does each make easy or hard (finding a free cubby, expiry, auditing)?

Hint 3

All contention is inside a single site. How does that influence your choice of shard key, and which database mechanisms (row locks with skip-locked, conditional updates, unique constraints) can guarantee only one winner?

Hint 4

Decide who is the authority for what: the cloud for bookings, the kiosk for physical door state. What lets a kiosk open the right door while it is offline, and how do you replay its events safely afterwards?