Execution flows
Follow how a request travels through the code. Steps link to real source; inferred steps are labeled.
Detected flows
Place an order POST /api/orders
An authenticated customer submits cart items; stock is checked, the order is saved, payment is charged, stock is decremented and a receipt is emailed.
- App is builtVerifiedcreateApp installs the JSON body parser, registers routes and the error handler.
- Orders router mountedVerifiedregisterRoutes mounts ordersRouter under /api/orders.
- Authentication requiredVerifiedordersRouter.use(requireAuth) runs before every order route.
- Controller handles requestVerifiedcreateOrder reads the user id from the request and delegates to placeOrder.
- Stock check and pricingVerifiedplaceOrder loads every product and rejects with 409 if stock is insufficient.
- Order persisted as pendingVerifiedsaveOrder writes the order row (upsert on id).
- Payment chargedVerifiedchargeCustomer creates a Stripe payment intent and stores the paid/failed status.
- Stock decrementedVerifieddecrementStock runs once per item after payment.
- Receipt emailedVerifiedsendOrderReceipt sends an SMTP email to the customer.
- No transactional boundaryInferenceNo database transaction wraps save, charge and stock update, so a failure in the middle can leave inconsistent state. This is a reading of the code, not an observed failure.