CamelCamelCamel API Design
Explore the design and architecture of the CamelCamelCamel API, focusing on price-drop alerts for Amazon products. Understand how it integrates Amazon's Product Advertising API using RESTful endpoints, handles data synchronization with caching and queues, and meets nonfunctional requirements like availability, scalability, and low latency to deliver timely notifications.
CamelCamelCamel API design
In e-commerce, customers can't continuously monitor product prices. The CamelCamelCamel API (hereafter C3) provides a price-drop alert service for Amazon products, notifying users when prices fall below a desired threshold. To power these features, C3 leverages Amazon's Product Advertising API (PA-API), which exposes product data, including prices, reviews, promotions, and seller information.
Functional requirements
Search product: Allow users to search for a specific product.
Price timeline: Allow users to retrieve a product's price history.
Add to price watch: Users define a target price for a product and receive notifications when the price drops.
Get watch list: Users can view all products on their price watch list.
Nonfunctional requirements
Availability: The service must remain operational even if Amazon's service fails, since C3 depends heavily on Amazon's data.
Reliability: Product data and price-drop alerts must be as accurate as possible.
Scalability: The service must handle growth in users and marketplaces seamlessly.
Low latency: Response times should be minimized despite synchronous dependencies.
Prerequisites
Two previously designed building blocks underpin C3:
Search service: Enables users to find products of interest.
Pub-sub service: Handles watch list subscriptions and price-drop notifications.
What role can caching and indexing play in optimizing the search service at C3, and where in the pipeline should they be introduced for maximum impact?
Use the AI assessment widget below to submit your solution and get an interactive response.
With these requirements established, the design proceeds through architecture and workflow analysis; design decisions (architectural style, data format, and HTTP version); API model definition (endpoints, data entities, and message formats); synchronous communication patterns with Amazon; and, finally, an evaluation against nonfunctional requirements with a latency budget.
Design overview and decisions
C3's architecture centers on synchronous communication with Amazon as a distinct service provider. The C3 API exposes three internal services (search, pub-sub, and product), each of which interacts with corresponding Amazon services to deliver data to customers. The following illustration demonstrates the high-level architecture:
The following table provides an overview of each component involved in the C3 service:
Components and Services Details
Component or Service | Details | |
API Gateway |
|
|
C3 Service | Search service |
|
Pub-sub service |
| |
Product service |
| |
Amazon Service | Search service |
|
Simple queuing service (SQS) |
| |
Product advertising service |
| |
Workflow of C3
The C3 service operates synchronously with Amazon. Requests to C3's API gateway route to the appropriate subservice based on the required functionality:
Search product: The API gateway forwards search queries to C3's search service, which collaborates with Amazon's search service for accurate results. Amazon processes the query, returns results to C3, and C3 processes and delivers the response to the client.
Add a product to price watch: Subscription requests route from the API gateway to the pub-sub service. Products serve as topics; whenever a price-drop event occurs, subscribers are notified. The pub-sub service acquires pricing data from C3's product service to evaluate price drops. Clients can also retrieve their watch list from this service.
When would a topic be created or deleted in the pub-sub service?
Price timeline: C3's product service communicates with Amazon's Product Advertising API (PA-API) via Amazon SQS to send periodic requests. Responses are compared with C3's local data. The database is updated when changes are detected, and the pub-sub service is notified about price updates for watched ...