Design the backend components and APIs for implementing loyalty points capability XYZ e-commerce.
Every time an authenticated customer buys from XYZ e-commerce in any channel, he/she gains
- loyalty points for every 10 pounds spend. To keep is simple, we round off to nearest integer and assign only integer points - there is no notion of points with decimals.
- Every time a customer logs into our website or mobile app, we will show a dashboard with top n ranking (n can be 10, 20, etc.). the dashboard will show a proxy name for the customer, his/her rank and number of points for the customers with top n ranks.
- Show the position of the customer in the dashboard along with 2 (configurable) customers ranked above and 2 (configurable) customers ranked below along with ranks and score.
- 50 millions customer in UK and Ireland
- 10 millions orders everyday -- summing up to mobile, store, website
- 10 millions DAU
- 10 transactions/day each user
- reading the system -- 100k/second
- proxy name --- confidential name
----------Functional Requirements:----------
- User should be able to view dashboard along with 2 (configurable) customers ranked above and 2 (configurable) customers ranked below along with ranks and score.
- When customer buys from XYZ e-commerce in any channel, he/she should gains loyalty points
----------Non-Functional Requirements:----------
- The system should have high availability for viewing the dashboard but should consistence for calculating Loyalty and dashboard results.
- The system should have low latency search
- The system should be scalable and able to handle high throughput for reading 100k/second
- The system should be scalable and able to handle high throughput for writing 10 millions * 10 /day
----------Core Entities----------
- User
- Loyalty
- Rank
- Order
----------API----------
1. Buying Items POST:/order/orderId -> status like success or failure of placing order
{
"ItemIds": string[],
"paymentDetails": ...
}
2. Get dashboard GET:/loyalty/userId -> Rank[]
3. Inserting loyality POST:/loyalty/userId --> loyaltyId
{
loyalty-points:"Integer"
}
High-Level Design

Deep Dives

Read Optimize
