Search⌘ K
AI Features

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.

Functional and nonfunctional requirements of C3 API
Functional and nonfunctional requirements of C3 API

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:

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.

Caching and Indexing in Search Optimization

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:

Working architecture of a C3 service
Working architecture of a C3 service

The following table provides an overview of each component involved in the C3 service:

Components and Services Details

Component or Service

Details


API Gateway

  • Client to C3 service
  • C3 to Amazon service
  • Analyzes and routes the requests to appropriate services
  • Authenticates and authorizes requests
  • Limits address rate to throttle requests

C3 Service

Search service

  • Handles client's search requests

Pub-sub service

  • Handles requests to add products to the watch list
  • Notifies users about price drops


Product service

  • Recommends products to users
  • Interacts continuously with the Amazon service to update data
  • Publishes an event of the price drop on the pub-sub after data analysis

Amazon Service


Search service

  • Handles search requests made by the C3 service to tackle the client's search requests

Simple queuing service (SQS)

  • Stores requests to be processed in a queue

Product advertising service

  • Handles periodic user requests forwarded by SQS

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.

1.

When would a topic be created or deleted in the pub-sub service?

Show Answer
1 / 3
  • 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 ...