Design an E-Commerce System

Difficulty: MEDIUMCategory: LLDFrequency: 1Asked On 2023-08-28

Problem Statement

Design the low-level architecture of a simplified E-Commerce System that allows users to browse products, add items to cart, place orders, and make payments.


🔷 Functional Requirements:

1.Product Catalog:
•Display a list of products with:
•ID, name, description, price, stock quantity, category, and brand.
•Support search and filter by category, price range, etc.
2.User Cart:
•Users can add, remove, or update product quantities in their cart.
•Cart should maintain the state until checkout or manual clear.
3.Place Order:
•User can place an order for all items in the cart.
•System should:
•Validate stock
•Lock stock to prevent overselling
•Generate order with details (products, quantity, total cost, shipping info)
4.Payment Simulation:
•Allow a user to pay for an order (simulate success/failure).
•On successful payment, mark order as confirmed and deduct stock.
5.Order Management:
•View past orders and their statuses: PLACED, CONFIRMED, SHIPPED, DELIVERED, CANCELLED.


🔷 Constraints & Assumptions:

•No real payment gateway — simulate payment status.
•No authentication required — assume user identity is passed.
•No database — use in-memory storage with collections/maps.
•No concurrency/multi-threading required (unless asked).
•No UI — assume CLI or function-based interaction.


🔶 Expected Design Focus:

•Core classes:
•Product, User, Cart, Order, Payment, OrderItem, EcommerceSystem
•Key services:
•CatalogService, CartService, OrderService, PaymentService
•Use of Enums for OrderStatus, PaymentStatus, Category, etc.
•Apply OOP & SOLID principles for maintainability and extensibility.

🔷 Bonus Features (Optional):

•Add Discounts/Promotions (e.g., 10% off on category)
•Add Inventory Management System
•Support wishlist
•Add email notifications (simulated)
•Support return/refund workflow

✅ Sample Use Case:

1plaintext 2CopyEdit 31. User browses and adds a "Laptop" and "Mouse" to cart. 42. Updates quantity of "Mouse" to 2. 53. Proceeds to checkout and places the order. 64. Chooses to pay → payment succeeds. 75. System updates stock, marks order as CONFIRMED. 86. User views order history and sees the placed order.


Solution

Comments