Design a Shipping Locker System

Medium
Real World SystemsStrategyObserverSingleton

Problem Statement

Design an Amazon Locker-style shipping locker system that:

  • Manages package delivery and pickup at locker stations
  • Assigns packages to appropriately-sized lockers
  • Sends access codes to recipients
  • Handles package expiration (unclaimed packages)
  • Manages multiple locker stations

Design Requirements

Key Entities:

  • LockerStation — A physical location with multiple lockers
  • Locker — Individual locker with size and status
  • Package — Has dimensions, weight, recipient
  • Delivery — Assignment of package to locker
  • AccessCode — Time-limited code sent to recipient
  • NotificationService — Sends email/SMS notifications

Key Behaviors:

  • assignLocker(package) → finds nearest available locker, generates access code
  • pickupPackage(accessCode) → validates code, opens locker, marks as collected
  • expireOldPackages() → returns unclaimed packages after 3 days

!Constraints

- Locker sizes: Small (< 1kg, < 30cm), Medium (< 5kg, < 60cm), Large (< 25kg, < 120cm) - Access code is 6-digit numeric, expires in 72 hours - Package must be picked up within 3 days or is returned to sender - One package per locker at a time - Locker station has 5–50 lockers of mixed sizes
Output

Run your code to see output here.