**design.md isn't ready to build as written. The payment flow (steps 3–6) can double-charge customers and lose paid orders. The fixes are small and the rest of the design is sound, so you could make them tonight and start tomorrow.**

## Must fix before building

1. **Retrying the charge can double-charge (step 4).** A timeout doesn't mean the charge failed. It may have succeeded on the provider's side. Retrying without an idempotency key can charge the customer up to 4 times.
   - Generate a stable idempotency key per order, for example the order id, and send it on every charge attempt.
   - Confirm the provider supports idempotency keys. If it doesn't, the retry policy needs a different design.

2. **A paid order can be rolled back (step 6).** If all attempts time out but the charge actually went through, you roll back the order and tell the client it failed. The customer is charged and has no order.
   - Treat a timeout as an unknown outcome, not a failure.
   - Commit the order as `PENDING` first, then resolve it by querying the provider or handling its webhook. Only a definite decline should move it to `FAILED`.

3. **The database transaction stays open during the payment call (steps 3–5).** With 5 s timeouts and 3 retries, the transaction can be held for 15 s or more, holding a connection the whole time. On a single Postgres instance this will cause pool exhaustion once traffic grows.
   - Commit `PENDING` before calling the provider.
   - Then update the order status in a second, short transaction.
   - This also fixes problem 2.

4. **No idempotency on `POST /orders`.** If a client retries after a network drop, it creates a duplicate order and a duplicate charge. Accept a client-supplied idempotency key and enforce it with a unique constraint.

## Should decide before building

5. **Overselling from the stock cache (step 2).** A 5-minute-stale cache is fine for browsing, but nothing here decrements or reserves stock at order time. Two buyers can both get the last item. Decide whether overselling is acceptable (backorder or refund) or whether you need a reservation. Write the decision down either way.

6. **The confirmation email can be lost (step 5).** If the process crashes after commit but before sending, the email is never sent. At 2,000 orders a day, a simple `email_sent` flag plus a retry job is enough. You don't need a queue.

7. **Test plan covers only the happy path.** The bugs above are all in the failure paths. Add integration tests for charge timeout then success, decline, duplicate request, and crash between charge and commit.

## What's fine

- **Scale and infrastructure:** The scale and a single Postgres instance are fine for 2,000 orders a day.
- **Code structure:** The module boundaries, thin routes, and `OrderCheckout` class are reasonable.
- **Logging:** Logging the order id on every line is good. Add the idempotency key and provider reference.
- **Backups:** Nightly backups mean up to 24 hours of lost orders and payments on failure. Consider enabling WAL archiving or point-in-time recovery, since this is payment data. That's not a blocker for starting.

VERDICT: READY WITH CHANGES
