ChataaS
Multi-tenant chat infrastructure, designed to be embedded into any product.
One-liner
Business-logic agnostic chat infrastructure. It knows about identity, channels, and messages — nothing else.
Why
Multiple products need chat, but each has entirely different business logic. Instead of reimplementing WebSocket connections, message ordering, reconnect catch-up, and read state in each product, extract a shared chat infrastructure layer.
Design Principles
- The chat service only knows identity / channel / message — not business semantics
- Host applications integrate via JWT tokens and opaque mention metadata
- If the chat service starts needing to call the host application’s API, that’s a coupling signal
Architecture
Backend: Elixir + Phoenix + Ash, PostgreSQL schema-per-tenant multi-tenancy.
SDK: TypeScript SDK (@chataas/sdk), wrapping WebSocket connections, channel abstraction, optimistic UI, and reconnect catch-up. The frontend never touches Phoenix Channel protocol.
Key Design Decisions
- DB-backed sequence: Each channel maintains a monotonically increasing seq, incremented inside the same transaction as the message insert — no GenServer
- Single write path: WS channel push and REST POST go through the same Ash action with shared serialization — identical payloads
- Idempotency: Client nonce with unique constraint per channel — disconnection retries never produce duplicate messages
- Read cursor: Per-channel per-user last_read_seq, upsert pattern, sent on foreground only
Status
Work in progress. Phase 0 (Transport) is under development, targeting Phase 3 for a minimally embeddable product.