Relay
(Real-time Community Chat)Project goal:
Build a self-owned space for public and private communities, with channel conversations, threaded replies and live presence that recover when connections drop.
Tech decisions:
React, Vite and Zustand power a virtualized, optimistic chat UI. A Node.js WebSocket validates shared Zod events, Drizzle and PostgreSQL persist messages, and Redis Pub/Sub distributes live events.
Results:
- 100 virtual users in local load test
- 1,800 messages persisted in local test
- 0 failed sends in local test
- React
- TypeScript
- Node.js
- WebSockets
- PostgreSQL
- Redis
Relay
real-time community chat
// Persist first; retries reuse the original clientId.
result = await sendMessage(db, {
userId: conn.user.id, roomId: ev.roomId,
clientId: ev.clientId, body: ev.body,
parentId: ev.parentId ?? null,
});
const event: BusEvent = {
type: "message.new", message: result.message,
committedAt: Date.now(),
};
const topic = topics.room(ev.roomId);
const published = await publishWithRetry(this.relay.bus, topic, event);