**Short answer:** The scale, module layout and code structure are fine for a team of four. The payment steps (4–6) can charge a customer twice or charge them with no order, so fix those in the doc before you build.

## Must fix before building

1. **Retrying the charge can double-charge (step 4).** A timeout doesn't mean the charge failed. Retrying up to 3 times without an idempotency key can charge the customer several times. Generate one key per order, for example the order id, and send it on every attempt. Also say what happens when all retries time out and the outcome is unknown.

2. **The database transaction stays open during the payment call (steps 3–5).** With 5 s timeouts and 3 retries, the transaction can be held open for 15 s or more, along with a connection. That's manageable at 200 orders a day, but it will hurt at 2,000. Insert `PENDING` and commit. Then call the provider, and then update the status in a second transaction.

3. **Rolling back after a charge leaves no record (step 6).** If the provider charged the card but the response timed out, the rollback deletes the `PENDING` order. The customer is charged and you have no order. The same happens if the commit fails after a successful charge. Keep the order row and use explicit states such as `PENDING`, `PAID`, `FAILED` and `PAYMENT_UNKNOWN`. Add a reconciliation job or webhook that resolves `PAYMENT_UNKNOWN` against the provider.

4. **`POST /orders` has no idempotency.** If a client retries after a dropped response, it creates a second order. Require a client-supplied idempotency key and make it unique in the database.

## Should address

- **Stock isn't reserved or decremented.** A cache that's up to 5 minutes stale is a reasonable trade-off, but the doc should say what happens when you oversell: back-order, cancel or refund. Say who handles it.
- **Confirmation email.** It's sent inline after the commit. If it fails, does the order fail? It shouldn't. Send it asynchronously with a retry, for example from an outbox table.
- **Backups.** Nightly backups on a single instance means up to 24 hours of lost orders and payments. Either accept that explicitly or enable WAL archiving or point-in-time recovery. The latter is cheap on managed Postgres.
- **Tests.** Only the happy path is covered. Add tests for payment timeout then success, all retries timing out, a duplicate request, and a provider error. Those are the paths where you lose money.
- **Logging.** Add the idempotency key and the provider's charge id to the log lines.

VERDICT: READY WITH CHANGES
