<mxfile host="app.diagrams.net" agent="architecture-diagram" version="24.0.0">
  <diagram name="Data Model — Message, Attempt, Receipt, Consent" id="12-data-model">
    <mxGraphModel dx="1400" dy="900" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1700" pageHeight="940" math="0" shadow="0">
      <root>
        <mxCell id="0" />
        <mxCell id="1" parent="0" />
        <mxCell id="n.tenant" value="&lt;b&gt;tenant&lt;/b&gt;&lt;br&gt;&lt;font style=&quot;font-size:10px;color:#5b6b7d&quot;&gt;tenant_id  PK&lt;br&gt;plan&lt;br&gt;entitlement_mps&lt;br&gt;residency_region&lt;br&gt;credit_balance&lt;/font&gt;" style="rounded=1;arcSize=4;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontColor=#1e3a1e;fontSize=12;fontFamily=Segoe UI;verticalAlign=top;align=left;spacingLeft=12;spacingTop=7;spacingRight=10;" vertex="1" parent="1">
          <mxGeometry x="40" y="80" width="340" height="120" as="geometry" />
        </mxCell>
        <mxCell id="n.sender" value="&lt;b&gt;sender_identity&lt;/b&gt;&lt;br&gt;&lt;font style=&quot;font-size:10px;color:#5b6b7d&quot;&gt;sender_id  PK&lt;br&gt;tenant_id  FK -&gt; tenant&lt;br&gt;type  long|short|alpha|toll&lt;br&gt;registrations  jsonb&lt;br&gt;throughput_ceiling&lt;/font&gt;" style="rounded=1;arcSize=4;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontColor=#1e3a1e;fontSize=12;fontFamily=Segoe UI;verticalAlign=top;align=left;spacingLeft=12;spacingTop=7;spacingRight=10;" vertex="1" parent="1">
          <mxGeometry x="470" y="80" width="340" height="120" as="geometry" />
        </mxCell>
        <mxCell id="n.route" value="&lt;b&gt;route&lt;/b&gt;&lt;br&gt;&lt;font style=&quot;font-size:10px;color:#5b6b7d&quot;&gt;route_id  PK&lt;br&gt;channel&lt;br&gt;jurisdiction&lt;br&gt;provider&lt;br&gt;price_per_segment&lt;br&gt;window_mps&lt;/font&gt;" style="rounded=1;arcSize=4;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontColor=#1e3a1e;fontSize=12;fontFamily=Segoe UI;verticalAlign=top;align=left;spacingLeft=12;spacingTop=7;spacingRight=10;" vertex="1" parent="1">
          <mxGeometry x="890" y="80" width="340" height="130" as="geometry" />
        </mxCell>
        <mxCell id="n.consent" value="&lt;b&gt;consent_event&lt;/b&gt;&lt;br&gt;&lt;font style=&quot;font-size:10px;color:#5b6b7d&quot;&gt;consent_event_id  PK&lt;br&gt;tenant_id  FK -&gt; tenant&lt;br&gt;destination_hash&lt;br&gt;sender_id  FK -&gt; sender&lt;br&gt;state  granted|withdrawn&lt;br&gt;evidence&lt;br&gt;recorded_at&lt;/font&gt;" style="rounded=1;arcSize=4;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontColor=#1e3a1e;fontSize=12;fontFamily=Segoe UI;verticalAlign=top;align=left;spacingLeft=12;spacingTop=7;spacingRight=10;" vertex="1" parent="1">
          <mxGeometry x="40" y="340" width="340" height="150" as="geometry" />
        </mxCell>
        <mxCell id="n.message" value="&lt;b&gt;message&lt;/b&gt;&lt;br&gt;&lt;font style=&quot;font-size:10px;color:#5b6b7d&quot;&gt;message_id  PK&lt;br&gt;tenant_id  FK -&gt; tenant&lt;br&gt;client_reference  UQ per tenant&lt;br&gt;destination_hash&lt;br&gt;sender_id  FK -&gt; sender&lt;br&gt;channel_requested&lt;br&gt;traffic_class&lt;br&gt;ttl_expires_at&lt;br&gt;segments_quoted&lt;br&gt;accepted_at&lt;/font&gt;" style="rounded=1;arcSize=4;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontColor=#1e3a1e;fontSize=12;fontFamily=Segoe UI;verticalAlign=top;align=left;spacingLeft=12;spacingTop=7;spacingRight=10;" vertex="1" parent="1">
          <mxGeometry x="470" y="340" width="340" height="190" as="geometry" />
        </mxCell>
        <mxCell id="n.attempt" value="&lt;b&gt;attempt&lt;/b&gt;&lt;br&gt;&lt;font style=&quot;font-size:10px;color:#5b6b7d&quot;&gt;attempt_id  PK&lt;br&gt;message_id  FK -&gt; message&lt;br&gt;seq&lt;br&gt;route_id  FK -&gt; route&lt;br&gt;provider_reference&lt;br&gt;submit_outcome&lt;br&gt;segments_charged&lt;br&gt;submitted_at&lt;/font&gt;" style="rounded=1;arcSize=4;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontColor=#1e3a1e;fontSize=12;fontFamily=Segoe UI;verticalAlign=top;align=left;spacingLeft=12;spacingTop=7;spacingRight=10;" vertex="1" parent="1">
          <mxGeometry x="890" y="340" width="340" height="160" as="geometry" />
        </mxCell>
        <mxCell id="n.body" value="&lt;b&gt;message_body&lt;/b&gt;&lt;br&gt;&lt;font style=&quot;font-size:10px;color:#5b6b7d&quot;&gt;body_id  PK&lt;br&gt;message_id  FK -&gt; message&lt;br&gt;object_uri&lt;br&gt;kms_key&lt;br&gt;purge_after&lt;/font&gt;" style="rounded=1;arcSize=4;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontColor=#1e3a1e;fontSize=12;fontFamily=Segoe UI;verticalAlign=top;align=left;spacingLeft=12;spacingTop=7;spacingRight=10;" vertex="1" parent="1">
          <mxGeometry x="40" y="600" width="340" height="120" as="geometry" />
        </mxCell>
        <mxCell id="n.receipt" value="&lt;b&gt;receipt&lt;/b&gt;&lt;br&gt;&lt;font style=&quot;font-size:10px;color:#5b6b7d&quot;&gt;receipt_id  PK&lt;br&gt;attempt_id  FK -&gt; attempt  NULLable&lt;br&gt;provider_reference&lt;br&gt;carrier_status&lt;br&gt;carrier_reason&lt;br&gt;carrier_timestamp&lt;br&gt;received_at&lt;/font&gt;" style="rounded=1;arcSize=4;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontColor=#1e3a1e;fontSize=12;fontFamily=Segoe UI;verticalAlign=top;align=left;spacingLeft=12;spacingTop=7;spacingRight=10;" vertex="1" parent="1">
          <mxGeometry x="890" y="600" width="340" height="150" as="geometry" />
        </mxCell>
        <mxCell id="n.state" value="&lt;b&gt;message_state&lt;/b&gt;&lt;br&gt;&lt;font style=&quot;font-size:10px;color:#5b6b7d&quot;&gt;message_id  PK  FK -&gt; message&lt;br&gt;state  accepted..unknown&lt;br&gt;terminal_at&lt;br&gt;derived_from_attempt&lt;br&gt;// projection, not authority&lt;/font&gt;" style="rounded=1;arcSize=4;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontColor=#1e3a1e;fontSize=12;fontFamily=Segoe UI;verticalAlign=top;align=left;spacingLeft=12;spacingTop=7;spacingRight=10;" vertex="1" parent="1">
          <mxGeometry x="470" y="600" width="340" height="120" as="geometry" />
        </mxCell>
        <mxCell id="n.inbound" value="&lt;b&gt;inbound_message&lt;/b&gt;&lt;br&gt;&lt;font style=&quot;font-size:10px;color:#5b6b7d&quot;&gt;inbound_id  PK&lt;br&gt;route_id  FK -&gt; route&lt;br&gt;provider_reference  UQ per route&lt;br&gt;sender_id  FK -&gt; sender&lt;br&gt;keyword_actioned&lt;br&gt;received_at&lt;/font&gt;" style="rounded=1;arcSize=4;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontColor=#1e3a1e;fontSize=12;fontFamily=Segoe UI;verticalAlign=top;align=left;spacingLeft=12;spacingTop=7;spacingRight=10;" vertex="1" parent="1">
          <mxGeometry x="1320" y="340" width="340" height="130" as="geometry" />
        </mxCell>
        <mxCell id="n.usage" value="&lt;b&gt;rated_usage_event&lt;/b&gt;&lt;br&gt;&lt;font style=&quot;font-size:10px;color:#5b6b7d&quot;&gt;usage_event_id  PK&lt;br&gt;attempt_id  FK -&gt; attempt&lt;br&gt;tenant_id  FK -&gt; tenant&lt;br&gt;route_id  FK -&gt; route&lt;br&gt;segments&lt;br&gt;amount&lt;/font&gt;" style="rounded=1;arcSize=4;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontColor=#1e3a1e;fontSize=12;fontFamily=Segoe UI;verticalAlign=top;align=left;spacingLeft=12;spacingTop=7;spacingRight=10;" vertex="1" parent="1">
          <mxGeometry x="1320" y="600" width="340" height="130" as="geometry" />
        </mxCell>
        <mxCell id="_r1" value="1 : N" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;endArrow=ERmany;endFill=0;startArrow=ERone;startFill=0;strokeWidth=1.4;strokeColor=#5a6570;fontSize=10;fontColor=#42536a;labelBackgroundColor=#ffffff;fontFamily=Segoe UI;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="n.tenant" target="n.consent">
          <mxGeometry relative="1" as="geometry" />
        </mxCell>
        <mxCell id="_r2" value="at submit" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;endArrow=ERmany;endFill=0;startArrow=ERone;startFill=0;strokeWidth=1.4;strokeColor=#8c8c8c;dashed=1;fontSize=10;fontColor=#42536a;labelBackgroundColor=#ffffff;fontFamily=Segoe UI;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;" edge="1" parent="1" source="n.consent" target="n.message">
          <mxGeometry relative="1" as="geometry" />
        </mxCell>
        <mxCell id="_r3" value="1 : N" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;endArrow=ERmany;endFill=0;startArrow=ERone;startFill=0;strokeWidth=1.4;strokeColor=#5a6570;fontSize=10;fontColor=#42536a;labelBackgroundColor=#ffffff;fontFamily=Segoe UI;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="n.sender" target="n.message">
          <mxGeometry relative="1" as="geometry" />
        </mxCell>
        <mxCell id="_r4" value="1 : N" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;endArrow=ERmany;endFill=0;startArrow=ERone;startFill=0;strokeWidth=1.4;strokeColor=#5a6570;fontSize=10;fontColor=#42536a;labelBackgroundColor=#ffffff;fontFamily=Segoe UI;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;" edge="1" parent="1" source="n.message" target="n.attempt">
          <mxGeometry relative="1" as="geometry" />
        </mxCell>
        <mxCell id="_r5" value="1 : N" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;endArrow=ERmany;endFill=0;startArrow=ERone;startFill=0;strokeWidth=1.4;strokeColor=#5a6570;fontSize=10;fontColor=#42536a;labelBackgroundColor=#ffffff;fontFamily=Segoe UI;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="n.route" target="n.attempt">
          <mxGeometry relative="1" as="geometry" />
        </mxCell>
        <mxCell id="_r6" value="1 : N" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;endArrow=ERmany;endFill=0;startArrow=ERone;startFill=0;strokeWidth=1.4;strokeColor=#5a6570;fontSize=10;fontColor=#42536a;labelBackgroundColor=#ffffff;fontFamily=Segoe UI;exitX=0.75;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="n.route" target="n.inbound">
          <mxGeometry relative="1" as="geometry" />
        </mxCell>
        <mxCell id="_r7" value="1 : 1" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;endArrow=ERmany;endFill=0;startArrow=ERone;startFill=0;strokeWidth=1.4;strokeColor=#5a6570;fontSize=10;fontColor=#42536a;labelBackgroundColor=#ffffff;fontFamily=Segoe UI;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="n.message" target="n.state">
          <mxGeometry relative="1" as="geometry" />
        </mxCell>
        <mxCell id="_r8" value="1 : 0..1" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;endArrow=ERmany;endFill=0;startArrow=ERone;startFill=0;strokeWidth=1.4;strokeColor=#8c8c8c;dashed=1;fontSize=10;fontColor=#42536a;labelBackgroundColor=#ffffff;fontFamily=Segoe UI;exitX=0.25;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="n.message" target="n.body">
          <mxGeometry relative="1" as="geometry" />
        </mxCell>
        <mxCell id="_r9" value="1 : N" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;endArrow=ERmany;endFill=0;startArrow=ERone;startFill=0;strokeWidth=1.4;strokeColor=#8c8c8c;dashed=1;fontSize=10;fontColor=#42536a;labelBackgroundColor=#ffffff;fontFamily=Segoe UI;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="n.attempt" target="n.receipt">
          <mxGeometry relative="1" as="geometry" />
        </mxCell>
        <mxCell id="_r10" value="1 : 1" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;endArrow=ERmany;endFill=0;startArrow=ERone;startFill=0;strokeWidth=1.4;strokeColor=#5a6570;fontSize=10;fontColor=#42536a;labelBackgroundColor=#ffffff;fontFamily=Segoe UI;exitX=0.75;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="n.attempt" target="n.usage">
          <mxGeometry relative="1" as="geometry" />
        </mxCell>
        <mxCell id="title" value="Data Model — Message, Attempt, Receipt, Consent" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;fontSize=20;fontStyle=1;fontColor=#16202c;fontFamily=Segoe UI;" vertex="1" parent="1">
          <mxGeometry x="40" y="20" width="1610" height="30" as="geometry" />
        </mxCell>
        <mxCell id="rule" value="" style="line;strokeWidth=1;html=1;strokeColor=#c9d3de;" vertex="1" parent="1">
          <mxGeometry x="40" y="50" width="1610" height="10" as="geometry" />
        </mxCell>
        <mxCell id="note" value="receipt.attempt_id is nullable on purpose: an uncorrelatable receipt is kept, not dropped." style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;fontSize=10;fontColor=#8a97a5;fontFamily=Segoe UI;" vertex="1" parent="1">
          <mxGeometry x="40" y="870" width="1610" height="20" as="geometry" />
        </mxCell>
        <mxCell id="foot-rule" value="" style="line;strokeWidth=1;html=1;strokeColor=#e3e9ef;" vertex="1" parent="1">
          <mxGeometry x="40" y="890" width="1610" height="10" as="geometry" />
        </mxCell>
        <mxCell id="foot" value="v 1.0   ·   owner Integration Platform Architecture" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;fontSize=9;fontColor=#9aa7b4;fontFamily=Segoe UI;" vertex="1" parent="1">
          <mxGeometry x="40" y="910" width="1610" height="10" as="geometry" />
        </mxCell>
      </root>
    </mxGraphModel>
  </diagram>
</mxfile>
