{
  "title": "Scatter-Gather Pattern",
  "description": "Scatter-gather pattern for parallel processing and result aggregation",
  "type": "architecture-pattern",
  "data": {
    "nodes": [
      {
        "id": "service-orchestrator",
        "type": "service",
        "position": {
          "x": 394,
          "y": 350
        },
        "data": {
          "mode": "full",
          "service": {
            "id": "price-orchestrator",
            "name": "Price Orchestrator",
            "owners": [
              "pricing-team"
            ],
            "sends": [
              "PriceRequest"
            ],
            "receives": [
              "GetPriceQuote",
              "PriceResponse"
            ],
            "version": "1.0.0",
            "summary": "Scatters price requests and gathers responses from multiple providers"
          }
        },
        "measured": {
          "width": 262,
          "height": 113
        }
      },
      {
        "id": "command-get-quote",
        "type": "command",
        "position": {
          "x": 12,
          "y": 357.5
        },
        "data": {
          "mode": "full",
          "message": {
            "id": "get-price-quote",
            "name": "GetPriceQuote",
            "version": "1.0.0",
            "summary": "Request for price quotes from multiple providers"
          }
        },
        "measured": {
          "width": 262,
          "height": 98
        }
      },
      {
        "id": "external-provider1",
        "type": "external-system",
        "position": {
          "x": 1158,
          "y": 692
        },
        "data": {
          "mode": "full",
          "externalSystem": {
            "id": "provider-a",
            "name": "Expedia API",
            "version": "2.1.0",
            "summary": "Third-party travel booking API providing flight and hotel prices"
          },
          "editor": {
            "title": "External System",
            "subtitle": "Edit the details of the external system",
            "schema": {
              "type": "object",
              "required": [
                "externalSystem",
                "mode"
              ],
              "properties": {
                "externalSystem": {
                  "type": "object",
                  "required": [
                    "name",
                    "version"
                  ],
                  "properties": {
                    "name": {
                      "type": "string",
                      "title": "Name",
                      "default": "Random value",
                      "description": "The name of the external system"
                    },
                    "version": {
                      "type": "string",
                      "title": "Version",
                      "default": "1.0.0",
                      "description": "The version number (e.g., 1.0.0)",
                      "pattern": "^\\\\d+\\\\.\\\\d+\\\\.\\\\d+(?:-[\\\\w.-]+)?(?:\\\\+[\\\\w.-]+)?$"
                    },
                    "summary": {
                      "type": "string",
                      "title": "Summary",
                      "default": "",
                      "description": "A brief summary of the external system"
                    }
                  }
                }
              }
            }
          }
        },
        "measured": {
          "width": 262,
          "height": 100
        }
      },
      {
        "id": "external-provider2",
        "type": "external-system",
        "position": {
          "x": 1158,
          "y": 512
        },
        "data": {
          "mode": "full",
          "externalSystem": {
            "id": "provider-b",
            "name": "Booking.com API",
            "version": "1.5.0",
            "summary": "Third-party accommodation booking API with competitive pricing"
          },
          "editor": {
            "title": "External System",
            "subtitle": "Edit the details of the external system",
            "schema": {
              "type": "object",
              "required": [
                "externalSystem",
                "mode"
              ],
              "properties": {
                "externalSystem": {
                  "type": "object",
                  "required": [
                    "name",
                    "version"
                  ],
                  "properties": {
                    "name": {
                      "type": "string",
                      "title": "Name",
                      "default": "Random value",
                      "description": "The name of the external system"
                    },
                    "version": {
                      "type": "string",
                      "title": "Version",
                      "default": "1.0.0",
                      "description": "The version number (e.g., 1.0.0)",
                      "pattern": "^\\\\d+\\\\.\\\\d+\\\\.\\\\d+(?:-[\\\\w.-]+)?(?:\\\\+[\\\\w.-]+)?$"
                    },
                    "summary": {
                      "type": "string",
                      "title": "Summary",
                      "default": "",
                      "description": "A brief summary of the external system"
                    }
                  }
                }
              }
            }
          }
        },
        "measured": {
          "width": 262,
          "height": 100
        }
      },
      {
        "id": "external-provider3",
        "type": "external-system",
        "position": {
          "x": 1158,
          "y": 332
        },
        "data": {
          "mode": "full",
          "externalSystem": {
            "id": "provider-c",
            "name": "Kayak API",
            "version": "3.0.0",
            "summary": "Meta-search engine API aggregating prices from multiple travel sites"
          },
          "editor": {
            "title": "External System",
            "subtitle": "Edit the details of the external system",
            "schema": {
              "type": "object",
              "required": [
                "externalSystem",
                "mode"
              ],
              "properties": {
                "externalSystem": {
                  "type": "object",
                  "required": [
                    "name",
                    "version"
                  ],
                  "properties": {
                    "name": {
                      "type": "string",
                      "title": "Name",
                      "default": "Random value",
                      "description": "The name of the external system"
                    },
                    "version": {
                      "type": "string",
                      "title": "Version",
                      "default": "1.0.0",
                      "description": "The version number (e.g., 1.0.0)",
                      "pattern": "^\\\\d+\\\\.\\\\d+\\\\.\\\\d+(?:-[\\\\w.-]+)?(?:\\\\+[\\\\w.-]+)?$"
                    },
                    "summary": {
                      "type": "string",
                      "title": "Summary",
                      "default": "",
                      "description": "A brief summary of the external system"
                    }
                  }
                }
              }
            }
          }
        },
        "measured": {
          "width": 262,
          "height": 100
        }
      },
      {
        "id": "service-aggregator",
        "type": "service",
        "position": {
          "x": 1922,
          "y": 513
        },
        "data": {
          "mode": "full",
          "service": {
            "id": "price-aggregator",
            "name": "Price Aggregator",
            "owners": [
              "pricing-team"
            ],
            "sends": [
              "BestPriceFound"
            ],
            "receives": [
              "PriceResponse"
            ],
            "version": "1.0.0",
            "summary": "Gathers responses and determines best price offer"
          }
        },
        "measured": {
          "width": 262,
          "height": 98
        }
      },
      {
        "id": "event-price-request",
        "type": "event",
        "position": {
          "x": 776,
          "y": 357.5
        },
        "data": {
          "mode": "full",
          "message": {
            "id": "price-request-event",
            "name": "PriceRequest",
            "version": "1.0.0",
            "summary": "Scattered request for price quotes"
          }
        },
        "measured": {
          "width": 262,
          "height": 98
        }
      },
      {
        "id": "event-price-response",
        "type": "event",
        "position": {
          "x": 1540,
          "y": 513
        },
        "data": {
          "mode": "full",
          "message": {
            "id": "price-response-event",
            "name": "PriceResponse",
            "version": "1.0.0",
            "summary": "Individual price response from provider"
          }
        },
        "measured": {
          "width": 262,
          "height": 98
        }
      },
      {
        "id": "event-best-price",
        "type": "event",
        "position": {
          "x": 2304,
          "y": 674.6666666666667
        },
        "data": {
          "mode": "full",
          "message": {
            "id": "best-price-found",
            "name": "BestPriceFound",
            "version": "1.0.0",
            "summary": "Aggregated result with best price offer"
          }
        },
        "measured": {
          "width": 262,
          "height": 98
        }
      },
      {
        "id": "data-correlation-store",
        "type": "data",
        "position": {
          "x": 2304,
          "y": 496.6666666666667
        },
        "data": {
          "mode": "full",
          "data": {
            "id": "correlation-store",
            "name": "Correlation Store",
            "owners": [
              "pricing-team"
            ],
            "version": "1.0.0",
            "summary": "Tracks request correlation IDs and response timeouts",
            "type": "Cache"
          }
        },
        "measured": {
          "width": 262,
          "height": 98
        }
      },
      {
        "id": "note-scatter-gather-instructions",
        "type": "note",
        "position": {
          "x": 383.6666666666667,
          "y": -169.66666666666666
        },
        "data": {
          "text": "🔄 **Scatter-Gather Pattern**\n\nTravel booking price comparison using parallel external API calls:\n\n**📝 Quote Request** → **🎯 Orchestrator** → **📡 Scatter** → **🌐 Expedia, Booking.com, Kayak** → **📊 Gather** → **🏆 Best Price**\n\n**Key Benefits:**\n• **Parallel processing** - Multiple external APIs called simultaneously\n• **Performance** - Faster than sequential API calls\n• **Resilience** - Can work with partial responses from providers\n• **Best results** - Compare prices and choose optimal offer\n• **Timeout handling** - Don't wait forever for slow external APIs\n\n**How it works:**\n1. **Price Orchestrator** receives travel quote request\n2. **Scatter** - Request sent to Expedia, Booking.com, and Kayak APIs\n3. **External providers** process requests in parallel\n4. **Aggregator** collects responses with correlation tracking\n5. **Best price** determined and returned to customer\n\n**💡 Pro tip:** Perfect for travel booking, insurance quotes, loan comparisons, or any multi-vendor scenarios!",
          "color": "green"
        },
        "measured": {
          "width": 420,
          "height": 300
        },
        "width": 420,
        "height": 300,
        "selected": false,
        "dragging": false
      }
    ],
    "edges": [
      {
        "source": "command-get-quote",
        "target": "service-orchestrator",
        "label": "Request Quote",
        "markerEnd": {
          "type": "arrowclosed",
          "color": "#000000"
        },
        "animated": false,
        "type": "default",
        "id": "xy-edge__command-get-quote-service-orchestrator"
      },
      {
        "source": "service-orchestrator",
        "target": "event-price-request",
        "label": "Scatter Request",
        "markerEnd": {
          "type": "arrowclosed",
          "color": "#000000"
        },
        "animated": true,
        "type": "animatedMessage",
        "id": "xy-edge__service-orchestrator-event-price-request"
      },
      {
        "source": "event-price-request",
        "target": "external-provider1",
        "label": "To Expedia",
        "markerEnd": {
          "type": "arrowclosed",
          "color": "#000000"
        },
        "animated": true,
        "type": "animatedMessage",
        "id": "xy-edge__event-price-request-external-provider1"
      },
      {
        "source": "event-price-request",
        "target": "external-provider2",
        "label": "To Booking.com",
        "markerEnd": {
          "type": "arrowclosed",
          "color": "#000000"
        },
        "animated": true,
        "type": "animatedMessage",
        "id": "xy-edge__event-price-request-external-provider2"
      },
      {
        "source": "event-price-request",
        "target": "external-provider3",
        "label": "To Kayak",
        "markerEnd": {
          "type": "arrowclosed",
          "color": "#000000"
        },
        "animated": true,
        "type": "animatedMessage",
        "id": "xy-edge__event-price-request-external-provider3"
      },
      {
        "source": "external-provider1",
        "target": "event-price-response",
        "label": "Expedia Response",
        "markerEnd": {
          "type": "arrowclosed",
          "color": "#000000"
        },
        "animated": true,
        "type": "animatedMessage",
        "id": "xy-edge__external-provider1-event-price-response"
      },
      {
        "source": "external-provider2",
        "target": "event-price-response",
        "label": "Booking Response",
        "markerEnd": {
          "type": "arrowclosed",
          "color": "#000000"
        },
        "animated": true,
        "type": "animatedMessage",
        "id": "xy-edge__external-provider2-event-price-response"
      },
      {
        "source": "external-provider3",
        "target": "event-price-response",
        "label": "Kayak Response",
        "markerEnd": {
          "type": "arrowclosed",
          "color": "#000000"
        },
        "animated": true,
        "type": "animatedMessage",
        "id": "xy-edge__external-provider3-event-price-response"
      },
      {
        "source": "event-price-response",
        "target": "service-aggregator",
        "label": "Gather Responses",
        "markerEnd": {
          "type": "arrowclosed",
          "color": "#000000"
        },
        "animated": true,
        "type": "animatedMessage",
        "id": "xy-edge__event-price-response-service-aggregator"
      },
      {
        "source": "service-aggregator",
        "target": "data-correlation-store",
        "label": "Track Correlation",
        "markerEnd": {
          "type": "arrowclosed",
          "color": "#000000"
        },
        "animated": false,
        "type": "default",
        "id": "xy-edge__service-aggregator-data-correlation-store"
      },
      {
        "source": "service-aggregator",
        "target": "event-best-price",
        "label": "Best Price Result",
        "markerEnd": {
          "type": "arrowclosed",
          "color": "#000000"
        },
        "animated": true,
        "type": "animatedMessage",
        "id": "xy-edge__service-aggregator-event-best-price"
      }
    ],
    "viewport": {
      "x": 219,
      "y": 130,
      "zoom": 0.6
    },
    "creationDate": "2025-08-11T15:38:15.953Z",
    "name": "Scatter-Gather Pattern",
    "version": "1.0",
    "source": "https://app.eventcatalog.dev",
    "appState": {},
    "id": "scatter-gather-pattern"
  },
  "usecase": "Design Parallel Processing Architecture",
  "mermaid": "flowchart TD\n    R[Request] --> O[Orchestrator]\n    O --> E[Expedia]\n    O --> B[Booking.com]\n    O --> K[Kayak]\n    E --> A[Aggregator]\n    B --> A\n    K --> A",
  "tags": ["API Design", "Intermediate"]
}