<mxfile host="drawio-mcp">
  <diagram id="arquitectura-eventos" name="Arquitectura basada en eventos">
    <mxGraphModel adaptiveColors="auto">
      <root>
        <mxCell id="0"/>
        <mxCell id="1" parent="0"/>

        <mxCell id="clients" value="Clientes" style="swimlane;startSize=26;rounded=1;arcSize=6;fillColor=#f5f5f5;strokeColor=#666666;fontColor=#333333;fontStyle=1;html=1;" vertex="1" parent="1">
          <mxGeometry x="40" y="40" width="180" height="190" as="geometry"/>
        </mxCell>
        <mxCell id="web" value="&lt;b&gt;Web SPA&lt;/b&gt;&lt;br&gt;Angular" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#666666;fontColor=#333333;" vertex="1" parent="clients">
          <mxGeometry x="20" y="40" width="140" height="56" as="geometry"/>
        </mxCell>
        <mxCell id="mobile" value="&lt;b&gt;App móvil&lt;/b&gt;&lt;br&gt;React Native" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#666666;fontColor=#333333;" vertex="1" parent="clients">
          <mxGeometry x="20" y="116" width="140" height="56" as="geometry"/>
        </mxCell>

        <mxCell id="gateway" value="&lt;b&gt;API Gateway&lt;/b&gt;&lt;br&gt;auth · rate limit" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontColor=#1a1a1a;" vertex="1" parent="1">
          <mxGeometry x="300" y="100" width="150" height="70" as="geometry"/>
        </mxCell>

        <mxCell id="order" value="&lt;b&gt;Order Service&lt;/b&gt;&lt;br&gt;crea pedidos" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontColor=#1a1a1a;" vertex="1" parent="1">
          <mxGeometry x="540" y="100" width="160" height="70" as="geometry"/>
        </mxCell>
        <mxCell id="orderdb" value="PostgreSQL&lt;br&gt;&lt;i&gt;orders&lt;/i&gt;" style="shape=cylinder3;whiteSpace=wrap;html=1;boundedLbl=1;size=10;fillColor=#e1d5e7;strokeColor=#9673a6;fontColor=#1a1a1a;" vertex="1" parent="1">
          <mxGeometry x="780" y="92" width="110" height="86" as="geometry"/>
        </mxCell>

        <mxCell id="registry" value="&lt;b&gt;Schema Registry&lt;/b&gt;&lt;br&gt;contratos Avro" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;fontColor=#1a1a1a;dashed=1;" vertex="1" parent="1">
          <mxGeometry x="1010" y="100" width="170" height="70" as="geometry"/>
        </mxCell>

        <mxCell id="broker" value="Event Broker · Apache Kafka" style="swimlane;startSize=28;rounded=1;arcSize=4;fillColor=#ffe6cc;strokeColor=#d79b00;fontColor=#1a1a1a;fontStyle=1;fontSize=13;swimlaneFillColor=#fff8f0;html=1;" vertex="1" parent="1">
          <mxGeometry x="40" y="290" width="1140" height="130" as="geometry"/>
        </mxCell>
        <mxCell id="t_orders" value="&lt;b&gt;orders&lt;/b&gt;&lt;br&gt;&lt;font style=&quot;font-size: 10px&quot;&gt;OrderCreated · OrderCancelled&lt;/font&gt;" style="shape=process;whiteSpace=wrap;html=1;size=0.06;fillColor=#ffffff;strokeColor=#d79b00;fontColor=#1a1a1a;fontFamily=Courier New;" vertex="1" parent="broker">
          <mxGeometry x="30" y="48" width="190" height="60" as="geometry"/>
        </mxCell>
        <mxCell id="t_payments" value="&lt;b&gt;payments&lt;/b&gt;&lt;br&gt;&lt;font style=&quot;font-size: 10px&quot;&gt;PaymentCompleted · PaymentFailed&lt;/font&gt;" style="shape=process;whiteSpace=wrap;html=1;size=0.06;fillColor=#ffffff;strokeColor=#d79b00;fontColor=#1a1a1a;fontFamily=Courier New;" vertex="1" parent="broker">
          <mxGeometry x="250" y="48" width="200" height="60" as="geometry"/>
        </mxCell>
        <mxCell id="t_inventory" value="&lt;b&gt;inventory&lt;/b&gt;&lt;br&gt;&lt;font style=&quot;font-size: 10px&quot;&gt;StockReserved · OutOfStock&lt;/font&gt;" style="shape=process;whiteSpace=wrap;html=1;size=0.06;fillColor=#ffffff;strokeColor=#d79b00;fontColor=#1a1a1a;fontFamily=Courier New;" vertex="1" parent="broker">
          <mxGeometry x="480" y="48" width="190" height="60" as="geometry"/>
        </mxCell>
        <mxCell id="t_shipping" value="&lt;b&gt;shipping&lt;/b&gt;&lt;br&gt;&lt;font style=&quot;font-size: 10px&quot;&gt;ShipmentDispatched&lt;/font&gt;" style="shape=process;whiteSpace=wrap;html=1;size=0.06;fillColor=#ffffff;strokeColor=#d79b00;fontColor=#1a1a1a;fontFamily=Courier New;" vertex="1" parent="broker">
          <mxGeometry x="700" y="48" width="190" height="60" as="geometry"/>
        </mxCell>
        <mxCell id="t_dlq" value="&lt;b&gt;*.dlq&lt;/b&gt;&lt;br&gt;&lt;font style=&quot;font-size: 10px&quot;&gt;eventos que agotan reintentos&lt;/font&gt;" style="shape=process;whiteSpace=wrap;html=1;size=0.06;fillColor=#f8cecc;strokeColor=#b85450;fontColor=#1a1a1a;fontFamily=Courier New;dashed=1;" vertex="1" parent="broker">
          <mxGeometry x="920" y="48" width="190" height="60" as="geometry"/>
        </mxCell>

        <mxCell id="kafka_logo" value="" style="shape=image;html=1;imageAspect=0;aspect=fixed;image=https://icons.diagrams.net/assets/apps-and-system-logos/1/Kafka.svg" vertex="1" parent="1">
          <mxGeometry x="1140" y="292" width="15" height="24" as="geometry"/>
        </mxCell>
        <mxCell id="payment" value="&lt;b&gt;Payment Service&lt;/b&gt;&lt;br&gt;cobra el pedido" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontColor=#1a1a1a;" vertex="1" parent="1">
          <mxGeometry x="160" y="520" width="160" height="70" as="geometry"/>
        </mxCell>
        <mxCell id="inventory" value="&lt;b&gt;Inventory Service&lt;/b&gt;&lt;br&gt;reserva stock" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontColor=#1a1a1a;" vertex="1" parent="1">
          <mxGeometry x="410" y="520" width="160" height="70" as="geometry"/>
        </mxCell>
        <mxCell id="shipping" value="&lt;b&gt;Shipping Service&lt;/b&gt;&lt;br&gt;prepara el envío" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontColor=#1a1a1a;" vertex="1" parent="1">
          <mxGeometry x="660" y="520" width="160" height="70" as="geometry"/>
        </mxCell>
        <mxCell id="notification" value="&lt;b&gt;Notification Service&lt;/b&gt;&lt;br&gt;avisa al cliente" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontColor=#1a1a1a;" vertex="1" parent="1">
          <mxGeometry x="910" y="520" width="170" height="70" as="geometry"/>
        </mxCell>

        <mxCell id="paymentdb" value="PostgreSQL&lt;br&gt;&lt;i&gt;payments&lt;/i&gt;" style="shape=cylinder3;whiteSpace=wrap;html=1;boundedLbl=1;size=10;fillColor=#e1d5e7;strokeColor=#9673a6;fontColor=#1a1a1a;" vertex="1" parent="1">
          <mxGeometry x="185" y="660" width="110" height="86" as="geometry"/>
        </mxCell>
        <mxCell id="inventorydb" value="MongoDB&lt;br&gt;&lt;i&gt;stock&lt;/i&gt;" style="shape=cylinder3;whiteSpace=wrap;html=1;boundedLbl=1;size=10;fillColor=#e1d5e7;strokeColor=#9673a6;fontColor=#1a1a1a;" vertex="1" parent="1">
          <mxGeometry x="435" y="660" width="110" height="86" as="geometry"/>
        </mxCell>
        <mxCell id="shippingdb" value="PostgreSQL&lt;br&gt;&lt;i&gt;shipments&lt;/i&gt;" style="shape=cylinder3;whiteSpace=wrap;html=1;boundedLbl=1;size=10;fillColor=#e1d5e7;strokeColor=#9673a6;fontColor=#1a1a1a;" vertex="1" parent="1">
          <mxGeometry x="685" y="660" width="110" height="86" as="geometry"/>
        </mxCell>
        <mxCell id="mail" value="&lt;b&gt;Email / Push&lt;/b&gt;&lt;br&gt;proveedor externo" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;fontColor=#333333;dashed=1;" vertex="1" parent="1">
          <mxGeometry x="920" y="668" width="150" height="70" as="geometry"/>
        </mxCell>

        <mxCell id="legend" value="&lt;div style=&quot;text-align:left&quot;&gt;&lt;b&gt;Leyenda&lt;/b&gt;&lt;br&gt;&lt;font color=&quot;#d79b00&quot;&gt;━━▶&lt;/font&gt; publica evento&lt;br&gt;&lt;font color=&quot;#d79b00&quot;&gt;┅┅▶&lt;/font&gt; consume (suscripción)&lt;br&gt;&lt;font color=&quot;#555555&quot;&gt;━━▶&lt;/font&gt; llamada síncrona / acceso a datos&lt;/div&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#999999;fontColor=#1a1a1a;align=left;spacingLeft=10;" vertex="1" parent="1">
          <mxGeometry x="40" y="800" width="290" height="90" as="geometry"/>
        </mxCell>
        <mxCell id="note" value="Cada servicio es dueño de sus datos: nadie lee la base de datos de otro.&lt;br&gt;Se comunican &lt;b&gt;solo&lt;/b&gt; publicando y consumiendo eventos en el broker." style="text;html=1;whiteSpace=wrap;fontColor=#555555;fontStyle=2;align=left;verticalAlign=middle;" vertex="1" parent="1">
          <mxGeometry x="370" y="810" width="520" height="70" as="geometry"/>
        </mxCell>

        <mxCell id="e_web" value="HTTPS" style="strokeColor=#555555;fontColor=#555555;fontSize=10;labelBackgroundColor=#ffffff;labelPlacement=auto;edgeStyle=orthogonalEdgeStyle;rounded=0;libavoidRouting=1;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" source="web" target="gateway" parent="1">
          
        <mxGeometry relative="1" as="geometry"><Array as="points"><mxPoint x="250" y="108" /><mxPoint x="250" y="135" /></Array></mxGeometry></mxCell>
        <mxCell id="e_mobile" style="strokeColor=#555555;labelBackgroundColor=default;defaultLabelBackgroundColor=page;edgeStyle=orthogonalEdgeStyle;rounded=0;libavoidRouting=1;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" source="mobile" target="gateway" parent="1">
          
        <mxGeometry relative="1" as="geometry"><Array as="points"><mxPoint x="250" y="184" /><mxPoint x="250" y="135" /></Array></mxGeometry></mxCell>
        <mxCell id="e_gw_order" value="POST /orders" style="strokeColor=#555555;fontColor=#555555;fontSize=10;labelBackgroundColor=#ffffff;verticalAlign=bottom;labelPlacement=auto;edgeStyle=orthogonalEdgeStyle;rounded=0;libavoidRouting=1;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" source="gateway" target="order" parent="1">
          <mxGeometry relative="1" as="geometry"/>
        </mxCell>
        <mxCell id="e_order_db" style="strokeColor=#555555;labelBackgroundColor=default;defaultLabelBackgroundColor=page;edgeStyle=orthogonalEdgeStyle;rounded=0;libavoidRouting=1;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" source="order" target="orderdb" parent="1">
          <mxGeometry relative="1" as="geometry"/>
        </mxCell>
        <mxCell id="e_pay_db" style="strokeColor=#555555;labelBackgroundColor=default;defaultLabelBackgroundColor=page;edgeStyle=orthogonalEdgeStyle;rounded=0;libavoidRouting=1;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" source="payment" target="paymentdb" parent="1">
          <mxGeometry relative="1" as="geometry"/>
        </mxCell>
        <mxCell id="e_inv_db" style="strokeColor=#555555;labelBackgroundColor=default;defaultLabelBackgroundColor=page;edgeStyle=orthogonalEdgeStyle;rounded=0;libavoidRouting=1;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" source="inventory" target="inventorydb" parent="1">
          <mxGeometry relative="1" as="geometry"/>
        </mxCell>
        <mxCell id="e_ship_db" style="strokeColor=#555555;labelBackgroundColor=default;defaultLabelBackgroundColor=page;edgeStyle=orthogonalEdgeStyle;rounded=0;libavoidRouting=1;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" source="shipping" target="shippingdb" parent="1">
          <mxGeometry relative="1" as="geometry"/>
        </mxCell>
        <mxCell id="e_notif_mail" style="strokeColor=#555555;labelBackgroundColor=default;defaultLabelBackgroundColor=page;edgeStyle=orthogonalEdgeStyle;rounded=0;libavoidRouting=1;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" source="notification" target="mail" parent="1">
          <mxGeometry relative="1" as="geometry"/>
        </mxCell>
        <mxCell id="e_registry" value="valida esquemas" style="strokeColor=#d6b656;dashed=1;endArrow=none;fontColor=#555555;fontSize=10;labelBackgroundColor=#ffffff;exitX=0.5;exitY=1;entryX=0.925;entryY=0;labelPlacement=auto;edgeStyle=orthogonalEdgeStyle;rounded=0;libavoidRouting=1;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" source="registry" target="broker" parent="1">
          
        <mxGeometry relative="1" as="geometry"><Array as="points"><mxPoint x="1095" y="230" /><mxPoint x="1095" y="230" /></Array></mxGeometry></mxCell>

        <mxCell id="p_order" value="OrderCreated" style="strokeColor=#d79b00;strokeWidth=2;fontColor=#b36b00;fontSize=10;fontStyle=1;labelBackgroundColor=#ffffff;exitX=0.25;exitY=1;entryX=0.5;entryY=0;labelPlacement=auto;edgeStyle=orthogonalEdgeStyle;rounded=0;libavoidRouting=1;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" source="order" target="t_orders" parent="1">
          
        <mxGeometry relative="1" as="geometry"><Array as="points"><mxPoint x="580" y="228" /><mxPoint x="165" y="228" /></Array></mxGeometry></mxCell>
        <mxCell id="p_payment" value="PaymentCompleted" style="strokeColor=#d79b00;strokeWidth=2;fontColor=#b36b00;fontSize=10;fontStyle=1;labelBackgroundColor=#ffffff;exitX=0.75;exitY=0;entryX=0.3;entryY=1;labelPlacement=auto;edgeStyle=orthogonalEdgeStyle;rounded=0;libavoidRouting=1;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" source="payment" target="t_payments" parent="1">
          
        <mxGeometry relative="1" as="geometry"><Array as="points"><mxPoint x="280" y="452" /><mxPoint x="350" y="452" /></Array></mxGeometry></mxCell>
        <mxCell id="p_inventory" value="StockReserved" style="strokeColor=#d79b00;strokeWidth=2;fontColor=#b36b00;fontSize=10;fontStyle=1;labelBackgroundColor=#ffffff;exitX=0.75;exitY=0;entryX=0.4;entryY=1;labelPlacement=auto;edgeStyle=orthogonalEdgeStyle;rounded=0;libavoidRouting=1;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" source="inventory" target="t_inventory" parent="1">
          
        <mxGeometry relative="1" as="geometry"><Array as="points"><mxPoint x="530" y="452" /><mxPoint x="596" y="452" /></Array></mxGeometry></mxCell>
        <mxCell id="p_shipping" value="ShipmentDispatched" style="strokeColor=#d79b00;strokeWidth=2;fontColor=#b36b00;fontSize=10;fontStyle=1;labelBackgroundColor=#ffffff;exitX=0.75;exitY=0;entryX=0.4;entryY=1;labelPlacement=auto;edgeStyle=orthogonalEdgeStyle;rounded=0;libavoidRouting=1;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" source="shipping" target="t_shipping" parent="1">
          
        <mxGeometry relative="1" as="geometry"><Array as="points"><mxPoint x="780" y="459" /><mxPoint x="816" y="459" /></Array></mxGeometry></mxCell>

        <mxCell id="s_orders_pay" style="strokeColor=#d79b00;dashed=1;strokeWidth=1.5;jumpStyle=arc;jumpSize=8;exitX=0.5;exitY=1;entryX=0.25;entryY=0;labelBackgroundColor=default;defaultLabelBackgroundColor=page;edgeStyle=orthogonalEdgeStyle;rounded=0;libavoidRouting=1;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" source="t_orders" target="payment" parent="1">
          
        <mxGeometry relative="1" as="geometry"><Array as="points"><mxPoint x="165" y="459" /><mxPoint x="200" y="459" /></Array></mxGeometry></mxCell>
        <mxCell id="s_orders_inv" style="strokeColor=#d79b00;dashed=1;strokeWidth=1.5;jumpStyle=arc;jumpSize=8;exitX=0.8;exitY=1;entryX=0.15;entryY=0;labelBackgroundColor=default;defaultLabelBackgroundColor=page;edgeStyle=orthogonalEdgeStyle;rounded=0;libavoidRouting=1;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" source="t_orders" target="inventory" parent="1">
          
        <mxGeometry relative="1" as="geometry"><Array as="points"><mxPoint x="222" y="466" /><mxPoint x="434" y="466" /></Array></mxGeometry></mxCell>
        <mxCell id="s_pay_ship" style="strokeColor=#d79b00;dashed=1;strokeWidth=1.5;jumpStyle=arc;jumpSize=8;exitX=0.92;exitY=1;entryX=0.25;entryY=0;labelBackgroundColor=default;defaultLabelBackgroundColor=page;edgeStyle=orthogonalEdgeStyle;rounded=0;libavoidRouting=1;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" source="t_payments" target="shipping" parent="1">
          
        <mxGeometry relative="1" as="geometry"><Array as="points"><mxPoint x="474" y="466" /><mxPoint x="700" y="466" /></Array></mxGeometry></mxCell>
        <mxCell id="s_ship_notif" style="strokeColor=#d79b00;dashed=1;strokeWidth=1.5;jumpStyle=arc;jumpSize=8;exitX=0.75;exitY=1;entryX=0.25;entryY=0;labelBackgroundColor=default;defaultLabelBackgroundColor=page;edgeStyle=orthogonalEdgeStyle;rounded=0;libavoidRouting=1;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" source="t_shipping" target="notification" parent="1">
          
        <mxGeometry relative="1" as="geometry"><Array as="points"><mxPoint x="883" y="459" /><mxPoint x="953" y="459" /></Array></mxGeometry></mxCell>
        <mxCell id="s_pay_order" value="actualiza estado" style="strokeColor=#d79b00;dashed=1;strokeWidth=1.5;fontColor=#b36b00;fontSize=10;labelBackgroundColor=#ffffff;exitX=0.6;exitY=0;entryX=0.6;entryY=1;labelPlacement=auto;edgeStyle=orthogonalEdgeStyle;rounded=0;libavoidRouting=1;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" source="t_payments" target="order" parent="1">
          
        <mxGeometry relative="1" as="geometry"><Array as="points"><mxPoint x="410" y="242" /><mxPoint x="636" y="242" /></Array></mxGeometry></mxCell>
        <mxCell id="s_inv_order" style="strokeColor=#d79b00;dashed=1;strokeWidth=1.5;jumpStyle=arc;jumpSize=8;exitX=0.5;exitY=0;entryX=0.85;entryY=1;labelBackgroundColor=default;defaultLabelBackgroundColor=page;edgeStyle=orthogonalEdgeStyle;rounded=0;libavoidRouting=1;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" source="t_inventory" target="order" parent="1">
          
        <mxGeometry relative="1" as="geometry"><Array as="points"><mxPoint x="615" y="256" /><mxPoint x="676" y="256" /></Array></mxGeometry></mxCell>
        <mxCell id="s_notif_dlq" value="reintentos agotados" style="strokeColor=#b85450;dashed=1;strokeWidth=1.5;fontColor=#b85450;fontSize=10;labelBackgroundColor=#ffffff;exitX=0.75;exitY=0;entryX=0.5;entryY=1;labelPlacement=auto;edgeStyle=orthogonalEdgeStyle;rounded=0;libavoidRouting=1;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" source="notification" target="t_dlq" parent="1">
          
        <mxGeometry relative="1" as="geometry"><Array as="points"><mxPoint x="1038" y="459" /><mxPoint x="1055" y="459" /></Array></mxGeometry></mxCell>
      </root>
    </mxGraphModel>
  </diagram>
</mxfile>
