Building Aegis: an anonymous chat app with no database
How Aegis's real-time rooms work with nothing but Socket.IO, an in-memory Map, and a display name.
Aegis is deliberately small. There's no sign-up, no password, and no database — you pick a display name, join or create a room, and start talking. Here's the shape of it.
No accounts, just a name
The entire "auth" flow is a single socket event:
@SubscribeMessage('setUsername')
handleSetUsername(client: Socket, username: string) {
this.service.registerUser(client.id, username);
}That's it. The identity is tied to the socket connection, not a stored credential. When the
client reconnects — say, after the server restarts — it just re-emits setUsername and
picks up where it left off.
State lives in a Map, not a database
Rooms, messages, and typing indicators are all plain Map and Set instances inside a
single ChatService. That means:
- Zero infrastructure to run besides the NestJS process itself.
- Everything resets on restart — which is fine for ephemeral, throwaway conversations.
- Adding persistence later is a contained change: one service, one clear seam.
Why keep it this way
Aegis was never meant to be a durable chat platform — it's meant to be the kind of thing you can open, use for two minutes, and close. Keeping it stateless (aside from the in-memory room data) is what let it become a "free tool" bolted onto a much larger site without dragging in a database migration or an auth system that would have to interoperate with everything else here.