flowchart LR
  WEB["Minha Conta · Backoffice<br/>Next.js + shadcn/ui"]:::management
  API["Management API<br/>Cadastro · regras · eventos"]:::management
  DB[("PostgreSQL<br/>Identidade · projeções · eventos")]:::storage
  KB["Kill Bill<br/>Assinaturas · faturas · recorrência · retries"]:::billing
  KDB[("Banco do Kill Bill")]:::storage
  BRIDGE["Bridge Java + Connector TypeScript<br/>Integração de pagamento"]:::management
  MP["Mercado Pago<br/>Tokenização e processamento<br/>Sem Subscription / Preapproval"]:::gateway
  WORKER["Fila + Worker<br/>Provisionamento · conciliação"]:::management
  subgraph EXISTING["Existentes · fora do escopo"]
    OSM["OSM NxTV Provider API<br/>Usuários · planos · ativação / suspensão"]:::existing
    APP["Aplicativos NxPlay<br/>Login · catálogo · reprodução"]:::existing
    OSM -->|Aplica acesso| APP
  end
  WEB --> API
  API --> DB
  API -->|Assinaturas e faturas| KB
  API -->|Jobs de acesso| WORKER
  KB --> KDB
  KB -->|Comando de cobrança| BRIDGE
  BRIDGE -->|Pagamento CIT / MIT| MP
  MP -.->|Webhooks · resultado| BRIDGE
  WORKER -->|API existente| OSM
  classDef management fill:#241e54,stroke:#8174bb,color:#ffffff,stroke-width:1.5px
  classDef billing fill:#063a63,stroke:#58a4e5,color:#ffffff,stroke-width:2px
  classDef gateway fill:#3a2b19,stroke:#f9a727,color:#fff1d8,stroke-width:1.5px
  classDef existing fill:#25282c,stroke:#a0a4aa,color:#eceef0,stroke-width:1.5px
  classDef storage fill:#202236,stroke:#70758e,color:#dce0ee,stroke-width:1px
  style EXISTING fill:#1c1e22,stroke:#7d8288,stroke-dasharray:5 5,color:#c8ccd2