The design is sound and none of the problems below require restructuring it. Three gaps would cause wrong stock or wrong charges in production, and each is a few lines added to the doc.

The core is right: stock is reserved in one transaction with a conditional update, the charge runs outside any transaction, both sides are idempotent, and unknown outcomes go to a reconciliation job with an alert. The simplicity suits 2,000 orders a day.

## Fix before building

1. **Status changes are not guarded, so stock can be restored twice.** The reconciliation job runs on both instances and nothing stops both settling the same order.
   - Case: an order for 3 units is `PENDING`, both jobs get "declined" from the provider, and both run step 5. `available` goes up by 6 instead of 3, and you later sell 3 units you do not have.
   - The same gap lets a slow request overwrite `PAID` with `FAILED`.
   - Fix: every transition is `UPDATE orders SET status = … WHERE id = … AND status = 'PENDING'`, and stock is restored only if that update changed a row.

2. **Reconciliation has no outcome for "the provider has never heard of this order".** Step 6 only allows `PAID` or `FAILED`.
   - Case: an instance crashes after step 2 commits and before step 3 calls the provider. The provider returns "not found", the order stays `PENDING` and holds stock indefinitely, and the 30-minute alert fires with no defined action.
   - Fix: define "not found" as `FAILED` plus stock restore, and "still processing" as leave `PENDING`.
   - Check: confirm the provider can look up a charge by your order id. Many cannot look up by idempotency key, and the `orders` table stores no provider charge id.

3. **The doc does not say where `unit_price` and `total` come from.** There is no price table, and the client sends "the cart". If the prices come from the request, a customer can pay 0.01 for anything. State that the server looks prices up and computes the total.

## Should fix, cheap to do now

4. **The idempotency key is unique globally, not per customer.** If two customers send the same key, the second gets the first customer's order back. Make the constraint `(customer_id, idempotency_key)`.
5. **A reused key with a different cart is undefined.** Today it would silently return the old order. Return `422` instead.
6. **Multi-item orders can deadlock.** Order A updates sku1 then sku2 while order B updates sku2 then sku1; Postgres kills one and the customer sees a 500. Update stock in sorted sku order.
7. **Concurrent duplicate `POST /orders` needs a stated mechanism.** Two simultaneous requests both pass a "does this key exist" check. Rely on the unique-constraint violation, roll back, and return the existing order.
8. **The test plan misses the riskiest paths.** Add tests for:
   - two buyers racing for the last unit;
   - concurrent duplicate posts;
   - a multi-item order where one item is out of stock, which must leave no partial reservation;
   - a decline restoring stock;
   - each reconciliation outcome: paid, declined, not found, and the job running twice.
9. **The client has no stated way to learn the result after a `202`.** Add `GET /orders/{id}` or say what the client polls.
10. **An order settled as `PAID` by reconciliation does not send the confirmation email.** Step 4 queues it only on the request path.

## Minor

11. A crash between the `PAID` commit and queuing the email loses the email. Write an email-pending row in the same transaction, or accept and note the loss.
12. Worst-case step 3 is about 20 s of timeouts plus backoff. Check that it is under the load balancer and client timeouts.
13. State which errors are retried: timeouts and 5xx, never declines.
14. The data model lists no keys or constraints. It needs primary keys, a foreign key from `order_items` to `orders`, `CHECK (available >= 0)`, a check on `status`, and an index on `(status, created_at)`.
15. Nothing stores the provider charge id or the decline reason, which support and refunds will need.
16. After `FAILED`, the same idempotency key returns the failed order forever. Document that a new payment attempt needs a new key and a new order.
17. "No module reads another module's tables" conflicts with steps 2 and 5, which span stock and orders in one transaction. Say that `OrderCheckout` owns the transaction and passes it to each module.
18. The doc does not say `customer_id` comes from the authenticated session rather than the request body.
19. The email queue is not listed in the infrastructure.
20. `numeric(12,2)` is wrong for currencies with zero or three decimal places (JPY, BHD). This is fine if you are single-currency; say so.
21. There is no cancel or refund state. That is fine for this revision, but note it as out of scope.

VERDICT: READY WITH CHANGES
