The design is sound at its core and you can start building tomorrow, provided you make four edits to the document first, each a few lines. The transaction boundaries, the stock reservation, the provider idempotency key and the unknown-result path are all correct as written.

## Fix before building (High)

1. **Stock can be restored twice, which leads to overselling.** Nothing says the move out of `PENDING` happens only once. Both instances will run the reconciliation job, and it can also overlap a slow request.
   - Case: an order for 1 unit of SKU A is declined, and the job on both instances sees it as `PENDING`.
   - Wrong: both mark it `FAILED` and both restore stock, so `available` rises by 2.
   - Expected: `available` rises by 1.
   - Fix: settle with `UPDATE orders SET status = … WHERE id = … AND status = 'PENDING'`, and restore stock or queue the email only if that changed a row.

2. **Reconciliation has no rule for "the provider has never heard of this order".**
   - Case: the instance crashes after step 2 commits and before the charge call in step 3.
   - Wrong: the provider returns "not found", step 6 only covers `PAID` or `FAILED`, and the order holds stock until someone answers the 30-minute alert.
   - Expected: the order becomes `FAILED` and stock is restored.
   - Also confirm your provider can look up a charge by your order id. Some only look up by their own charge id, which you don't have after a timeout.

3. **The idempotency key is unique across all customers.**
   - Case: customer B sends a key customer A already used.
   - Wrong: B gets A's order back.
   - Expected: B gets a new order.
   - Fix: make the constraint unique on `(customer_id, idempotency_key)`. Also decide what a reused key with a different cart returns; I suggest `422`.

4. **The design does not say where prices come from.** `unit_price` and `total` are stored, but there is no price source in the data model. If they come from the client's cart, a customer can set their own price. State that the server looks prices up and computes the total.

## Fix during the build (Medium)

5. **Reconciliation side effects are unspecified.** Step 6 does not say that a `FAILED` result restores stock or a `PAID` result queues the email. Route steps 4, 5 and 6 through one settle function, which also carries fix 1.
6. **Multi-item orders can deadlock.** Two orders reserving SKUs A,B and B,A lock in opposite orders; Postgres kills one and the customer gets a `500`. Reserve in sorted SKU order.
7. **The client has no way to learn the outcome after a `202`.** Add `GET /orders/{id}` to the design.
8. **The test plan misses the riskiest paths.** Add:
   - reconciliation for each outcome: paid, declined, not found
   - two reconciliation runs on the same order
   - two simultaneous buyers for the last unit
   - two simultaneous `POST`s with the same key
   - a multi-item order where the second item is out of stock

## Tidy up (Low)

9. **The confirmation email can be lost.** A crash between the `PAID` commit and the enqueue drops it. Writing the email job in the same transaction closes this; it is acceptable to defer if you record it as known debt.
10. **Constraints are missing from the data model.** Add primary keys, a foreign key on `order_items.order_id`, `CHECK (available >= 0)`, a check on `status`, and a column for the provider's charge id.
11. **Worst-case request time is not bounded.** Four 5-second attempts plus backoff is roughly 27 seconds or more. Cap the backoff and check it fits under the load balancer timeout and the 2-minute reconciliation threshold.
12. **Provider errors other than a decline are not classified.** Say that `5xx` and `429` count as "unknown" (step 6), not "declined" (step 5).
13. **A declined order is final for its key.** Retrying with the same `Idempotency-Key` returns the `FAILED` order, so the client must send a new key to try another card. Put this in the API contract.

VERDICT: READY WITH CHANGES
