**The design isn't ready to build. The payment flow (steps 3–6) can double-charge customers and can charge them without recording an order. Fix that before you start.**

## Blocking problems

1. **Retrying the charge can double-charge.** Step 4 retries on a 5 s timeout, up to 3 times. A timeout doesn't mean the charge failed. The provider may have captured the money and just been slow to answer. The design doesn't mention an idempotency key, so each retry can create a new charge. Generate one key per order (the order id works) and send it on every attempt.

2. **A customer can be charged with no order on record.** The order row sits in an uncommitted transaction while the charge happens. If the process crashes, or the commit fails, after the charge succeeds, the `PENDING` row is rolled back. The money is taken and nothing in your database says why.
   - Step 6 has the same hole. After three timeouts it rolls back and returns an error, but the charge may have gone through.
   - Commit `PENDING` first, outside the payment call. Then call the provider and move the order to `PAID`, `FAILED`, or `PAYMENT_UNKNOWN` in a separate step.
   - Add a reconciliation job that resolves `PAYMENT_UNKNOWN` and stale `PENDING` orders by asking the provider.
   - Add the provider's webhook as a second source of truth.

3. **A database transaction stays open during the external call.** Step 4 can hold a connection and row locks for 15 s or more (3 × 5 s plus backoff), and the provider's bad days will exhaust your connection pool. This goes away if you fix point 2.

4. **Nightly backups on a single instance put up to 24 hours of paid orders at risk.** If the disk dies at 5pm, you lose a day of orders that customers have already paid for. Enable WAL archiving or point-in-time recovery, and write down your recovery point and recovery time targets. Managed Postgres usually gives you this by default.

## Serious gaps

5. **Stock is checked against a 5-minute-old cache, and nothing decrements or reserves it.** Two buyers can both take the last unit. The 800 ms argument justifies reading the cache, but it says nothing about what happens when the cache is wrong. Decide explicitly: oversell and apologize, backorder, or re-check the warehouse at commit time for low-stock items. Also say who decrements stock, and when.

6. **There's no idempotency on `POST /orders` itself.** A client retry or a double-click creates two orders and two charges. Require a client-supplied idempotency key with a unique constraint.

7. **Step 6 treats every failure the same.** A card decline, a provider outage, and a timeout need different responses and different client messages. Only the last one is ambiguous, which is point 2.

8. **The confirmation email is sent inline after commit.** If the email send fails, what does the client see? Does the order stay `PAID`? Write the email intent to the database in the same transaction as `PAID` and send it from a background worker.

9. **The tests skip the failure paths.** You have one integration test, for the happy path, and every real risk is on the unhappy paths. Before shipping, add integration tests against a fake payment provider for these cases:
   - timeout then success (and no double-charge)
   - timeout on all three attempts
   - crash between charge and commit
   - decline
   - duplicate client request

## Missing from the doc

- An order state machine: the allowed states and transitions (`PENDING`, `PAID`, `FAILED`, `PAYMENT_UNKNOWN`, and so on).
- Cancellation and refunds.
- Authentication on `POST /orders`.
- Alerting on stuck orders and on the payment error rate.

## What's fine

- The scale is small (200 to 2,000 orders a day, one team). A single Postgres instance, a modular monolith, and a thin-routes plus `OrderCheckout` structure are proportionate. Don't add queues or microservices to fix the points above. A background job runner and an outbox table are enough.
- The module boundaries and structured logging with the order id are good.

Estimate about a day to rewrite steps 3–6 with the committed-`PENDING`, idempotency-key, and reconciliation design, and to settle the stock policy. You could then start building the next day.

VERDICT: NOT READY
