Inventory Management System

Difficulty: MEDIUMCategory: LLDFrequency: 1Asked On 2023-01-02

Problem Statement

Design and implement an Inventory Management System (IMS) to manage stock levels, track product movements, and support multiple warehouses. Focus on efficient stock tracking, order fulfillment, and reporting.


Functional Requirements (FR)


Product Management


•Add, update, and remove products.
•Maintain product attributes: name, SKU, category, price, supplier info.


Stock Management


•Track stock levels per warehouse.
•Handle stock-in (adding inventory) and stock-out (removal due to sales/orders).
•Support minimum/maximum stock alerts.


Warehouse Management


•Manage multiple warehouses.
•Track inventory location and transfer stock between warehouses.


Order & Fulfillment


•Reserve stock for incoming orders.
•Update inventory once orders are fulfilled or canceled.


Reporting & Analytics


•Generate stock reports, low-stock alerts, and product movement history.
•Optional analytics: top-selling products, slow-moving inventory.


Optional Features


•Support batch numbers, expiration dates.
•Integration with barcode scanners.
•User role management (admin, warehouse manager).


Non-Functional Requirements (NFR)


•Performance → Fast lookup and updates for inventory.
•Scalability → Handle thousands of products across multiple warehouses.
•Consistency → Ensure stock levels are accurate in real-time.
•Availability → System should support 24/7 operations.


Core Entities & Attributes


Product


•productId, name, SKU, category, price, supplierInfo


InventoryItem


•productId, warehouseId, quantity, batchNumber (optional), expiryDate (optional)


Warehouse


•warehouseId, name, location, capacity


Order (Optional)


•orderId, productId, quantity, status, reservedAt, fulfilledAt


User


•userId, name, role (admin/manager/staff)


Core Components


ProductService


•Manage product creation, updates, and deletion.


InventoryService


•Handle stock-in, stock-out, and transfers between warehouses.
•Maintain current stock levels per product per warehouse.


OrderService


•Reserve stock for orders and update inventory after fulfillment.


WarehouseService


•Manage multiple warehouses and their capacities.


ReportingService


•Generate stock reports, low-stock alerts, and analytics.


APIs / Operations


Product APIs


•addProduct(product)
•updateProduct(productId, details)
•getProduct(productId)
•deleteProduct(productId)


Inventory APIs


•addStock(productId, warehouseId, quantity)
•removeStock(productId, warehouseId, quantity)
•transferStock(productId, fromWarehouseId, toWarehouseId, quantity)
•getStockLevel(productId, warehouseId)


Order APIs (Optional)


•reserveStock(orderId, productId, quantity)
•fulfillOrder(orderId)


Reporting APIs


•getLowStockProducts(threshold)
•getProductMovementHistory(productId)


LLD Design Goals


•Class Diagram → Product, InventoryItem, Warehouse, Order, User, Services.


Design Patterns:


•Singleton → For centralized inventory tracking.
•Observer → Notify admins/managers on low stock.
•Factory → For creating products and orders.
•Concurrency Handling → Ensure thread-safe stock updates to prevent race conditions.
•Trade-offs →1. Real-time stock updates vs. batched updates for performance.2. Normalized database vs. denormalized for fast queries.


Solution

Comments