Design an Inventory Management System

Medium
Real World SystemsStock ManagementReorderMulti-LocationCRUDReporting

Problem Statement

Design an inventory management system for a retail business — tracking stock levels across multiple locations, handling stock movements (receipts, sales, transfers), and triggering reorder alerts.

Requirements

Functional Requirements

  • Product catalog: SKU, name, category, unit of measure, reorder threshold, reorder quantity
  • Multiple warehouse/store locations
  • Stock movements: RECEIVE (inbound), SELL (outbound), TRANSFER (location to location), ADJUST (manual correction)
  • Real-time stock level per product per location
  • Total stock across all locations per product
  • Low stock alert: trigger when total stock < reorderThreshold
  • Reorder suggestion: suggest reorder quantity when alert fires
  • Stock history: audit trail of all movements per product
  • Reports: stock value report (quantity × unit cost), turnover rate

Non-Functional Requirements

  • Thread-safe stock updates
  • Singleton InventoryService

Key Entities

  • Product: sku, name, category, unitCost, reorderThreshold, reorderQuantity
  • Location: id, name, type (WAREHOUSE/STORE)
  • Stock: productSku, locationId, quantity
  • StockMovement: id, product, fromLocation, toLocation, type, quantity, timestamp, reason
  • InventoryService: Singleton; manages stock, movements, alerts

Constraints

  • Stock quantity cannot go negative (overselling blocked)
  • Transfer requires sufficient stock at source location
  • Adjust movement can be negative (correction) or positive (found stock)
  • Thread-safe: concurrent sales must not allow overselling

!Constraints

- Stock quantity >= 0 at all times - Transfers blocked if source location has insufficient stock - ADJUST movements can be positive or negative - Thread-safe: concurrent SELL operations cannot oversell - Reorder alert fires asynchronously when threshold crossed
Output

Run or submit your code to see output here.