← things I ship
PERSONALCreator · personalRUNS LOCALLY

TalkWise.

A real-time chat app that scales across server instances: Socket.IO with a Redis adapter, presence and read receipts, plus Sage, an AI assistant.

TECH USED
ReactNestJSSocket.IORedisPostgreSQLpgvector
TalkWise chat screen with a conversation list on the left and a message thread with read receipts
01Live chatConversation list and a one-to-one thread with read receipts
TalkWise AI provider settings with provider and model selectors and a masked API key field
02AI providerBring-your-own-key settings: provider, model and masked key
demo
Space or K play and pause, M mute, F fullscreen, arrow keys seek 5 seconds
0:00 / 0:00
the full path

From problem to what's next.

In the order it actually happened. Use the route to jump around.

01THE PROBLEM

Chat only feels instant if messages, receipts and presence reach the other person right away, and that gets hard once connections are spread across server instances.

02THE SOLUTION

A NestJS Socket.IO gateway with the Redis adapter fans messages out across instances, and per-user rooms reach every device. Presence lives in Redis, messages persist in PostgreSQL. Sage adds an AI assistant.

WHAT I BUILT
  1. 01Built the distributed chat core: Redis adapter and presence, per-user rooms for multi-device, delivery and read receipts, catch-up after reconnect.
  2. 02Implemented auth with RS256 access tokens and rotating refresh cookies, with reuse detection that revokes every session.
  3. 03Added Sage: a per-turn classifier, RAG over pgvector message embeddings, a tool-calling loop, and bring-your-own-key providers with encrypted keys.
  4. 04Set up Docker Compose with nginx, Prometheus and Grafana monitoring, and k6 load tests.
03HOW IT'S BUILT

The system, end to end.

CHAT PATH
  1. STEP 01Senderbrowser, JWT handshake
  2. STEP 02Socket.IO gatewayNestJS instance
  3. STEP 03Redis pub/subadapter fans out across instances
  4. STEP 04User roomevery device of the receiver
  5. STEP 05Receiverdelivery ack back to sender
AI PATH
  1. STEP 01Messagesent over Socket.IO
  2. STEP 02BullMQ workerembeds messages · 768-dim vectors
  3. STEP 03Sage turnclassifier picks deep think · tools · RAG
  4. STEP 04LLM providerOpenAI, Anthropic or Ollama · user key
01Redis adapterThe Socket.IO Redis adapter publishes each emit through Redis, so a message sent on one server instance reaches sockets connected to another.
02Presence in RedisEach user has a Redis set of live sockets (SADD/SCARD), so any instance can tell who is online. Presence keys are cleared on boot.
03Token reuse detectionRefresh tokens rotate and are stored HMAC-hashed. Replaying a revoked token is treated as theft: every session is revoked via tokenInvalidBefore.
04Bring-your-own-keyUser API keys are AES-256-GCM encrypted with a per-user HKDF-derived key, so one leaked key cannot decrypt another user's key.
04WHAT BROKE,
AND THE FIX

FIX →Added the Socket.IO Redis adapter and per-user rooms, so one emit reaches every device of the receiver on any instance.

FIX →Presence keys are wiped on application bootstrap, before the server accepts connections.

FIX →When the receiver is online the message is marked delivered at once and the sender is acked, flipping the tick.

FIX →Fixed the namespace handling so the same-origin proxy carries WebSocket traffic.
05WHERE IT IS NOW
  1. IDEA
  2. BUILDING
  3. LIVE

Runs end to end with docker compose, with 12 server unit tests in CI.