{
 "$schema": "../../lib/umlimator.schema.json",
 "schemaVersion": 2,
 "title": "Interaction overview diagram",
 "root": "buy-book",
 "nodes": [
  {"id": "buy-start", "type": "uml.InitialNode"},
  {"id": "ref-find", "type": "uml.InteractionUse", "label": "Find a book", "opensView": "find-book"},
  {"id": "try-payment", "type": "uml.MergeNode"},
  {"id": "ref-checkout", "type": "uml.InteractionUse", "label": "Check out", "opensView": "buy-checkout"},
  {"id": "payment-ok", "type": "uml.DecisionNode", "label": "Payment accepted?"},
  {"id": "buy-split", "type": "uml.ForkNode"},
  {"id": "ref-receipt", "type": "uml.InteractionUse", "label": "Email the receipt", "opensView": "email-receipt"},
  {"id": "sd-queue", "type": "uml.Interaction", "label": "Queue the order", "opensView": "queue-order"},
  {"id": "ref-reserve", "type": "uml.InteractionUse", "label": "Reserve the stock", "opensView": "reserve-stock"},
  {"id": "receipt-done", "type": "uml.FlowFinalNode"},
  {"id": "both-done", "type": "uml.JoinNode"},
  {"id": "buy-done", "type": "uml.ActivityFinalNode"},
  {"id": "retry-note", "type": "uml.Comment", "label": "A declined card goes back to check out, where the shopper may pick another way to pay"},
  {"id": "lifeline-shopper", "type": "uml.Lifeline", "label": "shopper", "props": {"represents": "Shopper", "stereotypes": ["actor"]}},
  {"id": "lifeline-storefront", "type": "uml.Lifeline", "label": "storefront", "props": {"represents": "Storefront"}},
  {"id": "lifeline-api", "type": "uml.Lifeline", "label": "api", "props": {"represents": "ShopApi"}},
  {"id": "lifeline-payments", "type": "uml.Lifeline", "label": "payments", "props": {"represents": "PaymentProvider"}},
  {"id": "email", "type": "uml.Lifeline", "label": "email", "props": {"represents": "EmailService"}},
  {"id": "lifeline-queue", "type": "uml.Lifeline", "label": "queue", "props": {"represents": "OrderQueue"}},
  {"id": "lifeline-worker", "type": "uml.Lifeline", "label": "worker", "props": {"represents": "OrderWorker"}},
  {"id": "lifeline-stock", "type": "uml.Lifeline", "label": "stock", "props": {"represents": "StockService"}}
 ],
 "edges": [
  {"id": "f-buy-start", "type": "uml.ControlFlow", "from": "buy-start", "to": "ref-find"},
  {"id": "f-found", "type": "uml.ControlFlow", "from": "ref-find", "to": "try-payment", "label": "book chosen"},
  {"id": "f-pay", "type": "uml.ControlFlow", "from": "try-payment", "to": "ref-checkout"},
  {"id": "f-result", "type": "uml.ControlFlow", "from": "ref-checkout", "to": "payment-ok"},
  {"id": "f-accepted", "type": "uml.ControlFlow", "from": "payment-ok", "to": "buy-split", "props": {"guard": "payment accepted"}},
  {"id": "f-declined", "type": "uml.ControlFlow", "from": "payment-ok", "to": "try-payment", "props": {"guard": "else"}, "label": "try again"},
  {"id": "f-to-receipt", "type": "uml.ControlFlow", "from": "buy-split", "to": "ref-receipt"},
  {"id": "f-to-queue", "type": "uml.ControlFlow", "from": "buy-split", "to": "sd-queue"},
  {"id": "f-to-reserve", "type": "uml.ControlFlow", "from": "buy-split", "to": "ref-reserve"},
  {"id": "f-receipt-sent", "type": "uml.ControlFlow", "from": "ref-receipt", "to": "receipt-done"},
  {"id": "f-queued", "type": "uml.ControlFlow", "from": "sd-queue", "to": "both-done"},
  {"id": "f-reserved", "type": "uml.ControlFlow", "from": "ref-reserve", "to": "both-done"},
  {"id": "f-buy-done", "type": "uml.ControlFlow", "from": "both-done", "to": "buy-done"},
  {"id": "retry-note-link", "type": "uml.CommentLink", "from": "retry-note", "to": "payment-ok"}
 ],
 "views": [
  {"id": "buy-book", "diagram": "uml.interaction-overview", "title": "Buying a book", "parent": null, "direction": "down", "nodeIds": ["buy-start", "ref-find", "try-payment", "ref-checkout", "payment-ok", "buy-split", "ref-receipt", "ref-reserve", "sd-queue", "receipt-done", "both-done", "buy-done", "retry-note"]},
  {"id": "buy-book-right", "diagram": "uml.interaction-overview", "title": "Buying a book, laid out right", "parent": "buy-book", "nodeIds": ["buy-start", "ref-find", "try-payment", "ref-checkout", "payment-ok", "buy-split", "ref-receipt", "ref-reserve", "sd-queue", "receipt-done", "both-done", "buy-done", "retry-note"]},
  {"id": "find-book", "diagram": "uml.sequence", "title": "Find a book", "parent": "buy-book", "nodeIds": ["lifeline-shopper", "lifeline-storefront", "lifeline-api"],
   "edges": [
    {"id": "find-1", "type": "uml.Message", "from": "lifeline-shopper", "to": "lifeline-storefront", "label": "search(title)", "props": {"sort": "call"}},
    {"id": "find-2", "type": "uml.Message", "from": "lifeline-storefront", "to": "lifeline-api", "label": "findBooks(title)", "props": {"sort": "call"}},
    {"id": "find-3", "type": "uml.Message", "from": "lifeline-api", "to": "lifeline-storefront", "label": "books", "props": {"sort": "reply", "replyTo": "find-2"}},
    {"id": "find-4", "type": "uml.Message", "from": "lifeline-storefront", "to": "lifeline-shopper", "label": "results page", "props": {"sort": "reply", "replyTo": "find-1"}}
   ] },
  {"id": "buy-checkout", "diagram": "uml.sequence", "title": "Check out", "parent": "buy-book", "nodeIds": ["lifeline-storefront", "lifeline-api", "lifeline-payments"],
   "edges": [
    {"id": "pay-1", "type": "uml.Message", "from": "lifeline-storefront", "to": "lifeline-api", "label": "place(order)", "props": {"sort": "call"}},
    {"id": "pay-2", "type": "uml.Message", "from": "lifeline-api", "to": "lifeline-payments", "label": "charge(total)", "props": {"sort": "call"}},
    {"id": "pay-3", "type": "uml.Message", "from": "lifeline-payments", "to": "lifeline-api", "label": "accepted or declined", "props": {"sort": "reply", "replyTo": "pay-2"}},
    {"id": "pay-4", "type": "uml.Message", "from": "lifeline-api", "to": "lifeline-storefront", "label": "result", "props": {"sort": "reply", "replyTo": "pay-1"}}
   ] },
  {"id": "reserve-stock", "diagram": "uml.sequence", "title": "Reserve the stock", "parent": "buy-book", "nodeIds": ["lifeline-api", "lifeline-stock"],
   "edges": [
    {"id": "stock-1", "type": "uml.Message", "from": "lifeline-api", "to": "lifeline-stock", "label": "reserve(order lines)", "props": {"sort": "call"}},
    {"id": "stock-2", "type": "uml.Message", "from": "lifeline-stock", "to": "lifeline-api", "label": "reserved", "props": {"sort": "reply", "replyTo": "stock-1"}}
   ] },
  {"id": "email-receipt", "diagram": "uml.sequence", "title": "Email the receipt", "parent": "buy-book", "nodeIds": ["lifeline-api", "email", "lifeline-shopper"],
   "edges": [
    {"id": "mail-1", "type": "uml.Message", "from": "lifeline-api", "to": "email", "label": "send(receipt)", "props": {"sort": "async"}},
    {"id": "mail-2", "type": "uml.Message", "from": "email", "to": "lifeline-shopper", "label": "receipt email", "props": {"sort": "async"}}
   ] },
  {"id": "queue-order", "diagram": "uml.sequence", "title": "Queue the order", "parent": "buy-book", "nodeIds": ["lifeline-api", "lifeline-queue", "lifeline-worker"],
   "edges": [
    {"id": "queue-1", "type": "uml.Message", "from": "lifeline-api", "to": "lifeline-queue", "label": "enqueue(order)", "props": {"sort": "call"}},
    {"id": "queue-2", "type": "uml.Message", "from": "lifeline-queue", "to": "lifeline-api", "label": "queued", "props": {"sort": "reply", "replyTo": "queue-1"}},
    {"id": "queue-3", "type": "uml.Message", "from": "lifeline-queue", "to": "lifeline-worker", "label": "orderPlaced", "props": {"sort": "async"}}
   ] }
 ]
}
