Design a Book Purchase Broker
Design a system that accepts a user's request to buy a book. The request specifies the book (by title, ISBN, or other identifier), a maximum target price, and an expiration time. The system should query a limited set of partner bookstores asynchronously to find available inventory. If the best available total price (including taxes, fees, and shipping) is at or below the user's target price before the request expires, the system should place an order. If no store can satisfy the price constraint, the system should return the best available price to the user. If no store has inventory, the user should be notified that the book is unavailable.
Requirements:
- Support creating, checking, and canceling purchase requests.
- Query multiple partner bookstores asynchronously.
- Compare total prices, including taxes, fees, and shipping when available.
- Place at most one order for each user request.
- Respect request expiration times.
- Handle partner timeouts, retries, duplicate callbacks, partial failures, and changing inventory.
- Notify users about ordered, quoted, out-of-stock, expired, and failed outcomes.
AI interview prep
Core dilemma
Balancing the need for rapid, asynchronous querying of unreliable external partners against the strict requirements of fulfilling a user's request within a time-bound, price-constrained window, while ensuring at-most-once order semantics and robust failure handling.
3 tradeoffs and 3 stress tests locked
Interview prep
Unlock the interviewer X-Ray rubric, tradeoff matrix, stress tests, clarifying questions, and key concepts.
Design a Book Purchase Broker
Design a system that accepts a user's request to buy a book. The request specifies the book (by title, ISBN, or other identifier), a maximum target price, and an expiration time. The system should query a limited set of partner bookstores asynchronously to find available inventory. If the best available total price (including taxes, fees, and shipping) is at or below the user's target price before the request expires, the system should place an order. If no store can satisfy the price constraint, the system should return the best available price to the user. If no store has inventory, the user should be notified that the book is unavailable.
Requirements:
- Support creating, checking, and canceling purchase requests.
- Query multiple partner bookstores asynchronously.
- Compare total prices, including taxes, fees, and shipping when available.
- Place at most one order for each user request.
- Respect request expiration times.
- Handle partner timeouts, retries, duplicate callbacks, partial failures, and changing inventory.
- Notify users about ordered, quoted, out-of-stock, expired, and failed outcomes.