Your design is close to ready. I'd fix the two stock-handling gaps below before you start building, because they are easy to fix on paper and expensive to find in code. The rest can be settled while you build.

The design suits the load (200 to 2,000 orders a day, one Postgres, four people). Reserving stock and inserting the order in one transaction, calling the provider outside it, and using the order id as the provider's idempotency key are all sound. I also like that the failing cases in the test list are concrete.

## Fix before building

**1. Reconciliation can leave stock reserved forever (high).**
- Evidence: line 34 restores stock when a charge is declined. Line 38 says reconciliation settles orders as `PAID` or `FAILED`, but it never says it restores stock.
- Failing case: a customer buys the last unit and the provider times out on every attempt, so the client gets `202`. Reconciliation later learns the charge was declined and marks the order `FAILED`. The unit stays reserved, so the product shows as sold out with no live order behind it.
- Fix: put "mark `FAILED` and restore stock" in one `OrderCheckout` method, and have both step 5 and the reconciliation job call it.

**2. Nothing stops stock being restored twice, or two instances settling the same order (high).**
- Evidence: there are two instances (line 6), and the reconciliation job runs on a timer (line 36). Nothing says only one instance runs it. Nothing says a status change only applies to an order that is still `PENDING`.
- Failing case: both instances pick up the same stale order, both see a decline, and both restore stock. `available` goes up by twice the quantity, so you can oversell.
- Fix: make every settle step `UPDATE orders SET status=… WHERE id=:id AND status='PENDING'`. Restore stock only if that update changed a row. This also covers the race between a slow in-flight request and the reconciliation job. Add a Postgres advisory lock or `FOR UPDATE SKIP LOCKED` so only one instance reconciles a given order.

**3. Reconciliation has no answer when the provider has never seen the charge (medium-high).**
- Evidence: line 22 commits the order as `PENDING` before the charge in line 27. If the service crashes between those two steps, the provider has no record of the order. The design doesn't say what reconciliation does when the provider answers "not found". It also doesn't say what it does when the provider reports "still processing".
- Fix: define the mapping. For example, "not found" means retry the charge using the same idempotency key, or mark the order `FAILED` and restore stock. "Processing" means leave the order `PENDING`.

## Fix during the build (small, but write them down now)

- **Deadlocks on stock updates (medium).** Two carts that contain the same two SKUs in opposite order will lock rows in opposite order. Sort the SKUs before reserving. Rows are only locked inside the transaction in line 22.
- **Duplicate request race (medium).** Lines 19–21 say a repeated key returns the existing order. Two concurrent requests with the same key will make one of them hit the unique-constraint error. The design should say that error is caught and the existing order is returned. It should also say what happens when the same key arrives with a different cart. I'd suggest `422`.
- **Where the price comes from (medium).** `unit_price` and `total` are stored, but the design doesn't say whether the server looks up prices or trusts the cart. If it trusts the client, the client can set its own price. This is the price integrity point that most needs a decision, so decide it first.
- **Schema constraints are missing (low-medium).**
  - Add the unique index on `idempotency_key` (it is only mentioned in prose). I'd make it unique per customer.
  - Add a primary key on `stock.sku`.
  - Add `CHECK (available >= 0)`.
  - Add a foreign key on `order_items.order_id`.
  - Add an index on `(status, created_at)` for the reconciliation query.
- **Tests are missing for the new behaviour (medium).** The list in lines 49–51 has no test for decline restoring stock, reconciliation (either outcome), or a concurrent duplicate key. Add those, plus the double-settle case from item 2.
- **Confirmation email can be lost (low).** Line 31 commits `PAID` and then queues the email. A crash between the two loses the email, and the order still shows `PAID`. At your volume, accepting this is reasonable. If you do, write it down as a known limit.

## Concerns I can't confirm from the document

- **Request length.** Three retries at 5 seconds each, plus backoff, could hold the HTTP request open for 20 seconds or more. It depends on your load balancer timeout, which the design doesn't state.
- **Authentication.** The design doesn't say how `customer_id` is established. It may be handled elsewhere.
- **Refunds and cancellations.** These are not covered. This is fine if they are out of scope for this revision, but say so.

With the deadline in mind, items 1 to 3 should take well under an hour to put into the document. The rest can be turned into tests and tickets as you build.

VERDICT: READY WITH CHANGES
