Demo project

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.

  1. App is builtVerified
    createApp installs the JSON body parser, registers routes and the error handler.
  2. Orders router mountedVerified
    registerRoutes mounts ordersRouter under /api/orders.
  3. Authentication requiredVerified
    ordersRouter.use(requireAuth) runs before every order route.
  4. Controller handles requestVerified
    createOrder reads the user id from the request and delegates to placeOrder.
  5. Stock check and pricingVerified
    placeOrder loads every product and rejects with 409 if stock is insufficient.
  6. Order persisted as pendingVerified
    saveOrder writes the order row (upsert on id).
  7. Payment chargedVerified
    chargeCustomer creates a Stripe payment intent and stores the paid/failed status.
  8. Stock decrementedVerified
    decrementStock runs once per item after payment.
  9. Receipt emailedVerified
    sendOrderReceipt sends an SMTP email to the customer.
  10. No transactional boundaryInference
    No 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.