Skip to main content
ARCHOS 525 BLUEPRINT · /d/dgm_chat-system

Chat system (WebSocket gateways, publish-subscribe fan-out, partitioned message store)

15 COMPONENTS · 14 FLOWS · UPDATED 2026-11-21
GITHUB README / PR PREVIEW CARD
[![Chat system (WebSocket gateways, publish-subscribe fan-out, partitioned message store) — ArchOS Architecture](https://archos.sageideas.dev/d/dgm_chat-system/opengraph-image)](https://archos.sageideas.dev/d/dgm_chat-system)

*Interactive architecture diagram powered by [ArchOS Studio](https://archos.sageideas.dev/d/dgm_chat-system)*
NOTION / DOCS / CONFLUENCE EMBED
<iframe src="https://archos.sageideas.dev/embed/dgm_chat-system" width="100%" height="580" style="border:1px solid rgba(240,236,225,0.14);border-radius:6px;" loading="lazy" title="Chat system (WebSocket gateways, publish-subscribe fan-out, partitioned message store) — Interactive in ArchOS"></iframe>
PORTABLE MERMAID SPEC (GITHUB / NOTION / RFC)
flowchart LR
  sender_0[("Mobile Client")]
  recipient_1[("Recipient Client")]
  gw_2["API gateway"]
  pdp_3["Policy decision point (PDP)"]
  secrets_4[("Secrets manager")]
  svc_5["Resource server"]
  idgen_6[("Snowflake ID")]
  store_7[("System of record")]
  relay_8[("Message relay")]
  pubsub_9[("Publish-subscribe")]
  gw2_10["API gateway"]
  dlq_11[("Dead-letter queue (DLQ)")]
  tsdb_12[("Time-series database (TSDB)")]
  alerting_13[("Alerting")]
  capacity_14["Capacity Estimate"]
  sender_0 -->|"1. Sends with JWT · WebSocket"| gw_2
  gw_2 -->|"2a. Asks policy (mTLS) · HTTPS"| pdp_3
  gw_2 -->|"2b. Forwards (mTLS) · HTTP/2"| svc_5
  svc_5 -->|"3a. Gets message id · HTTPS"| idgen_6
  svc_5 -->|"3b. Saves message · HTTPS"| store_7
  store_7 -->|"4. Reads new rows · HTTPS"| relay_8
  relay_8 -.->|"5. Publishes message · TCP"| pubsub_9
  pubsub_9 -.->|"6a. Delivers to subscriber · TCP"| gw2_10
  pubsub_9 -.->|"6b. Parks failed deliveries · TCP"| dlq_11
  gw2_10 -.->|"7. Pushes message · WebSocket"| recipient_1
  secrets_4 -->|"Supplies credentials · HTTPS"| gw2_10
  tsdb_12 -->|"Scrapes latency · HTTPS"| store_7
  tsdb_12 -->|"Feeds alerts · HTTP"| alerting_13
  tsdb_12 -->|"Scrapes dead letters · HTTPS"| dlq_11

COMPONENT STACK (14)

  • Mobile ClientSTATEFUL
    Sends messages over one open connection
  • Recipient ClientSTATEFUL
    Receives pushed messages and pages history
  • API gatewaySTATELESS
    Keeps the sender connection, checks the JWT
  • Policy decision point (PDP)STATELESS
    Allows only members of the chat
  • Secrets managerSTATEFUL
    Holds TLS certificates for the recipient gateway
  • Resource serverSTATELESS
    Chat service: numbers and saves
  • Snowflake IDSTATEFUL
    Time-ordered ids; each copy has its own worker id
  • System of recordSTATEFUL
    Hash-partitioned by chat id, read by cursor
  • Message relaySTATEFUL
    Forwards new store rows to the topic; may repeat
  • Publish-subscribeSTATEFUL
    One topic per chat
  • API gatewaySTATELESS
    Keeps the recipient connection and pushes
  • Dead-letter queue (DLQ)STATEFUL
    Parks undelivered messages
  • Time-series database (TSDB)STATEFUL
    Stores save latency and dead-letter depth
  • AlertingSTATEFUL
    Pages on-call when latency or dead letters grow

REQUEST & DATA FLOW (14)

  1. Mobile Client → API gateway (Sends with JWT)[WebSocket]
  2. API gateway → Policy decision point (PDP) (Asks policy (mTLS))[HTTPS]
  3. API gateway → Resource server (Forwards (mTLS))[HTTP/2]
  4. Resource server → Snowflake ID (Gets message id)[HTTPS]
  5. Resource server → System of record (Saves message)[HTTPS]
  6. System of record → Message relay (Reads new rows)[HTTPS]
  7. Message relay → Publish-subscribe (Publishes message)[TCP]
  8. Publish-subscribe → API gateway (Delivers to subscriber)[TCP]
  9. Publish-subscribe → Dead-letter queue (DLQ) (Parks failed deliveries)[TCP]
  10. API gateway → Recipient Client (Pushes message)[WebSocket]
  11. Secrets manager → API gateway (Supplies credentials)[HTTPS]
  12. Time-series database (TSDB) → System of record (Scrapes latency)[HTTPS]
  13. Time-series database (TSDB) → Alerting (Feeds alerts)[HTTP]
  14. Time-series database (TSDB) → Dead-letter queue (DLQ) (Scrapes dead letters)[HTTPS]
Configure NGINX / Postgres / K8s →60-Sec L4–L7 Diagnostic →