**design.md is close, but the payment step in the flow has a double-charge bug that you should fix before you build.**

## Must fix before building

1. **Retrying the charge can double-charge customers (step 4).**
   - A timeout doesn't tell you the charge failed. The provider may have processed it, and the retry then charges again.
   - Send an idempotency key with every charge call. Use the order id or a stored payment-attempt id, so all retries share the same key.
   - Most providers support this. Check that yours does.

2. **A timeout followed by rollback can leave a customer charged with no order (steps 4 and 6).**
   - If all 3 attempts time out, the design rolls back and returns an error. The charge may still have gone through.
   - The same thing happens if the commit fails after a successful charge.
   - Don't treat a timeout as a failure. Mark the order `PAYMENT_UNKNOWN` and have a reconciliation job query the provider to resolve it.
   - Use a provider webhook as well, if one exists.

3. **The database transaction stays open during the external calls (steps 3 to 5).**
   - Worst case is 3 × 5 s of retries, about 15 s or more, with the transaction and its connection held open.
   - At 2,000 orders a day that's fine on volume, but a slow provider can exhaust the connection pool.
   - Commit `PENDING` first, make the charge outside the transaction, then update the status in a second short transaction.
   - This also gives you the durable record that fixes item 2.

## Should fix

4. **Overselling.**
   - A 5-minute-stale cache with no reservation means two buyers can get the last item.
   - If overselling is acceptable (backorder or apology), say so in the doc.
   - If it isn't, decrement or reserve stock atomically at order time.

5. **Duplicate client requests.** `POST /orders` has no idempotency key, so a double-click or a client retry creates two orders. Accept an `Idempotency-Key` header and enforce it with a unique constraint.

6. **Confirmation email (step 5).** It's sent inline after commit. If it fails, specify whether that fails the request (it shouldn't) and how it gets retried. An outbox table or a simple retry job is enough.

7. **Backups.**
   - Nightly backups on a single instance mean up to 24 hours of lost orders and payments.
   - Given that you're handling payments, consider point-in-time recovery (WAL archiving or a managed Postgres).
   - This isn't a blocker for the first build.

8. **Tests.**
   - The plan covers only the happy path in integration.
   - The risky paths are payment timeout, retry with the same idempotency key, charge-succeeded-but-commit-failed, and a duplicate client request.
   - Add integration tests with a fake payment provider for those.

## What's fine
- The scale is small, so a single Postgres instance and a monolith with modules are reasonable.
- The module boundaries, the thin routes with an `OrderCheckout` class, and logging the order id on every line are all good.
- Accepting the stale cache is a defensible trade-off, as long as you state the overselling consequence.

The fixes for items 1 to 3 change the flow itself (an explicit order state machine, idempotent charges, reconciliation). Revise the Flow section first, and then you can start building.

VERDICT: READY WITH CHANGES
