Design Inventory Management System
Difficulty: MEDIUMCategory: LLDFrequency: 1Asked On 2024-12-15
Problem Statement
Design a system to manage inventory for a warehouse, retail store, or e-commerce platform. The focus is on object-oriented design, modularity, and tracking inventory operations such as stock in, stock out, and reporting.
✅ Functional Requirements
1.Product Management
•Store product details: productId, name, category, price, quantityAvailable.
•Support CRUD operations on product records.
2.Inventory Operations
•Stock In: Add new stock for a product.
•Stock Out: Deduct stock when products are sold or shipped.
•Track inventory history for all operations.
3.Supplier & Purchase Management (Optional)
•Maintain supplier details and purchase orders.
•Track deliveries and expected stock arrival.
4.Reporting
•Get current stock levels for all products.
•Alert for low stock products.
•Generate historical reports of stock movement.
5.Optional Features
•Support multiple warehouses or storage locations.
•Track batch numbers, expiry dates (for perishable goods).
•Role-based access control for inventory operations.
🔐 Constraints & Assumptions
•Each product has a unique productId.
•Stock quantity is a non-negative integer.
•Focus is on LLD and internal operations, not UI or frontend.
🧱 Key Components & Classes
1.Product Class
1
2class Product {
3private:
4 int productId;
5 string name;
6 string category;
7 double price;
8 int quantityAvailable;
9public:
10 void addStock(int quantity);
11 void removeStock(int quantity);
12 int getQuantity();
13};1.InventoryOperation Class
1
2class InventoryOperation {
3private:
4 int operationId;
5 int productId;
6 string operationType; // STOCK_IN, STOCK_OUT
7 int quantity;
8 DateTime timestamp;
9public:
10 void logOperation();
11};1.InventoryManager Class
1
2class InventoryManager {
3private:
4 unordered_map<int, Product*> products; // productId -> Product
5 vector<InventoryOperation*> operationHistory;
6public:
7 void addProduct(Product* product);
8 void removeProduct(int productId);
9 void stockIn(int productId, int quantity);
10 void stockOut(int productId, int quantity);
11 vector<Product*> getLowStockProducts(int threshold);
12 vector<InventoryOperation*> getOperationHistory();
13};1.Supplier / Warehouse Classes (Optional)
•Manage multiple suppliers or warehouse locations.
🔄 Example Workflow
1.Add a new product: InventoryManager.addProduct(product).
2.Receive stock: InventoryManager.stockIn(productId, quantity).
3.Ship or sell products: InventoryManager.stockOut(productId, quantity).
4.Generate reports:
•Low stock products → getLowStockProducts(threshold)
•Stock movement history → getOperationHistory().
🧪 Expected Deliverables
•Class diagram showing Product, InventoryOperation, and InventoryManager.
•Implementation of stock in, stock out, and history tracking.
•Test cases:
•Adding/removing products
•Stock in/out operations
•Low stock alerts
•Operation history logging
💡 Discussion Points
•Handling concurrent stock updates.
•Extensibility for multiple warehouses and batch tracking.
•Data structures for fast lookup and inventory history retrieval.
•Optional: integration with purchase order and supplier management.