🛒

Building an E-commerce System: System Design Discussion with Gaurav Sen

Jun 27, 2024

Building an E-commerce System: System Design Discussion with Gaurav Sen

Introduction

  • Special guest: Gaurav Sen, founder of interviewready.io
  • Discussion on system design focused on e-commerce
  • Example systems: Amazon, Flipkart
  • Objective: Discuss how to build an e-commerce system step-by-step with a focus on an MVP (Minimum Viable Product)

Initial Considerations

  1. Requirements Gathering: Understand the problems and requirements from the product manager.
  2. Basic Features for MVP:
  • Inventory of products
  • Search functionality
  • Add to cart features
  • Payment gateway integration
  • Order tracking and notifications

User Journey

  1. Browsing and Searching: Users should be able to search for products via a search feature.
  2. Adding to Cart: Users should be able to add multiple products to a cart and adjust quantities.
  3. Checkout and Payment: Users should be able to make payments using various gateways like PayPal, Stripe.
  4. Order Tracking: Implementation of order tracking via notifications and status updates.

Architectural Considerations

  1. Monolithic vs Microservices: Start with a monolith for simplicity; later evolve into microservices for scalability.
  2. High-level Components to Implement: Inventory, delivery, payments, cart.
  3. Extensibility and Scalability: Design so the system can be decoupled later.

Inventory System Design

  1. Searching the Inventory:
  • Naive Search: Using SQL queries to match search strings (not efficient).
  • Optimized Search: Using an off-the-shelf solution like Elasticsearch for better performance.
  1. Storing the Inventory Data:
  • Primary Storage: Use RDBMS for storing inventory with high consistency.
  • Search Index: Sync RDBMS data with Elasticsearch for efficient search.
  1. ElasticSearch Integration:
  • Benefits: Fast text search, handles complex queries, efficient indexing.
  • Syncing from RDBMS: Ensure data from the primary storage is periodically synchronized.

Addition of Products

  1. Admin Dashboard: For adding and updating products by sellers or administrators.
  2. Metadata and JSON Storage: Structured storage in RDBMS and more flexible data in JSON format if needed.

Payment Integration

  • External Payment Gateways: Integration with gateways like PayPal and Stripe.
  • Monitoring Payments: Use purchase status (purchasing, successful, failed) to track transactions and handle payment failures.
  • Notification and Alerts: System for alerting on payment issues and other critical failures.

Monitoring and Debugging

  1. Health Checks: Regular pings to check if systems are alive (every few seconds).
  2. Metrics and Logging: Collect metrics for successful requests, errors, timeouts.
  3. Alerts and Notifications: Trigger alerts for any system anomalies, performance issues, etc.
  4. Error Handling: Detailed logging and error tracking for debugging issues.
  5. User Behavior Tracking: For tracking problems specific to user interactions.

Handling Media Files

  1. Storing Images: Use services like AWS S3 for storing product images.
  2. Serving Images: Store image URLs in the RDBMS, link with product records.
  3. Deleting Media: Ensure deletion of media files when associated products are removed.

Conclusion and Feedback

  • Focus on understanding components step-by-step and designing for extensibility.
  • Emphasize communication and logical reasoning behind design choices.
  • Overview of MVP for inventory system, readiness for scaling to full e-commerce system.

Feedback: System design discussions involve clear, logical solutions focused on solving specific problems in a scalable manner. Good practice is to maintain open communication during the interview, ensuring clarity of thought and design rationale. [Okay, Happy Learning!]