Designs by DuhartAll work
Rank
14 of 28
Tier
Tier B 69 of 120

8 — Realtime Gateway Trio

Rank 14 of 28 · Tier B · app/gateways/ Stack: Go, Kafka, Cassandra, WebSocket, Docker Compose Scope: 48,582 lines of Go across three gateways plus a test harness

Why this ranks here. Three independently-built WebSocket gateways, each with its own session, presence, dispatch, and event-bus layers over Kafka and Cassandra. It is genuine realtime-fan-out engineering at volume. It ranks below Tier S because it is largely superseded by GlobalChatService — but the layer decomposition is the reusable interview material.


The three gateways

GatewayLinesFiles
billboard_gateway19,92837
dating_gateway17,11833
mating_gateway7,62821
testing (harness)3,90812

The layer decomposition (repeated in each)

Each gateway is built from the same named layers — which is the point worth making in an interview, because it is a deliberate architecture repeated three times, not three ad-hoc services:

  connection.go     ── raw WebSocket lifecycle
  connClient.go     ── per-connection client state
  session.go        ── session identity and resumption
  sessClient.go     ── session-scoped client handle
  presence.go       ── online/offline, TTL
  dispatch.go       ── inbound message routing
  eventbus.go       ── internal pub/sub
  kafka.go          ── cross-service event transport
  cassandra.go      ── durable state
  dao.go            ── data access
  payload.go        ── wire format
  errorLord.go      ── centralized error taxonomy
  adapter.go        ── external service adapters
  handlers/         ── chat, profile, photo, upload

Separating connection from session from presence is the correct decomposition and is exactly what a "design a chat system" interview wants to hear: a connection is a TCP/WS object that dies constantly; a session survives reconnects; presence is a derived, TTL'd view over sessions.

Local operability

app/gateways/docker-compose.yml + Makefile bring the whole trio up locally against Kafka and Cassandra. Being able to run your distributed system on a laptop is an underrated interview answer.

Interview surface this opens