Design: Pricing Strategy System
Design covers discount and coupon management, validation, application logic, and usage tracking. Payment processing and product catalog are out of scope.
Functional Requirements
Non-Functional Requirements
Jump into concepts and practice - no test required
+-------------+ +---------------------+ +----------------+
| Frontend | <---> | API Gateway / Proxy | <---> | Discount Service|
+-------------+ +---------------------+ +----------------+
| |
| v
| +------------+
| | Cache (Redis)|
| +------------+
| |
v v
+---------------------+
| Relational Database |
| (Coupons, Discounts, |
| Usage Tracking) |
+---------------------+
+---------------------+
| Analytics & Reporting|
+---------------------+price = 100 coupon_discount = 15 # fixed amount final_price = price - coupon_discount print(final_price)
price = 200 discount = 20 # intended as 20% final_price = price - discount print(final_price)