**This design isn't ready to build tomorrow.** Step 4 can charge a customer twice, and step 6 can leave a customer charged with no order recorded. The fixes are small and fit your scale, so this is a day or two of design revision, not a rewrite.

## Blockers (fix before writing code)

**1. Retrying the charge can double-charge.**
- Step 4 retries after a 5 s timeout, but a timeout doesn't mean the charge failed. The provider may have charged the card and simply responded slowly.
- Example: the charge succeeds at the provider but the response takes 6 s. We retry and the customer is charged twice for one order. The design doesn't mention an idempotency key.
- Fix: send a stable idempotency key per order (the order id) on every charge attempt. Check that your provider supports one.

**2. A timeout followed by a rollback loses a real charge.**
- Step 6 rolls back on failure. If all 3 attempts time out, the money may have moved but the order row is gone. Support then has a customer complaint and no record to look up.
- Fix: persist the order as `PAYMENT_UNKNOWN` (not rolled back), and run a reconciliation job that asks the provider for the real status. Keep declined (definitive failure) and timed out (unknown) as separate outcomes.

**3. The database transaction stays open during the payment call.**
- Steps 3 to 5 hold a transaction, and so a pooled connection, across a network call that can take 3 × 5 s or more. Slow payments will exhaust your connection pool.
- This is also why the rollback problem in #2 exists. Fix: commit `PENDING`, call the provider outside any transaction, then update the status in a second short transaction.

**4. There is no client idempotency on `POST /orders`.**
- If the client times out and retries, two orders and two charges result. The design has no idempotency key on the request.
- Fix: require an `Idempotency-Key` header and store it with a unique constraint on the order.

## Serious gaps (fix in the doc, can be cheap)

**5. The stock check can oversell.**
- Accepting a cache that is up to 5 minutes old is a reasonable trade for 800 ms. But the design only reads the cache and never decrements or reserves stock.
- Example: 10 buyers each check the last unit within the same 5-minute window, and all 10 pass.
- Decide the policy explicitly. Either oversell is acceptable and you handle it with a backorder or refund flow, or you decrement the cache locally per order. Right now it's unaddressed.

**6. The confirmation email is sent inline, after commit.**
- A crash between commit and send means the customer is never emailed, and nothing retries it.
- Fix at your scale: a `confirmation_sent` flag plus a small retry job. A full outbox pattern isn't needed.

**7. Nightly backups on a single instance means up to 24 hours of lost orders and payments.**
- After a restore, you'd have charges at the provider with no matching orders.
- Fix: enable point-in-time recovery (WAL archiving, or the managed option if you're on one). It's cheap, and it's the same reconciliation problem as #2.

**8. Worst-case request time is over 15 seconds.**
- Three 5 s attempts plus backoff will exceed most client and load balancer timeouts. Define the client-facing behavior, for example return `202 Accepted` with the status `PROCESSING` and let the client poll.

## Tests (your own standard, so I'm holding this one firm)

"Unit tests per module and one happy-path integration test" doesn't meet your tests-first rule. The risky behavior is all in failure paths, so the plan needs at least these tests:
- Charge timeout followed by success on retry produces one charge (the idempotency key is reused).
- All attempts time out, the order ends as `PAYMENT_UNKNOWN`, and reconciliation resolves it.
- The provider declines, the order is `FAILED`, and nothing is retried.
- The same client `Idempotency-Key` sent twice produces one order.
- The last unit is bought concurrently, and the behavior matches the chosen oversell policy.
- The email fails after commit, and the retry job sends it.

Also add a payment-provider fake to the code structure. It needs to be able to simulate timeouts, since the tests above can't run without one.

## What's fine
- The module boundaries, the thin routes, and the `OrderCheckout` service class are sound.
- Structured logging with the order id is good. Add a metric and alert on `PAYMENT_UNKNOWN` count, since that's the state you most need to notice.
- Postgres on a single instance is appropriate for 2,000 orders a day. Don't add queues or sharding.

## Next step
Revise the doc to cover items 1 to 4 and the test list. Items 5 to 8 need a decision recorded in the doc, not necessarily more code. Then start building tomorrow, tests first.

VERDICT: NOT READY
