0
0
LLDsystem_design~12 mins

Cancellation and refund policy in LLD - Architecture Diagram

Choose your learning style9 modes available
System Overview - Cancellation and refund policy

This system manages user requests to cancel orders and process refunds. It ensures that cancellations follow policy rules and refunds are issued correctly and securely.

Key requirements include validating cancellation eligibility, updating order status, calculating refund amounts, and notifying users.

Architecture Diagram
User
  |
  v
Load Balancer
  |
  v
API Gateway
  |
  v
Cancellation Service <--> Refund Service
      |                      |
      v                      v
  Order Database          Payment Gateway
      |
      v
  Cache (for order status)
Components
User
client
Initiates cancellation and refund requests
Load Balancer
load_balancer
Distributes incoming requests evenly to API Gateway instances
API Gateway
api_gateway
Routes requests to appropriate services and handles authentication
Cancellation Service
service
Validates cancellation policy, updates order status
Refund Service
service
Calculates refund amount and interacts with payment gateway
Order Database
database
Stores order details and status
Cache
cache
Stores frequently accessed order status for quick reads
Payment Gateway
external_service
Processes refund transactions securely
Request Flow - 12 Hops
UserLoad Balancer
Load BalancerAPI Gateway
API GatewayCancellation Service
Cancellation ServiceCache
CacheCancellation Service
Cancellation ServiceOrder Database
Cancellation ServiceCache
Cancellation ServiceRefund Service
Refund ServicePayment Gateway
Payment GatewayRefund Service
Refund ServiceAPI Gateway
API GatewayUser
Failure Scenario
Component Fails:Order Database
Impact:New cancellations cannot update order status; refunds cannot be processed reliably
Mitigation:Use database replication for failover; allow reads from cache but block writes until DB recovers
Architecture Quiz - 3 Questions
Test your understanding
Which component checks if an order can be cancelled according to policy?
ALoad Balancer
BPayment Gateway
CCancellation Service
DCache
Design Principle
This architecture separates concerns by using dedicated services for cancellation validation and refund processing. It uses caching to speed up order status reads and relies on a payment gateway for secure refund transactions. Load balancing and API gateway ensure scalability and security.