{
  "title": "Order Processing Workflow",
  "description": "From checkout to delivery: verify the payment, commit once, and fulfill through a durable outbox.",
  "graph": {
    "direction": "LR",
    "nodes": [
      {
        "id": "checkout",
        "type": "io",
        "label": "Checkout",
        "description": "The customer reviews the basket and submits an order request with a stable checkout key. No payment result is trusted from the browser.",
        "group": "",
        "groupId": "commerce",
        "category": "frontend",
        "position": {
          "x": 80,
          "y": 180
        },
        "basis": "unknown",
        "sources": [
          {
            "repository": "",
            "path": "",
            "revision": "",
            "note": "Authored reference design for explaining system behavior. It describes a possible implementation, not production telemetry or an observed incident."
          }
        ]
      },
      {
        "id": "order_api",
        "type": "process",
        "label": "Create order",
        "description": "Resolve the stable checkout key and create or return the same pending order. Server-side prices and inventory rules determine the order total.",
        "group": "",
        "groupId": "commerce",
        "category": "backend",
        "position": {
          "x": 420,
          "y": 180
        },
        "basis": "unknown",
        "sources": []
      },
      {
        "id": "order_ledger",
        "type": "datastore",
        "label": "Order ledger",
        "description": "Persist the pending order before opening a hosted payment session. The stored order ID links the later payment event to this record.",
        "group": "",
        "groupId": "commerce",
        "category": "database",
        "position": {
          "x": 420,
          "y": 500
        },
        "basis": "unknown",
        "sources": []
      },
      {
        "id": "customer_update",
        "type": "terminal",
        "label": "Order confirmed",
        "description": "The customer sees the current durable order status. The worker may also send a confirmation; a delayed notification does not undo an accepted order.",
        "group": "",
        "groupId": "commerce",
        "category": "frontend",
        "position": {
          "x": 80,
          "y": 780
        },
        "basis": "unknown",
        "sources": []
      },
      {
        "id": "hosted_payment",
        "type": "process",
        "label": "Hosted payment",
        "description": "The payment provider handles card entry and payment authorization. A browser redirect is presentation only; the signed provider event is the payment signal.",
        "group": "",
        "groupId": "payments",
        "category": "external",
        "position": {
          "x": 800,
          "y": 180
        },
        "basis": "unknown",
        "sources": []
      },
      {
        "id": "verify_event",
        "type": "process",
        "label": "Verify webhook",
        "description": "Check the signature against the exact request body, validate the event type and amount, and resolve the stored order. Invalid messages stop here with an appropriate error response.",
        "group": "",
        "groupId": "payments",
        "category": "backend",
        "position": {
          "x": 800,
          "y": 500
        },
        "basis": "unknown",
        "sources": []
      },
      {
        "id": "seen_event",
        "type": "decision",
        "label": "Event already seen?",
        "description": "Look up the provider event ID. This read is only an optimization: the subsequent transaction enforces a unique event ID so simultaneous deliveries cannot duplicate the order transition.",
        "group": "",
        "groupId": "payments",
        "category": "backend",
        "position": {
          "x": 1160,
          "y": 458
        },
        "basis": "unknown",
        "sources": []
      },
      {
        "id": "acknowledge",
        "type": "terminal",
        "label": "Acknowledge",
        "description": "Return a successful HTTP response after an existing event is recognized or after the new order transaction commits. Do not wait for fulfillment to finish.",
        "group": "",
        "groupId": "payments",
        "category": "backend",
        "position": {
          "x": 1160,
          "y": 790
        },
        "basis": "unknown",
        "sources": []
      },
      {
        "id": "commit_order",
        "type": "process",
        "label": "Commit paid order",
        "description": "Atomically insert the unique event receipt, transition the order to paid, and insert its outbox message. If another delivery already won, acknowledge that existing result.",
        "group": "",
        "groupId": "delivery",
        "category": "backend",
        "position": {
          "x": 1580,
          "y": 180
        },
        "basis": "unknown",
        "sources": []
      },
      {
        "id": "outbox",
        "type": "datastore",
        "label": "Order outbox",
        "description": "Durable work created in the same transaction as the paid order. The worker claims an item, records attempts and retains it until processing succeeds.",
        "group": "",
        "groupId": "delivery",
        "category": "database",
        "position": {
          "x": 1580,
          "y": 500
        },
        "basis": "unknown",
        "sources": []
      },
      {
        "id": "worker",
        "type": "process",
        "label": "Fulfill order",
        "description": "Process the outbox item using the order ID as an idempotency key. Retry transient failures; record completed fulfillment before sending the customer update.",
        "group": "",
        "groupId": "delivery",
        "category": "backend",
        "position": {
          "x": 1580,
          "y": 790
        },
        "basis": "unknown",
        "sources": []
      }
    ],
    "edges": [
      {
        "id": "checkout_request",
        "source": "checkout",
        "target": "order_api",
        "label": "Order request",
        "description": "",
        "sourceHandle": "right",
        "targetHandle": "left",
        "basis": "unknown",
        "sources": []
      },
      {
        "id": "persist_pending",
        "source": "order_api",
        "target": "order_ledger",
        "label": "Pending",
        "description": "",
        "sourceHandle": "bottom",
        "targetHandle": "top",
        "basis": "unknown",
        "sources": []
      },
      {
        "id": "open_checkout",
        "source": "order_ledger",
        "target": "hosted_payment",
        "label": "Open checkout",
        "description": "",
        "sourceHandle": "right",
        "targetHandle": "left",
        "basis": "unknown",
        "sources": []
      },
      {
        "id": "payment_event",
        "source": "hosted_payment",
        "target": "verify_event",
        "label": "Signed event",
        "description": "",
        "sourceHandle": "bottom",
        "targetHandle": "top",
        "basis": "unknown",
        "sources": []
      },
      {
        "id": "verified_event",
        "source": "verify_event",
        "target": "seen_event",
        "label": "Valid event",
        "description": "",
        "sourceHandle": "right",
        "targetHandle": "left",
        "basis": "unknown",
        "sources": []
      },
      {
        "id": "known_event",
        "source": "seen_event",
        "target": "acknowledge",
        "label": "Yes",
        "description": "",
        "sourceHandle": "bottom",
        "targetHandle": "top",
        "basis": "unknown",
        "sources": []
      },
      {
        "id": "new_event",
        "source": "seen_event",
        "target": "commit_order",
        "label": "No",
        "description": "",
        "sourceHandle": "right",
        "targetHandle": "left",
        "basis": "unknown",
        "sources": []
      },
      {
        "id": "durable_outbox",
        "source": "commit_order",
        "target": "outbox",
        "label": "Same transaction",
        "description": "",
        "sourceHandle": "bottom",
        "targetHandle": "top",
        "basis": "unknown",
        "sources": []
      },
      {
        "id": "ack_commit",
        "source": "outbox",
        "target": "acknowledge",
        "label": "Committed",
        "description": "",
        "sourceHandle": "left",
        "targetHandle": "right",
        "basis": "unknown",
        "sources": []
      },
      {
        "id": "claim_work",
        "source": "outbox",
        "target": "worker",
        "label": "Claim job",
        "description": "",
        "sourceHandle": "bottom",
        "targetHandle": "top",
        "basis": "unknown",
        "sources": []
      },
      {
        "id": "retry_work",
        "source": "worker",
        "target": "outbox",
        "label": "Retry",
        "description": "A failed delivery attempt is retained and retried with backoff; the worker does not create a second paid order.",
        "sourceHandle": "right",
        "targetHandle": "right",
        "basis": "unknown",
        "sources": []
      },
      {
        "id": "notify_customer",
        "source": "worker",
        "target": "customer_update",
        "label": "Customer update",
        "description": "",
        "sourceHandle": "bottom",
        "targetHandle": "bottom",
        "basis": "unknown",
        "sources": []
      }
    ],
    "groups": [
      {
        "id": "commerce",
        "label": "Commerce",
        "description": "The customer journey and durable pending order."
      },
      {
        "id": "payments",
        "label": "Payment boundary",
        "description": "Treat signed payment events as untrusted input until verified; acknowledge duplicate delivery without repeating work."
      },
      {
        "id": "delivery",
        "label": "Order delivery",
        "description": "Record the paid state and an outbox message together, then fulfill idempotently."
      }
    ]
  },
  "investigation": null
}
