Assume approximately 10,000 online stores.
Need to scrap pricing data from each store, including price changes, daily.
Assume each store has an average of 10,000 different items and each item would need storage for name, ID, store name and price. Assuming each field has at most 100 characters limit, then 400 bytes is required to store an item.
so 400 * 10,000 * 10,000 = 40,000,000,000 bytes which is 40 GB.
Based on these calculations, I would use a SQL database such as MySQL since the storage requirements is only 40GB and also because there are different relationship between the data that could be better modelled using SQL relationships.
GetPrices:
Input - Item Name,
Output - Prices of item from various stores for comparison
ApplyCoupon:
Input - Coupon code,
Output - Applied discount
SetDealAlerts:
Input - User preferences,
Output - Deal notifications
GetCoupon:
Input - Item Name,
Output - List of coupons
We can have the below entities as part of our database design.
Item
Coupon
Store
Deal
The Web Application serves as the user-facing component that enables user interactions, account management, search features, and deal notifications. It acts as the central hub that coordinates communication between various services.
We will be implementing a microservices architecture. Each microservice could handle specific functions such as user authentication, deal notifications, and search features, leading to a more modular and efficient design.
Additionally, we can leverage cloud-based solutions like Amazon Web Services (AWS) or Google Cloud Platform (GCP) for hosting and managing the Web Application to ensure high availability and reliability.
The Coupon component scrapes coupon codes from various sources and maintains a coupon database. We could implement a distributed web scraping system. Use tools like Scrapy or BeautifulSoup in combination with a message queue system like RabbitMQ to orchestrate scraping tasks across multiple nodes. By distributing the scraping workload, we can improve performance and scalability. Additionally, utilize caching mechanisms to reduce redundant requests and optimize response times.
The Price Comparison Engine compares prices across different e-commerce platforms. We could integrate with established price comparison APIs such as PriceAPI or develop custom price scraping scripts. Implement caching mechanisms to store frequently accessed product prices and reduce API calls.
The Notification Service sends deal alerts, personalized recommendations, and updates to users via various channels. We could implement a multi-channel notification system by utilizing services like SendGrid or Twilio for email and SMS notifications, and leverage Firebase Cloud Messaging for push notifications. Implement user preference settings to allow customization of notification preferences and frequency.
As mentioned, we are using a microservice architecture for scalability and maintenance. Let us explore how we would implement following three services below:
When a user searches for a product on the platform, the Web Application sends a request to the Price Comparison Service with the product details. The Price Comparison Service integrates with APIs provided by various e-commerce platforms to fetch real-time price information for the requested product. The service retrieves prices from multiple online retailers, considering factors like product availability, shipping costs, and discounts. It compares the prices from different platforms and identifies the best deals or lowest prices available for the product. We can also ensure that the service ensures that the price data is normalized and presented in a consistent format for easy comparison.
Another option to get pricing data is using a customer scrapper. This can be implemented using a worker that periodically scapes designated website for data and stores it in our database. This can be implemented using some sort of task scheduler service.
The deal alert service is essentially a notification service. If there's a good deal we can utilize communication mechanisms like web sockets to inform the client on good deals. We can make the notification service multi-channel as well using third party options like firebase for push notification and Twilio for sms notification.
For real-time coupon code validation, a suitable data structure like a Hash Table can be employed to efficiently store and retrieve coupon details based on unique codes. When a user enters a coupon code, the system can quickly access the corresponding details for validation.
To mitigate some of these failure scenarios we could implement the following:
It would be interesting the dive more into the recommendation engine for deals. We could potentially use machine learning algorithms to enhance our recommendation results.