**design.md isn't ready to build from. The checkout flow in steps 3–6 can charge customers twice or charge them with no order recorded. The code structure and scale assumptions are fine.**

## Blocking problems

1. **Retrying the charge can double-charge customers (step 4).**
   - A timeout doesn't mean the charge failed. The provider may have processed it and the response was slow. Retrying up to 3 times can charge the card up to 4 times.
   - Fix: send an idempotency key with every charge call, for example one derived from the order id. Most providers support this. Also state which errors are retryable.

2. **A charge can succeed while the order is lost (steps 4–6).**
   - If the charge succeeds but the service crashes before commit, or the commit fails, the transaction rolls back. The customer is charged and there is no order.
   - Step 6 has the same problem. After timeouts, "failure" can mean the outcome is unknown, and rolling back then loses a possibly successful charge.
   - Fix:
     - Commit `PENDING` first.
     - Call the provider with the idempotency key.
     - Record the result in a second transaction.
     - Add a reconciliation job that resolves `PENDING` orders by querying the provider.
     - Add an explicit `PAYMENT_UNKNOWN` or similar state.

3. **The database transaction stays open during the external call (steps 3–5).**
   - With a 5 s timeout and 3 retries, the transaction can be open for 15–20 s or more while holding a connection and locks. A payment provider slowdown could exhaust the pool on a single Postgres instance.
   - The fix for problem 2 also fixes this. Don't hold a transaction across the network call.

4. **Clients can create duplicate orders.**
   - `POST /orders` has no client-supplied idempotency key. A retry after a mobile network drop or a double-click creates two orders and two charges.
   - Fix: require an `Idempotency-Key` header, store it with a unique constraint, and return the original result on replay.

## Should fix before launch

- **Stock handling is vague.** A 5-minute stale cache is a reasonable trade-off at this volume. But the doc doesn't say what happens when you oversell, such as a backorder or cancel-and-refund path, or whether the cache is decremented locally after a sale.
- **The confirmation email can fail or be lost after commit.** Send it from an outbox or a retryable job so a failure doesn't affect the order result.
- **Nightly backups on a single instance mean up to 24 hours of lost orders and payment records.** If you're on managed Postgres, turn on point-in-time recovery. It's cheap and worth it for payment data.
- **Tests only cover the happy path.** Add tests for payment timeout then success, duplicate requests, and a crash between charge and commit. These are the cases most likely to cause real incidents.

## What's fine

- The module boundaries, thin routes, the `OrderCheckout` class and structured logging with the order id are all reasonable.
- A single Postgres instance and a team of four are appropriate for 2,000 orders a day. Nothing needs to be more complex.

Rewrite the Flow section around idempotency and a commit-first state machine. That's probably a few hours of design work. After that I'd call it ready.

VERDICT: NOT READY
