Design a Price Alert & Promotion Tracking Service
Problem Statement
Design a highly scalable system that enables users to track product prices across e-commerce platforms and receive real-time alerts when the price of a product drops or increases, or when new promotions become available.
The system should support millions of users, handle continuous price updates from multiple sources, and provide efficient notifications through multiple channels (email, SMS, push notifications).
🎯 Core Requirements
1. User Operations
2. Product and Promotion Tracking
3. Alert and Notification
4. Scalability and Performance
5. Non-Functional Requirements
⚙️ Core Functional Components
ComponentResponsibility
User Service
Manage user profiles, preferences, and watchlists.
Product Service
Store and retrieve product metadata and pricing info.
Price Tracker / Crawler Service
Continuously fetch price data from sources (Amazon, Flipkart, etc.).
Price Change Detector
Compare new prices with stored ones to detect changes.
Alert Engine
Determine which users need to be notified based on their thresholds.
Notification Service
Send alerts via email, SMS, or push notifications.
Promotion Service
Track and surface ongoing promotions or deals.
Analytics Service
Store price history and generate insights/trends.
🧱 High-Level Data Model
User
1
2User {
3 user_id: UUID
4 email: string
5 phone: string
6 preferences: { notify_email: true, notify_sms: false }
7}Product
1
2Product {
3 product_id: UUID
4 name: string
5 url: string
6 current_price: float
7 last_updated: timestamp
8}UserWatchlist
1
2UserWatchlist {
3 user_id: UUID
4 product_id: UUID
5 desired_price: float
6 alert_sent: boolean
7}PriceHistory
1
2PriceHistory {
3 product_id: UUID
4 timestamp: datetime
5 price: float
6}Promotion
1
2Promotion {
3 promo_id: UUID
4 product_id: UUID
5 description: string
6 valid_till: datetime
7}🧩 High-Level Architecture
1
2 +--------------------+
3 | API Gateway |
4 +--------------------+
5 |
6 +-----------------------------------------+
7 | Backend Layer |
8 +-----------------------------------------+
9 | User Service | Product Service |
10 |--------------------------|----------------------|
11 | Price Tracker Service | Price Detector |
12 | Alert Engine | Promotion Service |
13 | Notification Service | Analytics Service |
14 +-----------------------------------------+
15 |
16 +--------------------+
17 | Message Queue |
18 | (Kafka/SQS) |
19 +--------------------+
20 |
21 +--------------------+
22 | Data Layer (DBs) |
23 +--------------------+
24 |
25 +------------------------------------+
26 | SQL/NoSQL | Redis Cache | Blob Storage |
27 +------------------------------------+🧠 Key Design Considerations
1. Data Collection
2. Price Change Detection
3. Alert Generation
4. Notification Delivery
Notification Service processes alerts and sends:
5. Scalability
📈 Example Flow
1. User adds a product
1
2User → /addWatch → UserWatchlist
3Product data stored or fetched from external site2. Price Update Detected
1
2Crawler fetches latest prices → Price Detector
3→ detects drop from ₹1200 → ₹950 → sends PRICE_DROP event to Kafka3. Alert Generation
1
2Alert Engine consumes event → finds users watching product
3→ triggers notification event4. Notification Delivery
1
2Notification Service → sends email/SMS → logs alert → marks alert_sent = true🧱 Storage Choices
Data TypeSuggested StorageReason
User & Watchlist
RDBMS (PostgreSQL/MySQL)
Strong consistency
Product & Price
NoSQL (Cassandra/DynamoDB)
High write throughput
Price History
Time-series DB
Fast range queries
Promotions
Document store (MongoDB)
Flexible metadata
Cache
Redis
Fast lookups
Queue
Kafka/SQS
Asynchronous communication
⚙️ Key APIs
APIDescription
POST /users/register
Create a new user.
POST /watchlist
Add a product to user’s watchlist.
GET /watchlist
Retrieve user’s tracked products.
POST /alerts/subscribe
Enable/disable alert channels.
GET /promotions
Fetch active promotions.
🚀 Scalability Enhancements
✅ Goal:
Design a real-time, event-driven price alert system that allows users to track product prices, detect promotions, and receive timely alerts when prices change — with scalability, reliability, and low-latency guarantees.