🛒

Designing an E-commerce System Architecture

Sep 23, 2024

System Design of an E-commerce Website

Overview

  • Designing an e-commerce system similar to Amazon.
  • Focus on use cases, system architecture, APIs, database model, and concurrency.

Use Cases

  • User Profile Management: Create and update user profiles.
  • Product Listing: Display available products.
  • Shopping Cart: Add products to the cart.
  • Purchase: Buy products from the cart.
  • Order Tracking: Track placed orders.

System Design

  • API Layer: Routes requests to appropriate services.
  • User Manager: Handles user details and profile updates.
  • Listing Manager: Manages product listings and availability.
  • Cart Manager: Adds products to the cart and manages checkout process.
  • Order Manager: Creates orders from cart data and processes them.
  • Payment Manager: Handles payments through external services.

APIs

  1. UserManager API:
    • Create/Update user profiles.
  2. ListingManager API:
    • Retrieve all products (can be optimized for user-specific needs).
    • Reduce product quantity when ordered.
  3. CartManager API:
    • Add products to user cart.
    • Checkout process: Places order, reduces quantity, manages payment, returns order ID.
  4. OrderManager API:
    • Create orders for a user.
    • Track all orders for a user.
    • Track specific order details.
  5. PaymentManager API:
    • Make payment and return tracking ID.

Database Model

  • User Entity:
    • Attributes: ID, Name, Email ID, Phone, etc.
  • Product Entity:
    • Attributes: ID, Name, Price, Quantity.
  • Order Entity:
    • Attributes: ID, User ID, List of Products, Order Date, Tracking Details.

Concurrency

  • Concurrency Handling:
    • Use locks in Listing Manager to prevent conflicts when users order the same item.
    • Handle failed updates gracefully in checkout process.

Conclusion

  • Broad problem suited for high-level design discussions.
  • Important to start with use cases and simple diagrams.
  • Could dive deeper into subsystems and discuss failure scenarios, scaling, etc.
  • Scope for future discussions or videos on specific components.