{
  "schema_version": 1,
  "diagram_type": "sequence",
  "meta": {
    "title": "iSpeed.my — Cancel Order Flow",
    "subtitle": "Order cancellation with trade PIN verification",
    "output": "ispeed-cancel-order.html",
    "viewBox": [1080, 620],
    "column_fit": "spread",
    "animation": "trace",
    "quality_profile": "showcase",
    "views": [
      { "id": "select-to-pin", "label": "Select to PIN", "focus": ["user", "app", "mobile-api"], "note": "Order selection and trade PIN entry" },
      { "id": "cancel-submit", "label": "Cancel Submit", "focus": ["app", "web-api", "session", "vbroker"], "note": "Backend cancellation via VBroker" },
      { "id": "full-flow", "label": "Full Flow", "focus": ["user", "app", "mobile-api", "web-api", "session", "vbroker"], "note": "Complete cancel lifecycle" }
    ]
  },
  "participants": [
    { "id": "user", "type": "external", "label": "User", "sublabel": "Trader" },
    { "id": "app", "type": "frontend", "label": "React Native App", "sublabel": "Expo SDK 56" },
    { "id": "mobile-api", "type": "backend", "label": "Mobile API", "sublabel": "rt-mx-mobile-api" },
    { "id": "web-api", "type": "backend", "label": "Web API", "sublabel": "rt-mx-web-api" },
    { "id": "session", "type": "database", "label": "AuthConn", "sublabel": "Redis sessions" },
    { "id": "vbroker", "type": "external", "label": "VBroker API", "sublabel": "Back office" }
  ],
  "segments": [
    { "from": 155, "to": 265, "label": "Select Order" },
    { "from": 275, "to": 385, "label": "Trade PIN" },
    { "from": 395, "to": 535, "label": "Cancel + Result" }
  ],
  "messages": [
    { "id": "c1", "from": "user", "to": "app", "y": 160, "label": "Select order to cancel", "variant": "default" },
    { "id": "c2", "from": "app", "to": "user", "y": 190, "label": "Show trade PIN input", "variant": "return" },
    { "id": "c3", "from": "user", "to": "app", "y": 220, "label": "Enter trade PIN", "variant": "default" },
    { "id": "c4", "from": "app", "to": "mobile-api", "y": 250, "label": "POST CancelOrderService", "variant": "emphasis" },
    { "id": "c5", "from": "mobile-api", "to": "web-api", "y": 280, "label": "CancelOrderService", "variant": "default" },
    { "id": "c6", "from": "web-api", "to": "session", "y": 310, "label": "validate + dup check", "variant": "security" },
    { "id": "c7", "from": "session", "to": "web-api", "y": 340, "label": "session valid", "variant": "return" },
    { "id": "c8", "from": "web-api", "to": "vbroker", "y": 370, "label": "cancelOrder", "variant": "emphasis" },
    { "id": "c9", "from": "vbroker", "to": "web-api", "y": 400, "label": "cancelled order number", "variant": "return" },
    { "id": "c10", "from": "web-api", "to": "mobile-api", "y": 430, "label": "orderNo + cancel_success", "variant": "return" },
    { "id": "c11", "from": "mobile-api", "to": "app", "y": 460, "label": "cancel response", "variant": "return" },
    { "id": "c12", "from": "app", "to": "user", "y": 490, "label": "Show cancelled success screen", "variant": "return" }
  ],
  "activations": [
    { "participant": "app", "from": 155, "to": 500, "type": "frontend" },
    { "participant": "mobile-api", "from": 250, "to": 470, "type": "backend" },
    { "participant": "web-api", "from": 280, "to": 440, "type": "backend" },
    { "participant": "session", "from": 305, "to": 350, "type": "database" },
    { "participant": "vbroker", "from": 365, "to": 410, "type": "external" }
  ],
  "cards": [
    {
      "dot": "emerald",
      "title": "Cancel Flow",
      "items": [
        "Cancel requires trade PIN for authorization",
        "SessionHelper prevents duplicate cancel requests",
        "Backend routes to VBroker cancelOrder endpoint"
      ]
    },
    {
      "dot": "rose",
      "title": "Security",
      "items": [
        "Trade PIN validated server-side by VBroker",
        "Duplicate order detection via Redis",
        "Account state checked before cancellation"
      ]
    }
  ]
}