**Verdict up front: this is a strong design. Most of it can be built tomorrow as written, but about four things need a sentence or two each in the doc first.** The key pieces are already right. Stock is reserved with a conditional update, the payment call happens outside any transaction, the charge uses a stable idempotency key, unknown payment results get a reconciliation job, and email can't fail an order. What's left is mostly a few failure paths and some details the doc leaves open.

## High: fix in the doc before you start coding

**1. When the reconciliation job marks an order `FAILED`, nothing gives the stock back.**
Step 5 restores stock on a decline, but step 6 only says "settles them as PAID or FAILED."
- Example: a customer buys the last unit, the provider times out on every attempt, and later the job learns the charge was declined. The order becomes `FAILED`, but `available` stays at 0 for good.
- Expected: settling as `FAILED` restores stock in the same transaction, wherever it happens.
- Fix: make "mark FAILED + restore stock" one shared operation that both step 5 and step 6 call.

**2. Two code paths can settle the same order, and stock can be restored twice.**
You run two instances, so as written the job runs on both. The request handler can also settle an order at the same moment.
- Example: both instances pick up the same declined `PENDING` order. Each marks it `FAILED` and each adds the quantity back. `available` goes from 4 to 6 instead of 5.
- Fix:
  - Make every status change conditional: `UPDATE orders SET status = 'FAILED' WHERE id = :id AND status = 'PENDING'`.
  - Restore stock only if that update actually changed a row.
  - Make sure only one instance runs the job, using either an advisory lock or `SELECT … FOR UPDATE SKIP LOCKED`.

**3. A crash between step 2 and step 3 leaves an order that was never charged, and the doc doesn't say what happens to it.**
- Example: the service commits the `PENDING` order and then restarts before calling the provider. The job asks the provider about that order id, and the provider answers "no such charge."
- Expected: the doc says that "not found" (once the order is older than 2 minutes) is treated as `FAILED`, which then restores stock under fix 1.
- This is safe because the request path finishes all its attempts in roughly 25 to 30 seconds, well inside the 2-minute cutoff. It's worth writing down why that margin matters.

**4. The idempotency key is unique across all customers, and a reused key isn't checked against the request.**
- Example 1: two customers' clients generate the same key, which can happen with a buggy client or a weak generator. Customer B then gets customer A's order back. That leaks another customer's data.
- Example 2: a client reuses a key with a different cart and silently gets the old order.
- Fix:
  - Make the unique constraint `(customer_id, idempotency_key)`.
  - Store a hash of the request body, and return `422` when the same key arrives with a different body.

## Medium: settle these early in the build

**5. The doc doesn't say where prices come from.** Step 1 says the client "sends the cart." If `unit_price` and `total` are taken from the client, anyone can buy at £0.01. State that prices are looked up on the server, which also means saying which module owns the catalogue.

**6. The client has no way to follow up on a `202`.** There is no `GET /orders/{id}` endpoint. Without one, the client's only option is to repeat the `POST` with the same key. That works, but it's an odd contract. Either add the endpoint or document the repeat-`POST` approach.

**7. Orders settled as `PAID` by the job don't get a confirmation email.** Step 4 queues the email only on the request path. The job should queue it too.

**8. An email can be lost if the service crashes after the commit in step 4 and before the email is queued.** Writing the email job to a table in the same transaction as the status change closes this gap. Since email is non-critical, you could also accept the risk, but write that choice down.

**9. The doc contradicts itself on table access.** It says "no module reads another module's tables," yet steps 2 and 5 update `stock` and `orders` in one transaction. Say how it actually works. For example, the inventory module exposes `reserve()` and `release()` functions that run inside a transaction the caller passes in.

**10. The doc doesn't say which payment errors get retried.** Only timeouts, network errors and 5xx responses should be retried. A decline or other 4xx must go straight to step 5.

**11. Concurrent orders can deadlock.** If order 1 reserves SKU A then SKU B while order 2 reserves B then A, Postgres will kill one of them. Sort SKUs before updating them, and merge duplicate SKU lines in the cart first.

## Low: small fixes

12. The data model doesn't name primary keys. Use `stock.sku` and `order_items (order_id, sku)` or a surrogate id. Add a foreign key from `order_items.order_id`.
13. Add check constraints: `available >= 0`, `quantity > 0`, and `status IN ('PENDING','PAID','FAILED')`, or use an enum type.
14. Add an index on `orders (status, created_at)` so the job's query stays cheap.
15. The tests don't cover:
    - the reconciliation job (paid, declined and not-found outcomes)
    - stock coming back after a decline
    - two buyers racing for the last unit
    - a reused key with a different body
    - two job instances running at once
    - a crash before the charge
    - an email failure
16. Say how long idempotency keys are kept and what happens to old `PENDING` rows. This is minor at 2,000 orders a day.
17. A request can take about 25 seconds in the worst case (four 5-second attempts plus backoff). Check that the load balancer and client timeouts are longer than that.

Load is not a concern. At 2,000 orders a day, this architecture has plenty of headroom.

VERDICT: READY WITH CHANGES
