{
  "schema_version": 1,
  "diagram_type": "sequence",
  "meta": {
    "title": "iSpeed.my — Schedule Order Flow",
    "subtitle": "Regular Savings Plan (RSP) order creation with frequency scheduling",
    "output": "ispeed-schedule-order.html",
    "viewBox": [1080, 960],
    "column_fit": "spread",
    "animation": "trace",
    "quality_profile": "showcase",
    "views": [
      { "id": "summary", "label": "Schedule Summary", "focus": ["user", "app", "mobile-api", "web-api"], "note": "Schedule order summary and next execution date" },
      { "id": "submit", "label": "Schedule Submit", "focus": ["app", "web-api", "session", "vbroker"], "note": "Trade PIN and VBroker schedule submission" },
      { "id": "full-flow", "label": "Full Flow", "focus": ["user", "app", "mobile-api", "web-api", "session", "appconfig", "vbroker"], "note": "Complete schedule order lifecycle" }
    ]
  },
  "participants": [
    { "id": "user", "type": "external", "label": "User", "sublabel": "Investor" },
    { "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 values" },
    { "id": "vbroker", "type": "external", "label": "VBroker API", "sublabel": "Back office" }
  ],
  "segments": [
    { "from": 155, "to": 265, "label": "Session Setup" },
    { "from": 275, "to": 445, "label": "Schedule Summary" },
    { "from": 455, "to": 625, "label": "Trade PIN + Submit" },
    { "from": 635, "to": 865, "label": "Result" }
  ],
  "messages": [
    { "id": "s1", "from": "user", "to": "app", "y": 160, "label": "Open RSP order form", "variant": "default" },
    { "id": "s2", "from": "app", "to": "mobile-api", "y": 190, "label": "POST /mobile-exs/member (login)", "variant": "emphasis" },
    { "id": "s3", "from": "mobile-api", "to": "session", "y": 220, "label": "validate session", "variant": "security" },
    { "id": "s4", "from": "mobile-api", "to": "app", "y": 250, "label": "session ID", "variant": "return" },
    { "id": "s5", "from": "app", "to": "user", "y": 280, "label": "Render RSP form", "variant": "return" },
    { "id": "s6", "from": "user", "to": "app", "y": 310, "label": "Fill schedule + confirm", "variant": "default" },
    { "id": "s7", "from": "app", "to": "mobile-api", "y": 340, "label": "POST schedule confirmation", "variant": "emphasis" },
    { "id": "s8", "from": "mobile-api", "to": "web-api", "y": 370, "label": "ScheduleOrderConfirmationService", "variant": "default" },
    { "id": "s9", "from": "web-api", "to": "appconfig", "y": 400, "label": "get VB API URL", "variant": "dashed" },
    { "id": "s10", "from": "web-api", "to": "vbroker", "y": 430, "label": "confirmScheduleOrder", "variant": "emphasis" },
    { "id": "s11", "from": "vbroker", "to": "web-api", "y": 460, "label": "nextScheduleDate", "variant": "return" },
    { "id": "s12", "from": "web-api", "to": "mobile-api", "y": 490, "label": "scheduleDate", "variant": "return" },
    { "id": "s13", "from": "mobile-api", "to": "app", "y": 520, "label": "summary with next date", "variant": "return" },
    { "id": "s14", "from": "app", "to": "user", "y": 550, "label": "Show summary + ask PIN", "variant": "return" },
    { "id": "s15", "from": "user", "to": "app", "y": 580, "label": "Enter trade PIN", "variant": "default" },
    { "id": "s16", "from": "app", "to": "mobile-api", "y": 610, "label": "POST new schedule order", "variant": "emphasis" },
    { "id": "s17", "from": "mobile-api", "to": "web-api", "y": 640, "label": "NewScheduleOrderService", "variant": "default" },
    { "id": "s18", "from": "web-api", "to": "session", "y": 670, "label": "validate session", "variant": "security" },
    { "id": "s19", "from": "session", "to": "web-api", "y": 700, "label": "session valid", "variant": "return" },
    { "id": "s20", "from": "web-api", "to": "vbroker", "y": 730, "label": "placeNewScheduleOrder", "variant": "emphasis" },
    { "id": "s21", "from": "vbroker", "to": "web-api", "y": 760, "label": "order number", "variant": "return" },
    { "id": "s22", "from": "web-api", "to": "mobile-api", "y": 790, "label": "orderNumber + message", "variant": "return" },
    { "id": "s23", "from": "mobile-api", "to": "app", "y": 820, "label": "schedule created", "variant": "return" },
    { "id": "s24", "from": "app", "to": "user", "y": 850, "label": "Show RSP success screen", "variant": "return" }
  ],
  "activations": [
    { "participant": "app", "from": 155, "to": 860, "type": "frontend" },
    { "participant": "mobile-api", "from": 185, "to": 835, "type": "backend" },
    { "participant": "web-api", "from": 370, "to": 805, "type": "backend" },
    { "participant": "session", "from": 215, "to": 710, "type": "database" },
    { "participant": "appconfig", "from": 395, "to": 435, "type": "cloud" },
    { "participant": "vbroker", "from": 425, "to": 770, "type": "external" }
  ],
  "cards": [
    {
      "dot": "emerald",
      "title": "Schedule Summary",
      "items": [
        "ScheduleOrderConfirmationService calculates next execution date",
        "Frequency options: Weekly (Mon-Fri) or Monthly (1-28)",
        "User sees summary before entering trade PIN"
      ]
    },
    {
      "dot": "violet",
      "title": "RSP Order Types",
      "items": [
        "All schedule orders are cash/amount type",
        "Order type is hardcoded to 'cash'",
        "Settlement currency supports MYR and foreign currencies"
      ]
    },
    {
      "dot": "rose",
      "title": "Frequency Validation",
      "items": [
        "Weekly: frequency=0, day 1-5 (Mon-Fri)",
        "Monthly: frequency=1, day 1-28",
        "Start date is required for schedule creation"
      ]
    },
    {
      "dot": "orange",
      "title": "Schedule Management",
      "items": [
        "RetrieveScheduleOrderService lists ongoing schedules",
        "AmendScheduleOrderService modifies frequency/day/amount",
        "CancelScheduleOrderService stops a schedule"
      ]
    }
  ]
}