{
  "schema_version": 1,
  "diagram_type": "sequence",
  "meta": {
    "title": "iSpeed.my — New Order Flow",
    "subtitle": "End-to-end order placement with trade PIN authentication",
    "output": "ispeed-new-order.html",
    "viewBox": [1080, 1040],
    "column_fit": "spread",
    "animation": "trace",
    "quality_profile": "showcase",
    "views": [
      { "id": "form-to-confirm", "label": "Form to Confirmation", "focus": ["user", "app", "mobile-api", "web-api"], "note": "Order entry form through confirmation estimate" },
      { "id": "trade-pin-and-submit", "label": "Trade PIN & Submit", "focus": ["app", "mobile-api", "web-api", "session", "vbroker"], "note": "Trade PIN validation and VBroker order submission" },
      { "id": "full-flow", "label": "Full Flow", "focus": ["user", "app", "mobile-api", "web-api", "session", "appconfig", "vbroker"], "note": "Complete order lifecycle from entry to success" }
    ]
  },
  "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": "appconfig", "type": "cloud", "label": "AppConfig", "sublabel": "Config + RIC codes" },
    { "id": "vbroker", "type": "external", "label": "VBroker API", "sublabel": "Back office" }
  ],
  "segments": [
    { "from": 155, "to": 325, "label": "Order Entry" },
    { "from": 335, "to": 475, "label": "Confirmation Estimate" },
    { "from": 485, "to": 625, "label": "Trade PIN + Submit" },
    { "from": 635, "to": 955, "label": "Result" }
  ],
  "messages": [
    { "id": "m1", "from": "user", "to": "app", "y": 160, "label": "Open order form", "variant": "default" },
    { "id": "m2", "from": "app", "to": "mobile-api", "y": 190, "label": "POST /mobile-exs/member (login)", "variant": "emphasis" },
    { "id": "m3", "from": "mobile-api", "to": "session", "y": 220, "label": "validate + store session", "variant": "security" },
    { "id": "m4", "from": "mobile-api", "to": "app", "y": 250, "label": "session ID", "variant": "return" },
    { "id": "m5", "from": "app", "to": "user", "y": 280, "label": "Render order form", "variant": "return" },
    { "id": "m6", "from": "user", "to": "app", "y": 310, "label": "Fill form + tap Confirm", "variant": "default" },
    { "id": "m7", "from": "app", "to": "mobile-api", "y": 340, "label": "POST /mobile-exs/{{session}} (login)", "variant": "emphasis" },
    { "id": "m8", "from": "mobile-api", "to": "session", "y": 370, "label": "refresh session", "variant": "security" },
    { "id": "m9", "from": "mobile-api", "to": "app", "y": 400, "label": "session OK", "variant": "return" },
    { "id": "m10", "from": "app", "to": "mobile-api", "y": 430, "label": "POST order_estimate", "variant": "emphasis" },
    { "id": "m11", "from": "mobile-api", "to": "web-api", "y": 460, "label": "OrderConfirmationService", "variant": "default" },
    { "id": "m12", "from": "web-api", "to": "appconfig", "y": 490, "label": "getRICCode / getTradingLot", "variant": "dashed" },
    { "id": "m13", "from": "web-api", "to": "vbroker", "y": 520, "label": "order_estimate", "variant": "emphasis" },
    { "id": "m14", "from": "vbroker", "to": "web-api", "y": 550, "label": "estimated P&L", "variant": "return" },
    { "id": "m15", "from": "web-api", "to": "mobile-api", "y": 580, "label": "estPL + limits", "variant": "return" },
    { "id": "m16", "from": "mobile-api", "to": "app", "y": 610, "label": "confirmation summary", "variant": "return" },
    { "id": "m17", "from": "app", "to": "user", "y": 640, "label": "Show summary + ask PIN", "variant": "return" },
    { "id": "m18", "from": "user", "to": "app", "y": 670, "label": "Enter trade PIN", "variant": "default" },
    { "id": "m19", "from": "app", "to": "mobile-api", "y": 700, "label": "POST PlaceNewOrder", "variant": "emphasis" },
    { "id": "m20", "from": "mobile-api", "to": "web-api", "y": 730, "label": "NewOrderService", "variant": "default" },
    { "id": "m21", "from": "web-api", "to": "session", "y": 760, "label": "validate + dup check", "variant": "security" },
    { "id": "m22", "from": "session", "to": "web-api", "y": 790, "label": "session valid", "variant": "return" },
    { "id": "m23", "from": "web-api", "to": "vbroker", "y": 820, "label": "placeNewOrder", "variant": "emphasis" },
    { "id": "m24", "from": "vbroker", "to": "web-api", "y": 850, "label": "order numbers", "variant": "return" },
    { "id": "m25", "from": "web-api", "to": "mobile-api", "y": 880, "label": "orderNo + message", "variant": "return" },
    { "id": "m26", "from": "mobile-api", "to": "app", "y": 910, "label": "order created", "variant": "return" },
    { "id": "m27", "from": "app", "to": "user", "y": 940, "label": "Show success screen", "variant": "return" }
  ],
  "activations": [
    { "participant": "app", "from": 175, "to": 950, "type": "frontend" },
    { "participant": "mobile-api", "from": 185, "to": 925, "type": "backend" },
    { "participant": "web-api", "from": 460, "to": 895, "type": "backend" },
    { "participant": "session", "from": 215, "to": 800, "type": "database" },
    { "participant": "appconfig", "from": 485, "to": 525, "type": "cloud" },
    { "participant": "vbroker", "from": 515, "to": 855, "type": "external" }
  ],
  "cards": [
    {
      "dot": "emerald",
      "title": "Session Refresh",
      "items": [
        "Every order action creates a fresh login session",
        "Session ID is stored in SecureStore on device",
        "Backend validates via Redis (AuthConn)"
      ]
    },
    {
      "dot": "violet",
      "title": "Order Confirmation",
      "items": [
        "OrderConfirmationService fetches estimated P&L",
        "AppConfig resolves RIC code and lot size",
        "VBroker returns price limits and margin check"
      ]
    },
    {
      "dot": "rose",
      "title": "Trade PIN Security",
      "items": [
        "Trade PIN is sent in the create request payload",
        "Invalid PIN redirects to trade PIN screen",
        "Duplicate order detection via Redis"
      ]
    },
    {
      "dot": "orange",
      "title": "VBroker Integration",
      "items": [
        "Local market uses DBConn, foreign uses FTMrktConn",
        "Supports Limit, Market, StopLimit, StopMarket, Cash orders",
        "Returns order numbers on success"
      ]
    }
  ]
}