**The design is sound and you can start building tomorrow, provided you add a few sentences to it first for problems 1–3.** None of the problems below needs a restructure. The core is right: stock is reserved with a conditional update in one transaction, the charge happens outside any transaction with the order id as the provider's idempotency key, and a reconciliation job settles unknown results.

## Fix before building (each can cause wrong stock or wrong money)

1. **Nothing stops an order from being settled twice.** Steps 4, 5 and 6 all change a `PENDING` order, and the design does not say the change is conditional. With two instances, the reconciliation job presumably runs on both.
   - **Failing case:** both jobs pick up the same declined order of 3 units and both run step 5. `available` goes up by 6 instead of 3, and you later sell 3 units you don't have.
   - **Fix:** settle with `UPDATE orders SET status = ... WHERE id = :id AND status = 'PENDING'`, and restore stock or queue the email only if that changed a row. Also state whether the job runs on one instance or both.

2. **Reconciliation has no rule for "the provider has never heard of this order".** Step 6 says orders settle as `PAID` or `FAILED`, but there is a third answer.
   - **Failing case:** the instance crashes after step 2 commits and before step 3 sends the charge. The provider returns "not found", the order stays `PENDING` and its stock stays reserved until someone answers the 30-minute alert by hand.
   - **Fix:** treat "not found" as `FAILED` and restore stock. Also state that the total retry time in step 3 must stay well under the 2-minute threshold, so the job never fails an order whose charge is still in flight.

3. **The design does not say where `unit_price` and `total` come from.** There is no price table, and step 1 says the client sends "the cart". If prices come from the request, a customer can submit a 1,000.00 item at 1.00 and be charged 1.00. State that the server looks up prices and computes the total.

## Fix during the build

4. **Concurrent multi-item orders can deadlock.** Order A reserves SKU 1 then SKU 2 while order B reserves SKU 2 then SKU 1; Postgres aborts one with an error. Update the SKUs in sorted order.

5. **The idempotency key has gaps.**
   - The unique constraint should be on `(customer_id, idempotency_key)`, or one customer's key can return another customer's order.
   - The behaviour for the same key with a different cart is not defined; I'd return `422`.
   - Two simultaneous requests with the same key: the loser hits the unique violation and must return the existing order, not a `500`.

6. **The provider's charge id is not stored on the order.** You will need it for refunds, support queries and reconciliation lookups.

7. **The confirmation email can be lost or never queued.**
   - A crash between the commit and the enqueue in step 4 loses the email.
   - Step 6 does not say that orders the reconciliation job marks `PAID` get an email at all.
   - **Fix:** add an `email_queued_at` column that the job checks, or write the email request in the same transaction as the `PAID` update.

8. **The test plan misses the riskiest paths.** Add tests for:
   - two concurrent buyers of the last unit;
   - two concurrent `POST /orders` with the same key;
   - the reconciliation job for paid, declined, not found and still unknown;
   - an order settled twice (problem 1);
   - the same key with a different cart.

## Minor

9. **No constraints are listed in the data model.** Add primary keys (`order_items` has none), foreign keys, `CHECK (available >= 0)`, `CHECK (quantity > 0)` and a check on the `status` values.

10. **The `202` response has no follow-up path.** Say how the client learns the outcome, for example by polling `GET /orders/{id}`.

11. **The worst-case request time is not stated.** Four attempts at 5 s plus backoff is over 20 s, which probably exceeds the load balancer or client timeout. The flow survives this, but write the number down and check it against the timeout.

12. **Retry after a decline is not described.** The same key returns the `FAILED` order, so the client needs a new key to try again.

13. **Steps 2 and 5 cross the module boundary rule.** They change `stock` and `orders` in one transaction while "no module reads another module's tables". Say that `OrderCheckout` owns the transaction and passes it to the inventory module.

14. **The source of `customer_id` is not stated.** It should come from the authenticated session, not the request body.

15. **There are no refund or cancel states.** That is fine for this revision; note it as out of scope so it reads as a decision.

VERDICT: READY WITH CHANGES
