Room Chat build log - WordPad
✕
C:\ar9av\builds\ROOMCHAT.TXT
  1. Desktop
  2. Build Log
  3. Social & Multiplayer

Build log · Social & Multiplayer

How I built Room Chat

Type a room code and chat live, play Pictionary or Connect Four, no sign-up

Screenshot of Room Chat running in the portfolio
Room Chat, running on the desktop. Open it yourself →

1.Why I built it

I wanted a chat where the only thing you need is a code. Anyone who types the same room code lands in the same live conversation, and an invite link like /app/roomchat?room=CODE drops someone straight in. There are no accounts. Your identity is derived from your IP, so you get the same random name, animal icon and colour every visit.

Once people were in a room together, games were the obvious next step. Each room can run one game at a time: Tic-Tac-Toe, Connect Four, Rock Paper Scissors, or Pictionary for two to eight players, with everyone else spectating and game events posted into the chat.

2.How it works

Identity from a hashed IP

The browser never sends an identity. The /api/roomchat route reads the forwarded IP, hashes it with SHA-256 and keeps 32 hex characters. Different 8 character slices of that hash, read as integers, index into lists of adjectives, animals and colours, which produces names like an adjective, an animal and a number from 0 to 99.

Because it is deterministic, the same IP always gets the same name without storing anything. The hash is passed to Convex mutations so they can rate limit and seat players, but queries strip it before returning messages. The code comments note the obvious limit: an IP is not a person, so a shared network shares a name and a VPN gets a new one.

Messages in Convex

Messages live in a chat_messages table with indexes on room and time and on IP hash and time. Room codes are normalised to uppercase letters and digits, 3 to 16 characters. The list query takes the newest 150 messages in a room and the client subscribes with useQuery, so new messages arrive without polling.

The send mutation trims text to 500 characters and rejects a message if the same IP hash sent one less than 800 ms ago. Media uses Convex file storage: the client asks for a short-lived upload URL, uploads the file, then sends the message with the storage id. The mutation checks the stored file's content type and size (image or video, up to 10 MB) and deletes the file if it fails.

Board games with server-side rules

Each room has at most one room_games row holding the kind, status, two seats, a flat board array where -1 is empty, the turn, scores and the winning line. Tic-Tac-Toe checks the eight fixed lines. Connect Four only checks around the piece just dropped: for each of four directions it walks both ways from that cell counting matching pieces, which is much cheaper than scanning the board.

Rock Paper Scissors needs secrecy, so picks are stored on the server and are never included in what the query returns. The round only resolves once both players have locked in, and the result is published afterwards.

Pictionary over a realtime database

The drawer's strokes are buffered locally and flushed to Convex roughly every 200 ms as flattened x,y arrays scaled to 0 to 1000, so the canvas works at any window size. Guessers redraw from the stored strokes on every update, while the drawer paints locally and only seeds from the server once per round, for example after a reload mid-turn.

The secret word sits in the game row and is only returned by a query that checks the caller's IP hash belongs to the current drawer. Guessing happens in normal chat: the send mutation first asks the game whether the text contains the word, and if it does, the message is swallowed and scored instead of posted. Earlier guessers score more, the drawer gets a point per correct guess, and 80 second rounds end through ctx.scheduler.runAfter, which is ignored if the round already moved on.

Docking and notifications

Minimising the window while in a room parks the chat above the taskbar in the bottom-right corner. It stays subscribed, so messages from others show a toast for six seconds and an unread count. A two-note chime plays through Web Audio, with one module-level AudioContext shared between the window and the dock so the same message never dings twice. Joining a room only records where history ends, so old messages don't replay as notifications.

3.Try it

Type or roll a room code, share the invite link, chat, attach an image or video with the paperclip, and start a game from the game panel.

More from the build log

Room Chat · 3 min readAll 29 builds