The design is not quite ready as written, but it is close: the core flow is sound, and I found 16 gaps, all fixable in the doc without restructuring. Reserving stock in one transaction, charging outside it, using the order id as the provider idempotency key and reconciling unknown results are the right calls, and the design is sensibly sized for 2,000 orders a day.

## High: fix in the doc before coding

1. **Reconciliation has no rule for "provider has no such charge".** Step 6 only settles orders as `PAID` or `FAILED` based on a charge status. If an instance crashes after step 2 commits but before the charge reaches the provider, the provider has no record. The order then stays `PENDING` and holds its stock until someone acts on the 30-minute alert. Add: no charge found after the 2-minute cutoff means `FAILED`.

2. **Step 6 does not say what else happens on settlement.** Step 5 restores stock on a decline and step 4 queues the email on success, but step 6 mentions neither. Say explicitly that a reconciled `FAILED` restores stock and a reconciled `PAID` queues the confirmation email.

3. **Status changes are not guarded, so stock can be restored twice.** Both instances will run the reconciliation job. For example, an order for 1 unit is found declined by both jobs at once, each restores stock, and `available` rises by 2 instead of 1. That unit can then be oversold. Make every transition conditional (`UPDATE orders SET status = ... WHERE id = :id AND status = 'PENDING'`) and restore stock only if that changed a row. The same guard covers a slow request thread and the job settling the same order.

4. **The design does not say where prices come from or that quantities are validated.** If `unit_price` and `total` come from the client cart, a customer can set their own price. A quantity of -5 passes the `available >= :qty` check, raises stock by 5 and lowers the total. State that prices are looked up server-side and quantity must be at least 1, and back it with a `CHECK` constraint.

## Medium: resolve during the first days of the build

5. **A concurrent duplicate request for the last unit gets `409` instead of the existing order.** Two requests with the same key arrive together and neither sees an existing order. The first takes the last unit and commits; the second fails the stock update and returns `409` for an order that succeeded. Insert the order row first, or re-check the key before returning `409`.

6. **The idempotency key's uniqueness scope is unspecified.** It should be unique per `(customer_id, idempotency_key)`, or one customer's key can return another customer's order. Also define what happens when the same key arrives with a different cart; the usual answer is `422`.

7. **Multi-item orders can deadlock.** Order X updates SKU A then B while order Y updates B then A. Postgres aborts one, which surfaces as a 500. Update stock rows in sorted SKU order.

8. **The client has no way to learn the outcome after `202`.** No `GET /orders/{id}` or other polling contract is defined.

9. **The worst-case request may outlast the load balancer timeout.** Four attempts at 5 s plus backoff holds the request for 20 s or more. Check this against the load balancer and client timeouts.

10. **The confirmation email can be lost.** Step 4 commits `PAID` and then queues the email, so a crash between the two drops it. Write an outbox row in the same transaction, or add an `email_queued_at` column that the reconciliation job sweeps. The queue technology is also unnamed.

11. **The payment provider's behaviour is assumed, not confirmed.** Confirm it can look up a charge by your order id, since after a timeout you have no provider charge id. Confirm its idempotency window is longer than your longest retry and reconciliation span.

12. **Retryable errors are not defined.** Timeouts and 5xx should retry; declines and 4xx should not. Say what status an order gets on a non-decline hard error such as an invalid request.

13. **The test plan misses the riskiest paths.** Add tests for:
    - the reconciliation job: paid, declined, no charge found, provider down, and two jobs running at once
    - two different buyers racing for the last unit
    - a concurrent duplicate `POST`
    - a multi-item order where one item is out of stock, proving full rollback
    - a decline restoring stock
    - an email failure not failing the order

## Minor

14. **The data model omits keys and constraints.** Add primary keys, the `order_items` to `orders` foreign key, `CHECK (available >= 0)`, a `CHECK` on `status`, and columns for the provider charge reference and failure reason.

15. **The 30-minute `PENDING` alert has no owner or runbook.** Also add an alert for the reconciliation job not running, since everything in step 6 depends on it.

16. **Smaller documentation gaps.**
    - Retrying after a decline needs a new idempotency key, or the client gets the old `FAILED` order back.
    - `numeric(12,2)` is wrong for zero-decimal and three-decimal currencies; state it if you are single-currency.
    - There is no cancelled or refunded status; say so if that is deliberately out of scope.
    - The alert sits under "Code structure" and belongs in an operations section.

VERDICT: READY WITH CHANGES
