<mxfile host="app.diagrams.net" type="device">
  <diagram name="banco-dados" id="banco-dados">
    <mxGraphModel dx="1200" dy="800" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1600" pageHeight="1200" math="0" shadow="0">
      <root>
        <mxCell id="0"/>
        <mxCell id="1" parent="0"/>
        <mxCell id="n2" value="Busca-Busca — Esquema do banco (PostgreSQL + PostGIS)" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=18;fontColor=#222222;fontStyle=1;" vertex="1" parent="1"><mxGeometry x="40" y="20" width="900" height="24" as="geometry"/></mxCell>
        <mxCell id="n3" value="PK = chave primária · FK = chave estrangeira · 1..* = um para muitos" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#888888;" vertex="1" parent="1"><mxGeometry x="40" y="46" width="1000" height="24" as="geometry"/></mxCell>
        <mxCell id="n4" value="&lt;b&gt;Padrão de auditoria&lt;/b&gt; (todas as tabelas,&lt;br/&gt;exceto referência)&lt;br/&gt;&lt;hr size='1'/&gt;criado_em · atualizado_em&lt;br/&gt;excluido_em (exclusão lógica / soft delete)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;fontSize=11;align=left;verticalAlign=middle;" vertex="1" parent="1"><mxGeometry x="40" y="780" width="240" height="96" as="geometry"/></mxCell>
        <mxCell id="n5" value="&lt;b&gt;municipio&lt;/b&gt;&lt;br/&gt;&lt;hr size='1'/&gt;PK id&lt;br/&gt;codigo_ibge · UNIQUE&lt;br/&gt;nome · uf" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=11;align=left;verticalAlign=middle;" vertex="1" parent="1"><mxGeometry x="40" y="100" width="210" height="88" as="geometry"/></mxCell>
        <mxCell id="n6" value="&lt;b&gt;tipo_imovel&lt;/b&gt;&lt;br/&gt;&lt;hr size='1'/&gt;PK id&lt;br/&gt;nome · UNIQUE" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=11;align=left;verticalAlign=middle;" vertex="1" parent="1"><mxGeometry x="40" y="240" width="210" height="70" as="geometry"/></mxCell>
        <mxCell id="n7" value="&lt;b&gt;modalidade_venda&lt;/b&gt;&lt;br/&gt;&lt;hr size='1'/&gt;PK id&lt;br/&gt;nome · UNIQUE" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=11;align=left;verticalAlign=middle;" vertex="1" parent="1"><mxGeometry x="40" y="350" width="210" height="70" as="geometry"/></mxCell>
        <mxCell id="n8" value="&lt;b&gt;imovel_foto&lt;/b&gt;&lt;br/&gt;&lt;hr size='1'/&gt;PK id&lt;br/&gt;FK imovel_id&lt;br/&gt;url · ordem&lt;br/&gt;UNIQUE(imovel_id, ordem)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=11;align=left;verticalAlign=middle;" vertex="1" parent="1"><mxGeometry x="310" y="100" width="230" height="106" as="geometry"/></mxCell>
        <mxCell id="n9" value="&lt;b&gt;historico_preco&lt;/b&gt;&lt;br/&gt;&lt;hr size='1'/&gt;PK id&lt;br/&gt;FK imovel_id&lt;br/&gt;valor · desconto_pct&lt;br/&gt;status (status_imovel)&lt;br/&gt;capturado_em" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=11;align=left;verticalAlign=middle;" vertex="1" parent="1"><mxGeometry x="310" y="260" width="230" height="124" as="geometry"/></mxCell>
        <mxCell id="n10" value="&lt;b&gt;analise_custo&lt;/b&gt;&lt;br/&gt;&lt;hr size='1'/&gt;PK id&lt;br/&gt;FK imovel_id (1..1)&lt;br/&gt;itbi · custas · registro&lt;br/&gt;dividas · reforma_estimada&lt;br/&gt;custo_total · desconto_real_pct&lt;br/&gt;score · status_confianca&lt;br/&gt;calculado_em" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=11;align=left;verticalAlign=middle;" vertex="1" parent="1"><mxGeometry x="310" y="430" width="230" height="160" as="geometry"/></mxCell>
        <mxCell id="n11" value="&lt;b&gt;coleta_bruta&lt;/b&gt;&lt;br/&gt;&lt;hr size='1'/&gt;PK id&lt;br/&gt;fonte (csv/detalhe) · uf · codigo&lt;br/&gt;payload_bruto (bytea · zstd)&lt;br/&gt;compressao · payload_hash · tamanho_bytes&lt;br/&gt;coletado_em · retenção ~90d" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#999999;fontSize=11;align=left;verticalAlign=middle;" vertex="1" parent="1"><mxGeometry x="310" y="640" width="250" height="124" as="geometry"/></mxCell>
        <mxCell id="n12" value="&lt;b&gt;imovel&lt;/b&gt;&lt;br/&gt;&lt;hr size='1'/&gt;PK id&lt;br/&gt;codigo · UNIQUE por fonte&lt;br/&gt;FK tipo_imovel_id · FK modalidade_venda_id&lt;br/&gt;FK municipio_id · bairro · endereco&lt;br/&gt;localizacao (geography Point 4326)&lt;br/&gt;area_total · area_privativa · area_terreno&lt;br/&gt;quartos&lt;br/&gt;valor_avaliacao · valor_minimo · desconto_pct&lt;br/&gt;status (status_imovel)&lt;br/&gt;criado_em · atualizado_em" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=11;align=left;verticalAlign=middle;" vertex="1" parent="1"><mxGeometry x="620" y="100" width="330" height="214" as="geometry"/></mxCell>
        <mxCell id="n13" value="&lt;b&gt;imovel_detalhe (1..1)&lt;/b&gt;&lt;br/&gt;&lt;hr size='1'/&gt;PK id · FK imovel_id · UNIQUE&lt;br/&gt;valor_primeiro/segundo_leilao&lt;br/&gt;data_primeiro/segundo_leilao&lt;br/&gt;leiloeiro · edital · numero_item&lt;br/&gt;matricula · comarca · oficio&lt;br/&gt;inscricao_imobiliaria · cep&lt;br/&gt;endereco_completo&lt;br/&gt;aceita_fgts · aceita_financiamento&lt;br/&gt;despesas_condominio/tributos_comprador&lt;br/&gt;situacao_ocupacao · descricao_completa&lt;br/&gt;edital_url · matricula_url&lt;br/&gt;enriquecido_em · status_enriquecimento" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#999999;fontSize=11;align=left;verticalAlign=middle;" vertex="1" parent="1"><mxGeometry x="620" y="470" width="340" height="250" as="geometry"/></mxCell>
        <mxCell id="n14" value="&lt;b&gt;usuario&lt;/b&gt;&lt;br/&gt;&lt;hr size='1'/&gt;PK id&lt;br/&gt;email · UNIQUE&lt;br/&gt;nome · avatar_url&lt;br/&gt;provedor · provedor_id (OIDC)&lt;br/&gt;UNIQUE(provedor, provedor_id)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=11;align=left;verticalAlign=middle;" vertex="1" parent="1"><mxGeometry x="1010" y="100" width="220" height="124" as="geometry"/></mxCell>
        <mxCell id="n15" value="&lt;b&gt;favorito&lt;/b&gt;&lt;br/&gt;&lt;hr size='1'/&gt;PK id&lt;br/&gt;FK usuario_id&lt;br/&gt;FK imovel_id&lt;br/&gt;criado_em&lt;br/&gt;UNIQUE(usuario_id, imovel_id)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=11;align=left;verticalAlign=middle;" vertex="1" parent="1"><mxGeometry x="1010" y="280" width="220" height="124" as="geometry"/></mxCell>
        <mxCell id="n16" value="&lt;b&gt;alerta&lt;/b&gt;&lt;br/&gt;&lt;hr size='1'/&gt;PK id&lt;br/&gt;FK usuario_id&lt;br/&gt;filtro (jsonb)&lt;br/&gt;canal (canal_alerta) · ativo&lt;br/&gt;criado_em" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=11;align=left;verticalAlign=middle;" vertex="1" parent="1"><mxGeometry x="1010" y="470" width="220" height="124" as="geometry"/></mxCell>
        <mxCell id="n17" value="&lt;b&gt;token_atualizacao&lt;/b&gt;&lt;br/&gt;&lt;hr size='1'/&gt;PK id&lt;br/&gt;FK usuario_id&lt;br/&gt;token_hash · UNIQUE&lt;br/&gt;familia_id (uuid)&lt;br/&gt;expira_em · revogado_em&lt;br/&gt;substituido_por (FK self)&lt;br/&gt;user_agent · ip" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#999999;fontSize=11;align=left;verticalAlign=middle;" vertex="1" parent="1"><mxGeometry x="1010" y="630" width="220" height="160" as="geometry"/></mxCell>
        <mxCell id="n18" value="FK" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;strokeColor=#555555;startArrow=none;endArrow=block;" edge="1" parent="1" source="n5" target="n12"><mxGeometry relative="1" as="geometry"/></mxCell>
        <mxCell id="n19" value="FK" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;strokeColor=#555555;startArrow=none;endArrow=block;" edge="1" parent="1" source="n6" target="n12"><mxGeometry relative="1" as="geometry"/></mxCell>
        <mxCell id="n20" value="FK" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;strokeColor=#555555;startArrow=none;endArrow=block;" edge="1" parent="1" source="n7" target="n12"><mxGeometry relative="1" as="geometry"/></mxCell>
        <mxCell id="n21" value="1..*" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;strokeColor=#555555;startArrow=none;endArrow=none;" edge="1" parent="1" source="n12" target="n8"><mxGeometry relative="1" as="geometry"/></mxCell>
        <mxCell id="n22" value="1..*" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;strokeColor=#555555;startArrow=none;endArrow=none;" edge="1" parent="1" source="n12" target="n9"><mxGeometry relative="1" as="geometry"/></mxCell>
        <mxCell id="n23" value="1..1" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;strokeColor=#555555;startArrow=none;endArrow=none;" edge="1" parent="1" source="n12" target="n10"><mxGeometry relative="1" as="geometry"/></mxCell>
        <mxCell id="n24" value="1..1" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;strokeColor=#555555;startArrow=none;endArrow=none;" edge="1" parent="1" source="n12" target="n13"><mxGeometry relative="1" as="geometry"/></mxCell>
        <mxCell id="n25" value="por codigo" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;strokeColor=#555555;startArrow=none;endArrow=none;dashed=1;" edge="1" parent="1" source="n11" target="n12"><mxGeometry relative="1" as="geometry"/></mxCell>
        <mxCell id="n26" value="1..*" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;strokeColor=#555555;startArrow=none;endArrow=none;" edge="1" parent="1" source="n14" target="n15"><mxGeometry relative="1" as="geometry"/></mxCell>
        <mxCell id="n27" value="1..*" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;strokeColor=#555555;startArrow=none;endArrow=none;" edge="1" parent="1" source="n12" target="n15"><mxGeometry relative="1" as="geometry"/></mxCell>
        <mxCell id="n28" value="1..*" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;strokeColor=#555555;startArrow=none;endArrow=none;" edge="1" parent="1" source="n14" target="n16"><mxGeometry relative="1" as="geometry"/></mxCell>
        <mxCell id="n29" value="1..*" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;strokeColor=#555555;startArrow=none;endArrow=none;" edge="1" parent="1" source="n14" target="n17"><mxGeometry relative="1" as="geometry"/></mxCell>
      </root>
    </mxGraphModel>
  </diagram>
</mxfile>
