Design an E-commerce Website

Difficulty: MEDIUMCategory: HLDFrequency: 1Asked On 2024-06-01

Problem Statement

Design a scalable, fault-tolerant, and high-performance e-commerce system like Amazon or Flipkart. The system should allow users to browse products, manage carts, place orders, and make payments.


✅ Functional Requirements:

👤 User Management:

•User registration and login
•View and update user profile
•View order history


🛍️ Product Management:

•View products by category, name, brand
•Search, filter, and sort products
•View product details (description, price, images, stock)


🛒 Cart & Checkout:

•Add/remove/update items in the cart
•Apply discounts or coupon codes
•Proceed to checkout


📦 Order Management:

•Place order
•Track order status
•Cancel or return an order


💳 Payments:

•Integrate with payment gateway
•Handle success/failure of payment
•Generate invoice


⭐ Reviews & Ratings:

•Users can review and rate products
•Ratings impact product ranking


⚙️ Non-Functional Requirements:

•Scalability: Handle millions of products and concurrent users.
•Availability: System must be highly available, especially for cart and checkout.
•Consistency: Order and payment operations must be strongly consistent.
•Latency: Fast browsing and product search.
•Security: User data and payment info must be protected.


🔐 Constraints:

•Design for read-heavy traffic (browsing, searching)
•Cart and order operations are write-heavy and user-specific
•Database should support product catalog growth and horizontal scaling
•Payment handling should be decoupled and idempotent


🧠 Scope Notes:

You can break this into services like:

•User Service
•Product Service
•Cart Service
•Order Service
•Payment Service
•Search Service
•Recommendation Service
•Review & Rating Service
•Inventory Service
•Notification Service (email/SMS)


🧪 Example Scenario:

1plaintext 2CopyEdit 3- User logs in, searches for "Wireless Headphones" 4- Applies filter for "Sony" and sorts by price 5- Adds item to cart, applies a coupon, and places the order 6- System confirms order, redirects to Razorpay for payment 7- Payment succeeds, inventory is updated, and invoice is generated 8- Order tracking is available in the user's dashboard


Solution

Comments