Back to LLD explorer
OOD / Allocation Patterns: Strategy, Factory

Amazon Locker

Medium

Problem Summary

Design a package delivery locker system that matches packages to available lockers, manages security PINs, and handles returns.

Functional Scope

  • Locker sizes must match package dimensions (Small, Medium, Large).
  • Generate a secure 6-digit PIN on package delivery for customer pickup.
  • Enforce pickup timeout limits (release locker if not claimed in 3 days).

Entity-Relationship (ER) Schema

LockerService [1] <---> [*] Locker
Locker [1] <---> [0..1] Package

Design Approach

Optimize matching using dynamic strategies (first fit, best fit). Use background cron processes to clean expired locks and flag unclaimed lockers.

Core Classes & Models

LockerService (Coordinator)Locker (ID, size, availability, PIN, expiry)Package (Size, Tracking ID)
Code Blueprint
public class Locker {
    private String id;
    private boolean isAvailable = true;
    public synchronized boolean lock() { return true; }
}