**The 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. Both come from the payment flow, which needs to be redesigned before you write code.

## Blockers

**1. Retrying the charge can double-charge.** Step 4 retries on a 5 s timeout, up to 3 times, with no idempotency key.
- **Failing case:** the provider charges the card but its response is slow. Your retry sends a second charge, and the customer pays 2× for one order.
- **Fix:** generate one idempotency key per order (the order id works) and send it on every attempt. Check that your provider supports one.

**2. A timeout is not a failure, but step 6 treats it as one.** After 3 timeouts you roll back and return an error. The charge may still have succeeded.
- **Failing case:** the customer is charged $80, the order row is rolled back, and the client sees an error. There is no record of the order, so support cannot find it and it cannot be refunded automatically.
- **Related case:** the charge succeeds and then the commit fails. The result is the same.
- **Fix:** commit the `PENDING` order first, outside the payment call. Move to `PAID` or `FAILED` once the outcome is known. Give "unknown" its own state, such as `PAYMENT_UNCERTAIN`. A background job should resolve it by querying the provider with the idempotency key.

**3. The payment call is inside the database transaction.** Three retries at 5 s each is more than 15 s with a connection held open.
- **Why it matters:** the transaction is also pointless. The `PENDING` row is invisible to everyone else until commit, and a rollback erases it. You lose the audit trail of failed attempts.
- **Fix:** this goes away with the restructure in blocker 2. No external call should happen inside a transaction.

**4. Nothing protects against a client retrying `POST /orders`.** A user double-clicks or the mobile client retries after a network drop, and you get two orders. Require a client-supplied idempotency key on the endpoint and store it with a unique constraint.

## Serious but not blocking

- **Stock is checked and never reserved.** The cache is up to 5 minutes stale, and nothing decrements it when an order is placed. Two customers can both buy the last unit. Accepting the cache for speed is a reasonable choice at 200 orders a day. However, the design needs to say what happens on oversell (cancel and refund, or backorder), or it has silently picked "refund by hand".
- **Backups are nightly with no point-in-time recovery.** A crash at 4 pm loses up to a day of paid orders, and the payment provider will have charged those customers. Turn on WAL archiving or point-in-time recovery. On managed Postgres this is usually a setting.
- **The confirmation email is sent inline after commit.** If the email provider is down, either the request fails after the customer was charged, or the email is silently lost. Write an outbox row in the same transaction as the `PAID` update and send from a worker.
- **Tests only cover the happy path.** The risks above are all in failure paths: timeout then success, timeout ×3, commit failure, and duplicate client request. Under your own standards, the payment-uncertainty and idempotency cases should be written first as tests. Add a fake payment provider that can be told to time out, so these tests are deterministic.

## Gaps to decide

- Which provider errors are retryable? A card decline must not be retried.
- Is there a reconciliation job comparing your orders against the provider's charges daily? With real money, it should exist from day one.
- Are refunds and cancellations in scope for v1?
- The "no module reads another's tables" rule is good. The design should still state which module owns the order state machine, since `OrderCheckout` now coordinates across all three.

## What's fine

The module split, thin routes, structured logging with the order id, and the scale assumptions. A single Postgres instance is fine for 2,000 orders a day. Accepting the stale cache is a defensible trade-off once oversell handling is written down.

## Suggested revised flow

```mermaid
flowchart TD
    A[POST /orders + client idempotency key] --> B[Check stock cache]
    B --> C[Insert order PENDING, commit]
    C --> D[Charge with order-id idempotency key]
    D -->|success| E[Mark PAID + outbox email row, commit]
    D -->|decline| F[Mark FAILED]
    D -->|timeout x3| G[Mark PAYMENT_UNCERTAIN]
    G --> H[Background job asks provider for the charge outcome]
    H --> E
    H --> F
```

Rework the design.md flow along these lines, add the failure-path test plan, and it should be ready to build. That is likely a few hours of design work, not days.

VERDICT: NOT READY
