Preparing your design workspace

Loading the problem and your latest saved attempt…

Design a Medicine Delivery Platform

Find nearby stocked pharmacies and coordinate expiring stock reservations with retryable payments.

Problem statement

For this exercise, assume a patient uploads a prescription, reviews the medicines extracted by an AI service, adds items to a cart, finds a pharmacy within 5 km that can fill the whole cart, and pays for an order routed to that pharmacy.

Extraction produces suggestions, not permission to dispense: assume an external prescription-review process has already approved the medicines before checkout. Design the ordering platform from extraction through order confirmation. Inventory must not be oversold and a retry must not charge the patient twice.

A stock reservation lasts 10 minutes while payment is pending. Payment confirmation can be delayed or delivered more than once; explain what the customer sees when the result is not yet known.

For this exercise, one order uses one pharmacy and partial fulfillment, substitutions, courier tracking, and the clinical approval process are out of scope. Keep the architecture small enough to operate initially in one city and expand to more cities.

What to build

  1. A patient can upload a prescription and review extracted medicine suggestions; only externally approved medicines may enter checkout.
  2. A patient can find pharmacies within 5 km that appear able to fill the complete cart; checkout must revalidate stock.
  3. Checkout reserves inventory for 10 minutes, starts or resumes a payment, and exposes pending, confirmed, or unsuccessful order outcomes without overselling or duplicate charging.
  4. The system routes a confirmed order to its pharmacy once, releases expired unpaid reservations, and safely resolves delayed or duplicate payment notifications.

At scale

  • For this exercise, assume 3,000 concurrent active users in the first city; city expansion must not require scanning all pharmacies in all cities.
  • For this exercise, target a 300 ms p95 response for nearby-pharmacy discovery during normal operation. Discovery may show recently stale stock, but checkout must enforce current inventory.
  • A payment-pending inventory reservation expires after 10 minutes. Inventory cannot be oversold and retries cannot produce a second charge or a second pharmacy order.
  • For this exercise, limit extraction to five requests per patient per minute and keep discovery/order-status reads available during an extraction-provider outage; report pending payment results honestly.