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
[](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_11COMPONENT STACK (14)
- Mobile ClientSTATEFULSends messages over one open connection
- Recipient ClientSTATEFULReceives pushed messages and pages history
- API gatewaySTATELESSKeeps the sender connection, checks the JWT
- Policy decision point (PDP)STATELESSAllows only members of the chat
- Secrets managerSTATEFULHolds TLS certificates for the recipient gateway
- Resource serverSTATELESSChat service: numbers and saves
- Snowflake IDSTATEFULTime-ordered ids; each copy has its own worker id
- System of recordSTATEFULHash-partitioned by chat id, read by cursor
- Message relaySTATEFULForwards new store rows to the topic; may repeat
- Publish-subscribeSTATEFULOne topic per chat
- API gatewaySTATELESSKeeps the recipient connection and pushes
- Dead-letter queue (DLQ)STATEFULParks undelivered messages
- Time-series database (TSDB)STATEFULStores save latency and dead-letter depth
- AlertingSTATEFULPages on-call when latency or dead letters grow
REQUEST & DATA FLOW (14)
- Mobile Client → API gateway (Sends with JWT)[WebSocket]
- API gateway → Policy decision point (PDP) (Asks policy (mTLS))[HTTPS]
- API gateway → Resource server (Forwards (mTLS))[HTTP/2]
- Resource server → Snowflake ID (Gets message id)[HTTPS]
- Resource server → System of record (Saves message)[HTTPS]
- System of record → Message relay (Reads new rows)[HTTPS]
- Message relay → Publish-subscribe (Publishes message)[TCP]
- Publish-subscribe → API gateway (Delivers to subscriber)[TCP]
- Publish-subscribe → Dead-letter queue (DLQ) (Parks failed deliveries)[TCP]
- API gateway → Recipient Client (Pushes message)[WebSocket]
- Secrets manager → API gateway (Supplies credentials)[HTTPS]
- Time-series database (TSDB) → System of record (Scrapes latency)[HTTPS]
- Time-series database (TSDB) → Alerting (Feeds alerts)[HTTP]
- Time-series database (TSDB) → Dead-letter queue (DLQ) (Scrapes dead letters)[HTTPS]