System Design – Design "Amazon Locker" System
Difficulty: MEDIUMCategory: HLDFrequency: 1Asked On 2025-05-31
Problem Statement
Amazon provides a locker-based delivery system where users can choose to have their orders delivered to a secure Amazon Locker (instead of home delivery). The user then receives a pickup code or QR code and can collect their package from the locker within a certain timeframe. If not collected, the package is returned.
Your task is to design a scalable Amazon Locker system that ensures secure package delivery, efficient locker allocation, and real-time tracking.
Functional Requirements
1.User Workflow
•At checkout, allow user to select an Amazon Locker location.
•Notify user with pickup code/QR code once the package is delivered.
•User unlocks the locker by entering code/scanning QR.
2.Locker Management
•Lockers come in different sizes (small, medium, large).
•System must allocate an appropriate locker based on package size.
•Track locker availability in real-time.
3.Delivery Workflow
•Delivery personnel can open assigned locker(s) via secure API.
•Once package is deposited, locker is marked as occupied.
4.Package Expiry Handling
•Users must pick up packages within a configured time window (e.g., 3 days).
•Uncollected packages → returned to warehouse.
5.Notifications
•Notify user when package is delivered.
•Send reminders if nearing expiry.
Non-Functional Requirements
•Scalability: Must support lockers across multiple cities and millions of users.
•Availability: Highly available to avoid blocking deliveries.
•Security: Prevent unauthorized access to lockers.
•Performance: Real-time locker status updates (<1s latency).
•Fault Tolerance: Handle locker device failures, network outages, etc.
Design Considerations
•Locker Allocation
•Maintain metadata of locker locations, sizes, and availability.
•Need efficient search for nearest locker with available slot.
•APIs
•reserveLocker(packageId, location, size)
•unlockLocker(lockerId, authCode)
•getLockerStatus(lockerId)
•Metadata Store
•Store mappings: Locker → Slots → Occupied/Free.
•Track reservations and package → locker mapping.
•Authentication & Security
•OTP/QR code verification at pickup.
•Delivery agents authenticated via secure tokens.
•Failure Handling
•If locker malfunctions, reassign to another locker in the same/nearby location.
•Retry mechanism for notifications.