{
  "schemaVersion": "flowdrome.workflow.v1",
  "id": "",
  "name": "Sales — explode line items & roll up",
  "version": "0",
  "status": "draft",
  "nodes": [
    {
      "id": "seed",
      "type": "input.inject",
      "label": "Order with line items",
      "category": "trigger",
      "config": {
        "contentType": "application/json",
        "payload": {
          "orderId": "B-2001",
          "items": [
            {
              "sku": "WID-1",
              "qty": 3,
              "price": 10
            },
            {
              "sku": "WID-2",
              "qty": 1,
              "price": 45
            },
            {
              "sku": "WID-1",
              "qty": 2,
              "price": 10
            },
            {
              "sku": "WID-3",
              "qty": 5,
              "price": 6
            }
          ]
        }
      },
      "position": {
        "x": 0,
        "y": 0
      }
    },
    {
      "id": "explode",
      "type": "processing.split-out",
      "label": "Explode items",
      "category": "processing",
      "config": {
        "field": "items",
        "include": "none"
      },
      "position": {
        "x": 530,
        "y": 0
      }
    },
    {
      "id": "revenue",
      "type": "processing.set",
      "label": "Line revenue",
      "category": "processing",
      "config": {
        "mode": "manual",
        "assignments": [
          {
            "name": "revenue",
            "type": "number",
            "value": "{{ $json.qty * $json.price }}"
          }
        ],
        "include": "all",
        "dotNotation": true,
        "ignoreConversionErrors": false
      },
      "position": {
        "x": 1060,
        "y": 0
      }
    },
    {
      "id": "rollup",
      "type": "processing.aggregate",
      "label": "Per-SKU rollup",
      "category": "processing",
      "config": {
        "groupBy": "sku",
        "operations": [
          {
            "op": "sum",
            "field": "qty",
            "as": "units"
          },
          {
            "op": "sum",
            "field": "revenue",
            "as": "revenue"
          }
        ]
      },
      "position": {
        "x": 1590,
        "y": 0
      }
    },
    {
      "id": "out",
      "type": "utility.console",
      "label": "Dashboard feed",
      "category": "utility",
      "config": {
        "message": "SKU rollup: {{ $json }}"
      },
      "position": {
        "x": 2120,
        "y": 0
      }
    }
  ],
  "edges": [
    {
      "id": "e0",
      "sourceNodeId": "seed",
      "sourcePort": "output",
      "targetNodeId": "explode",
      "targetPort": "input"
    },
    {
      "id": "e1",
      "sourceNodeId": "explode",
      "sourcePort": "output",
      "targetNodeId": "revenue",
      "targetPort": "input"
    },
    {
      "id": "e2",
      "sourceNodeId": "revenue",
      "sourcePort": "output",
      "targetNodeId": "rollup",
      "targetPort": "input"
    },
    {
      "id": "e3",
      "sourceNodeId": "rollup",
      "sourcePort": "output",
      "targetNodeId": "out",
      "targetPort": "input"
    }
  ],
  "triggers": [
    {
      "id": "t0",
      "nodeId": "seed"
    }
  ],
  "meta": {
    "snippets": [],
    "source": "template-gallery",
    "description": "One order arrives with nested line items; Split Out explodes them into rows and Aggregate rolls revenue up per SKU — the shape you'd push to a dashboard."
  }
}