Bird
Raised Fist0
HLDsystem_design~12 mins

Shopping cart and session management in HLD - Architecture Diagram

Choose your learning style9 modes available
System Overview - Shopping cart and session management

This system manages user sessions and shopping carts for an online store. It ensures users can add items to their cart, keep their cart saved during their visit, and retrieve it later. The system must handle many users simultaneously and keep data consistent and fast.

Architecture Diagram
User
  |
  v
Load Balancer
  |
  v
API Gateway
  |
  +-------------------+
  |                   |
Session Service    Cart Service
  |                   |
  v                   v
Session Store      Cache Layer
  |                   |
  v                   v
Database           Database
Components
User
client
Person using the online store through a browser or app
Load Balancer
load_balancer
Distributes incoming user requests evenly to backend services
API Gateway
api_gateway
Routes requests to appropriate services and handles authentication
Session Service
service
Manages user login sessions and session validation
Cart Service
service
Handles shopping cart operations like add, remove, and view items
Session Store
database
Stores session data persistently for user authentication
Cache Layer
cache
Caches shopping cart data for fast access and reduced database load
Database
database
Stores persistent shopping cart data and user information
Request Flow - 15 Hops
UserLoad Balancer
Load BalancerAPI Gateway
API GatewaySession Service
Session ServiceSession Store
Session StoreSession Service
Session ServiceAPI Gateway
API GatewayCart Service
Cart ServiceCache Layer
Cache LayerCart Service
Cart ServiceDatabase
DatabaseCart Service
Cart ServiceCache Layer
Cart ServiceAPI Gateway
API GatewayLoad Balancer
Load BalancerUser
Failure Scenario
Component Fails:Cache Layer
Impact:Cart service cannot retrieve cached cart data, causing slower responses due to direct database queries
Mitigation:System falls back to database queries for cart data; cache is rebuilt on next successful cart operation
Architecture Quiz - 3 Questions
Test your understanding
Which component is responsible for validating the user's session token?
AAPI Gateway
BCart Service
CSession Service
DLoad Balancer
Design Principle
This design separates session management and cart operations into distinct services, improving modularity and scalability. Using a cache layer reduces database load and speeds up cart data access. The API Gateway centralizes routing and authentication, simplifying client interactions.