Developer Guide
Bounded context: real-time transport (generic) · Stack: Node.js / Socket.IO · Code-level walkthrough: Socket Service
The socket-service is the bridge between the broker and the browser. It carries per-building telemetry and alerts to connected clients over WebSockets. It is classified as a generic subdomain (see Telemetry Distribution: pure transport, with no domain model and no database.
Deliberately the simplest service in the system: no persistence and no domain model. Everything the service does splits cleanly into two kinds of code, and index.ts says so in its own header comment: “Composition root (imperative shell): build dependencies, wire the pure handlers to them, and start listening. No logic lives here — that’s in core/ and handlers/, which is why this file is excluded from coverage.”
core/relay.ts) is three pure functions — roomForBuilding, roomForDomain, buildingIdFromChannel — string manipulation only, no I/O, no dependencies.auth.ts decodes the mesh-injected x-gateway-claims header on the WebSocket handshake (Istio’s RequestAuthentication already verified it once, upstream — the same trust model every other migrated service uses); handlers/connection.ts, handlers/telemetry.ts, and handlers/notification.ts do the actual work of joining rooms and emitting to sockets.index.ts is the composition root: it registers the auth check as Socket.IO handshake middleware, wires each Redis channel to its handler, and starts listening — nothing else.graph LR
subgraph "Imperative Shell"
IDX["index.ts\ncomposition root"]
AUTH["auth.ts\nauthenticateClaimsHeader"]
CONN["handlers/connection.ts"]
TEL["handlers/telemetry.ts"]
NOTIF["handlers/notification.ts"]
end
subgraph "Functional Core — core/relay.ts"
REL["roomForBuilding · roomForDomain\nbuildingIdFromChannel"]
end
BR1[(broker: notifications)] --> IDX
BR2[(broker: telemetry:filtered:*)] --> IDX
IDX -->|"io.use() — handshake middleware"| AUTH
IDX -->|"io.on('connection')"| CONN
IDX --> TEL
IDX --> NOTIF
TEL --> REL
NOTIF --> REL
CONN --> REL
TEL -->|room-scoped| CL[Connected clients]
NOTIF -->|room-scoped / broadcast| CLtelemetry:filtered:<id>), and emits them to clients — see Communication & Data Flow.For the channel-to-event mapping, the client subscription protocol, and scaling notes, see the Socket Service internals page.