Loading LLD design...
Design an object-oriented e-commerce platform (like Amazon) with user/seller registration, product catalogue with hierarchical categories, product search with multi-filter support, shopping cart, checkout with stock validation and atomic inventory reduction, a full order lifecycle, cancellation with stock restoration, and a product review system.
The checkout flow validates stock availability for all cart items, atomically reduces inventory, computes the total (subtotal + 8% tax + shipping − discount), processes payment, and creates an order. Orders follow a lifecycle: PLACED → CONFIRMED → SHIPPED → OUT_FOR_DELIVERY → DELIVERED. Cancellation is only allowed before shipping and triggers stock restoration and refund. Reviews are restricted to users who have received the product.
Register users and sellers
Buyers register with profile and addresses; sellers register with business info
Product catalogue
Sellers list products with name, description, price, category, stock, images
Search and filter products
Search by keyword, category, price range, rating; sort by price/rating/relevance
Shopping cart
Add/remove/update items in cart with price snapshot at add time
Place order (checkout)
Convert cart to order: validate stock, reduce inventory, compute total (subtotal + tax + shipping - discount), process payment
Order lifecycle
PLACED → CONFIRMED → SHIPPED → OUT_FOR_DELIVERY → DELIVERED
Cancel order
Cancel before shipping, restore stock, refund payment
Product reviews
Buyers who purchased can leave 1-5 star reviews; updates product average rating
Inventory management
Track stock per product; auto-mark OUT_OF_STOCK when quantity hits zero
Before diving into code, clarify the use cases and edge cases. Understanding the problem deeply leads to better class design.
Identify the primary actions users will perform. For a parking lot: park vehicle, exit vehicle, check availability. Each becomes a method.
Who interacts with the system? Customers, admins, automated systems? Each actor type may need different interfaces.
What are the limits? Max vehicles, supported vehicle types, payment methods. Constraints drive your data structures.
What happens on overflow? Concurrent access? Payment failures? Thinking about edge cases reveals hidden complexity.