Bird
0
0
LLDsystem_design~12 mins

Payment handling in LLD - Architecture Diagram

Choose your learning style9 modes available
System Overview - Payment handling

This system securely processes user payments for online purchases. It handles payment requests, validates them, communicates with external payment gateways, and updates order status. Key requirements include security, reliability, and fast response times.

Architecture Diagram
User
  |
  v
Load Balancer
  |
  v
API Gateway
  |
  v
Payment Service <--> Cache
  |
  v
Database
  |
  v
External Payment Gateway
Components
User
client
Initiates payment requests
Load Balancer
load_balancer
Distributes incoming requests evenly to API Gateway instances
API Gateway
api_gateway
Handles authentication, routing, and request validation
Payment Service
service
Processes payment logic, communicates with database and external gateway
Cache
cache
Stores recent payment status and reduces database load
Database
database
Stores payment records and order status
External Payment Gateway
external_service
Processes actual payment transactions with banks or card networks
Request Flow - 12 Hops
UserLoad Balancer
Load BalancerAPI Gateway
API GatewayPayment Service
Payment ServiceCache
CachePayment Service
Payment ServiceDatabase
Payment ServiceExternal Payment Gateway
External Payment GatewayPayment Service
Payment ServiceCache
Payment ServiceAPI Gateway
API GatewayLoad Balancer
Load BalancerUser
Failure Scenario
Component Fails:Database
Impact:New payment records cannot be saved; payment status updates fail. Cached payment status can still be served for recent queries.
Mitigation:Use database replication and failover to a standby database. Cache serves read requests temporarily. Alert system triggers for manual intervention.
Architecture Quiz - 3 Questions
Test your understanding
Which component first handles user payment requests after they pass through the Load Balancer?
AAPI Gateway
BPayment Service
CCache
DDatabase
Design Principle
This architecture uses layered components to separate concerns: Load Balancer for traffic distribution, API Gateway for security and routing, Payment Service for business logic, Cache for performance, Database for persistence, and External Gateway for actual payment processing. This separation improves scalability, reliability, and maintainability.