Design a storage-locker system that supports storing and retrieving items when lockers come in multiple sizes.
Scenario
A company operates self-service locker locations (like package lockers). Each location contains many individual locker compartments of different sizes (e.g., S/M/L, or dimension-based). Couriers arrive to deposit packages; customers later retrieve them.
Functional requirements
-
Store / check-in
: Given a package (dimensions or size class) and a target location, assign a locker and generate a pickup credential (PIN/QR/code).
-
Optimal assignment
: Choose the
smallest
available locker that fits the package (minimize wasted space). If none fit, return an error.
-
Retrieve / pickup
: Given a pickup credential at a location kiosk, open the correct locker door and mark the item as picked up.
-
Expiration
: Packages expire after a configured time; expired packages may be removed by an operator.
-
Operations/admin
: Mark lockers out-of-service; support manual overrides (e.g., door jam, lost code).
Non-functional requirements
-
Low latency at kiosk/courier check-in.
-
Correctness under concurrency (multiple couriers arriving simultaneously).
-
High availability (locations may have intermittent connectivity).
-
Auditability and security (access logs).
Deliverables
-
APIs and data model
-
Core services/components and how they interact
-
Locker allocation strategy (including concurrency control)
-
Storage/consistency choices, scaling strategy, and failure handling