Side project

Realtime Signal Relay

A stateless relay: services POST a signal with recipients and it reaches those users’ sockets. It holds no signing key—socket identity is resolved by asking the issuing service.

Period
2026.02 — 2026.04
Role
Plan · Design · Build · Ship · Improve · solo
Stack
Node.js, Express, Socket.IO 4, MySQL, Docker

Process

  1. Plan

    Apps needed live signals without each running its own socket server.

  2. Design

    Stateless relay; identity checked by asking the issuing service, not by sharing keys.

  3. Build

    Express and Socket.IO, API keys with modes, per-key daily caps.

  4. Ship

    The same pull-based pipeline rebuilds the relay only when it changes; a container health check confirms it came up.

  5. Improve

    Cut a chat server down to a pure relay and turned on key enforcement step by step.

System diagram 7 components · 6 connections Play the flow and trace each connection

Overview

The only send path is one REST endpoint with up to 500 recipients per call. Sockets are receive-only and join a room for their verified user id.

Why I built it

It began as a chat server with rooms, messages, and read receipts—which meant it held other services’ data. Version 3 cut it to a pure relay: the server went from 396 to 148 lines and 21 chat functions were removed.

The old tables were kept, not dropped. Stopping reads and discarding data are different decisions.

System

Express and Socket.IO in one process behind nginx, in Docker with a 30-second health check. The database holds only API keys, services, and connection logs.

See this in the system diagram

Identity

Socket identity uses token introspection: the relay asks the issuing service to verify a short-lived token, with a 3-second timeout and a 60-second cache of up to 5,000 entries. Sharing signing keys would mean breaching the relay lets you forge every service’s users.

API keys have off, warn, and enforce modes, so enforcement rolled out gradually without cutting off clients. Each key has a daily cap that resets at midnight. Development keys are routed to separate rooms.

Stack

Node.js, Express 4, Socket.IO 4, mysql2, winston, Docker.

Notes

Hard parts: API-key validation had been imported but never called; finding and wiring it in came with the mode switch. A legacy call without recipients answered with 200 would look delivered while going nowhere, so it now returns 400.

What held: if the relay goes down, the source data still lives in each service’s REST API. Holding no state, it restarts cheaply.