Design inventory management system (admin-side) for an ecommerce platform

Difficulty: MEDIUMCategory: LLDFrequency: 1Asked On 2024-12-15

Problem Statement

Designing an admin-side inventory management system for an e-commerce platform. The system allows administrators to manage products, stock levels, suppliers, and categories. Focus is on object-oriented design, modular components, and real-time stock tracking.


✅ Functional Requirements


1.Product Management
•Add, update, and delete products.
•Maintain product metadata: productId, name, category, price, SKU, description, images.
•Support multiple variants (size, color, etc.).
2.Category & Supplier Management
•Create and manage product categories and subcategories.
•Maintain supplier information: supplierId, name, contactDetails.
•Assign products to suppliers and categories.
3.Stock Management
•Track stock quantity per product/variant.
•Support stock updates on addition, sale, or return.
•Alert when stock falls below threshold (low stock notification).
4.Inventory Reports
•Generate reports for stock levels, product sales, and supplier performance.
•Support export of reports (CSV, Excel).
5.Access Control
•Only admins or authorized personnel can perform inventory operations.
•Maintain audit logs for changes to inventory or products.
6.Optional Features
•Batch updates for stock or product information.
•Integration with e-commerce frontend for real-time stock availability.


🔐 Constraints & Assumptions


•Focus is on LLD, class design, and modular architecture, not UI design.
•Stock updates can happen concurrently (e.g., multiple admins or automated updates).
•The system should handle thousands of products and variants efficiently.


🧱 Key Components & Classes


1.Product Class
1 2class Product { 3private: 4 string productId; 5 string name; 6 string description; 7 double price; 8 string sku; 9 vector<ProductVariant*> variants; 10 Category* category; 11 Supplier* supplier; 12public: 13 void updatePrice(double newPrice); 14 void updateStock(int quantityChange, string variantId); 15};
1.ProductVariant Class
1 2class ProductVariant { 3private: 4 string variantId; 5 string color; 6 string size; 7 int stockQuantity; 8public: 9 void updateStock(int quantityChange); 10};
1.Category Class
1 2class Category { 3private: 4 string categoryId; 5 string name; 6 Category* parentCategory; 7 vector<Product*> products; 8public: 9 void addProduct(Product* product); 10 void removeProduct(Product* product); 11};
1.Supplier Class
1 2class Supplier { 3private: 4 string supplierId; 5 string name; 6 string contactDetails; 7 vector<Product*> suppliedProducts; 8public: 9 void addProduct(Product* product); 10};
1.InventoryManager Class
•Core class for stock tracking and product operations.
1 2class InventoryManager { 3public: 4 void addProduct(Product* product); 5 void updateProduct(Product* product); 6 void deleteProduct(string productId); 7 void updateStock(string productId, string variantId, int quantityChange); 8 vector<Product*> getLowStockProducts(int threshold); 9};
1.AuditLog Class
•Tracks changes made by admins for accountability.
1 2class AuditLog { 3private: 4 string action; 5 string performedBy; 6 DateTime timestamp; 7 string details; 8public: 9 void logAction(string action, string performedBy, string details); 10};


🔄 Example Workflow


1.Admin adds a new product → InventoryManager.addProduct() → AuditLog records action.
2.Product stock changes due to a sale → updateStock() updates ProductVariant.stockQuantity.
3.Low stock detected → getLowStockProducts() returns products below threshold → admin notified.
4.Admin generates stock report → inventory data fetched from InventoryManager and formatted.


🧪 Expected Deliverables


•Class diagram showing Product, ProductVariant, Category, Supplier, InventoryManager, and AuditLog.
•Implementation of product CRUD, stock updates, low-stock alerts, and report generation.
•Test cases:
•Add, update, delete products and variants
•Stock updates for concurrent changes
•Low-stock detection
•Audit logging of admin actions


💡 Discussion Points


•Concurrency: thread-safe stock updates to prevent race conditions.
•Extensibility: support for multiple warehouses or locations.
•Reporting: efficient aggregation for large product catalogs.
•Integration: optional real-time updates to e-commerce frontend.


Solution

Comments