{
  "docVersion": 1,
  "id": "template-serverless-event-backbone",
  "name": "Serverless event backbone",
  "purpose": "Event-driven serverless reference: bridge routing into a choreographed lane and an orchestrated lane, async request-reply via status store, DLQ destinations.",
  "nodes": {
    "client": {
      "type": "mobile",
      "label": "Client App",
      "x": 20,
      "y": 300,
      "runtime": "fire and poll"
    },
    "apigw": {
      "type": "gateway",
      "label": "API Gateway",
      "x": 280,
      "y": 300,
      "runtime": "returns 202 + request id"
    },
    "bridge": {
      "type": "bus",
      "label": "Event Bridge",
      "x": 540,
      "y": 300,
      "runtime": "content-based routing",
      "color": "blue",
      "notes": "Routing rules match event shape → targets. Producers don't know consumers exist."
    },
    "warm": {
      "type": "cron",
      "label": "Warmer",
      "x": 540,
      "y": 80,
      "runtime": "provisioned concurrency"
    },
    "fn1": {
      "type": "lambda",
      "label": "Validate Fn",
      "x": 800,
      "y": 80,
      "runtime": "reacts to OrderReceived",
      "patterns": [
        "stateless"
      ]
    },
    "fn2": {
      "type": "lambda",
      "label": "Enrich Fn",
      "x": 1060,
      "y": 80,
      "runtime": "reacts to Validated",
      "patterns": [
        "stateless"
      ]
    },
    "orch": {
      "type": "orchestrator",
      "label": "Step Orchestrator",
      "x": 800,
      "y": 400,
      "runtime": "state machine owns the flow",
      "color": "purple",
      "notes": "Every step, retry and branch is visible in one definition — pay with coupling, buy auditability."
    },
    "fn3": {
      "type": "lambda",
      "label": "Reserve Fn",
      "x": 1060,
      "y": 320,
      "runtime": "step 1 · retry policy"
    },
    "fn4": {
      "type": "lambda",
      "label": "Charge Fn",
      "x": 1060,
      "y": 480,
      "runtime": "step 2 · idempotent"
    },
    "status": {
      "type": "keyvalue",
      "label": "Status Store",
      "x": 540,
      "y": 540,
      "runtime": "request id → progress"
    },
    "dlq": {
      "type": "dlq",
      "label": "DLQ + destinations",
      "x": 1320,
      "y": 300,
      "runtime": "failures, parked",
      "color": "amber"
    }
  },
  "edges": {
    "e1": {
      "from": "client",
      "to": "apigw",
      "fromSide": "right",
      "toSide": "left",
      "label": "POST → 202 Accepted",
      "animated": true
    },
    "e2": {
      "from": "apigw",
      "to": "bridge",
      "fromSide": "right",
      "toSide": "left",
      "label": "OrderReceived",
      "style": "dashed",
      "animated": true
    },
    "e3": {
      "from": "client",
      "to": "status",
      "fromSide": "bottom",
      "toSide": "left",
      "label": "poll GET /status/:id",
      "style": "dashed"
    },
    "e4": {
      "from": "bridge",
      "to": "fn1",
      "fromSide": "top",
      "toSide": "left",
      "label": "rule: source=checkout",
      "style": "dashed"
    },
    "e5": {
      "from": "fn1",
      "to": "fn2",
      "fromSide": "right",
      "toSide": "left",
      "label": "Validated event",
      "style": "dashed",
      "patterns": [
        "dedup"
      ]
    },
    "e6": {
      "from": "warm",
      "to": "fn1",
      "fromSide": "right",
      "toSide": "left",
      "label": "keep warm",
      "style": "dashed"
    },
    "e7": {
      "from": "bridge",
      "to": "orch",
      "fromSide": "bottom",
      "toSide": "left",
      "label": "rule: needs saga",
      "style": "dashed"
    },
    "e8": {
      "from": "orch",
      "to": "fn3",
      "fromSide": "right",
      "toSide": "left",
      "label": "invoke",
      "patterns": [
        "retry",
        "timeout"
      ]
    },
    "e9": {
      "from": "orch",
      "to": "fn4",
      "fromSide": "right",
      "toSide": "left",
      "label": "invoke",
      "patterns": [
        "idempotent"
      ]
    },
    "e10": {
      "from": "orch",
      "to": "status",
      "fromSide": "left",
      "toSide": "right",
      "label": "write progress"
    },
    "e11": {
      "from": "fn4",
      "to": "dlq",
      "fromSide": "right",
      "toSide": "bottom",
      "label": "after N failures",
      "style": "dashed"
    }
  },
  "boxes": {
    "b1": {
      "x": 760,
      "y": 20,
      "w": 560,
      "h": 220,
      "label": "choreography — functions react, nobody owns the flow",
      "color": "green",
      "opacity": 0.04
    },
    "b2": {
      "x": 760,
      "y": 280,
      "w": 560,
      "h": 360,
      "label": "orchestration — the state machine owns the flow",
      "color": "purple",
      "opacity": 0.04
    }
  },
  "texts": {
    "t1": {
      "x": 20,
      "y": 480,
      "text": "choreography scales teams;\norchestration scales understanding —\nchoose per flow, not per company",
      "color": "purple",
      "size": 12
    },
    "t2": {
      "x": 20,
      "y": 620,
      "text": "202 + status endpoint = async request-\nreply: no held connections, no gateway\ntimeouts, retries stay client-side",
      "color": "blue",
      "size": 12
    }
  },
  "meta": {
    "createdAt": "2026-07-13T09:00:00.000Z",
    "modifiedAt": "2026-07-13T09:00:00.000Z"
  }
}