**Short answer: you can start building tomorrow.** The core design is sound. Reserving stock and creating the order in one transaction, calling the payment provider outside any transaction with the order id as its idempotency key, and running a reconciliation job are the right choices for this scale. Two problems should be fixed in the doc before you write the payment and reconciliation code. Neither is a redesign; each is a few lines. Everything else is a clarification you can make as you go.

## Must fix before building those parts

**1. Settling an order twice gives back stock twice. (High)**
The request path (steps 4 and 5) and the reconciliation job (step 6) can both settle the same order. The job could also run on both instances at once. Nothing in the doc says a settlement only happens if the order is still `PENDING`.
- *Case:* an order for 1 unit of SKU `A` (stock 10 → 9) stays `PENDING`. Both instances run reconciliation, both learn the charge was declined, and both mark it `FAILED` and restore stock. Stock goes to 11. It should be 10.
- *Fix:* make every status change conditional, e.g. `UPDATE orders SET status = 'FAILED' WHERE id = :id AND status = 'PENDING'`. Only restore stock or queue the email if that update changed exactly one row. Also, step 6 should say that reconciliation uses the same transitions as steps 4 and 5: restore stock on `FAILED`, queue the email on `PAID`.

**2. Reconciliation has no answer for "the provider has never heard of this charge." (High)**
If an instance crashes after step 2 commits but before step 3 sends the charge, the order is `PENDING` and the provider has no record of it. Step 6 only says how to settle as `PAID` or `FAILED`.
- *Case:* the order commits, the instance is restarted during a deploy, and reconciliation asks the provider for the order id's charge status and gets "not found." What happens is undefined. The order likely sits until the 30-minute alert fires, with stock held.
- *Fix:* decide what reconciliation does in that case. Either retry the charge with the same idempotency key, or mark the order `FAILED` and restore stock. Also confirm that your provider supports looking up a charge by idempotency key, because step 6 depends on it.

```mermaid
stateDiagram-v2
    [*] --> PENDING: stock reserved, order inserted
    PENDING --> PAID: charge succeeded (request or reconciliation)
    PENDING --> FAILED: charge declined (request or reconciliation)
    PENDING --> PENDING: result unknown, 202 returned
    PENDING --> undefined: provider has no record of the charge (problem 2)
    PAID --> [*]
    FAILED --> [*]
```

## Medium: clarify while building

3. **Where prices come from.** The doc doesn't say whether `unit_price` and `total` come from the client's cart or from the server. If they come from the client, a client can set its own price. State that prices are looked up on the server.
4. **Deadlocks between concurrent orders.** Two carts containing SKUs `A` and `B` in opposite order can deadlock in step 2. Update the stock rows in sorted SKU order, and merge duplicate SKU lines first.
5. **The client has no way to learn the final status after a `202`.** No `GET /orders/{id}` endpoint is described, so a client that got `202` can't find out whether it was charged.
6. **The same idempotency key sent with a different cart.** Today this silently returns the first order. Common practice is to reject it with `422`. Also decide whether keys are unique across all customers or per customer.
7. **Two simultaneous requests with the same key.** One of them will hit the unique-constraint violation. That request's transaction rolls back, which correctly releases its stock reservation. The code then has to catch the violation and return the existing order rather than a `500`. Worth one sentence in the doc.
8. **The confirmation email can be lost.** If the instance dies after the `PAID` commit but before the email is queued, no email is sent. Writing an outbox row in the same transaction fixes this. The doc also doesn't name the queue it uses; it isn't in the Context section.
9. **Module boundaries vs. the step 2 transaction.** One transaction writes both the inventory table (`stock`) and the orders tables. That's fine, but say how it fits "no module reads another module's tables": for example, each module's repository joins a transaction that `OrderCheckout` owns.
10. **Missing tests for the riskiest parts:**
    - reconciliation (`PAID`, `FAILED`, provider has no record)
    - two buyers racing for the last unit
    - two simultaneous requests with the same key
    - a decline restores stock
    - an email failure leaves the order `PAID`
    - a request settling an order at the same moment as reconciliation (problem 1)

## Minor

11. **Missing database constraints:** primary keys on `order_items` and `stock(sku)`, foreign keys, `CHECK (available >= 0)`, `CHECK (quantity > 0)`, a check constraint on `status`, and the unique index on `idempotency_key` (it's only mentioned in prose).
12. **Which payment errors get retried.** Retry only timeouts and 5xx responses, never declines.
13. **Worst-case request time.** About 4 × 5 s plus backoff, roughly 30 s. Check that the load balancer's and clients' timeouts allow it. Also write down that this has to stay well under the 2-minute reconciliation threshold, so reconciliation never picks up an order that's still being retried.
14. **Response codes aren't specified** for success (`201`?) or decline (`402`?).
15. **Scope.** Say that refunds and cancellations are out of scope for this revision.

Volume is not a concern. 2,000 orders a day is trivial for this setup.

VERDICT: READY WITH CHANGES
