A chat app built on WebSockets and a Go server: public rooms, private conversations, typing indicators and online status, plus voice notes recorded right in the browser.
- Year
- 2024
- Role
- design, backend, frontend
- Status
- live
- A public room with two users online
- A private conversation with the typing indicator
- Sign in with just a nickname
Overview
Messages are delivered over WebSockets through a Go hub that fans each message out to the right room or private conversation. Presence, typing indicators and online status ride on the same connection.
Audio messages are recorded in the browser with the MediaRecorder API, sent as a dedicated message action, and played back inline, so the chat works as well for voice notes as for text.
The interface is responsive and keyboard friendly, and the API is small enough to be a reference for anyone wanting to add real-time features to a Go backend.
Features
-
Public rooms
Create a room, join it, leave it, delete it: all over one WebSocket connection.
-
Private chats
One to one conversations created on demand between two users.
-
Real-time
Messages, joins and leaves are pushed instantly to everyone in the room.
-
Typing indicators
See when the other side is writing.
-
Audio messages
Record in the browser and send the clip as a message.
-
Online status
Who is logged in and in which rooms.
Under the hood
- A central chat server keeps the set of connected clients and rooms.
- Each client has a read and a write goroutine; messages are JSON with an action field such as send-message or join-room.
- Rooms broadcast to their members; private rooms are regular rooms limited to two users.
- The server, client, room and message packages each have their own tests.
Built with
- Go
- WebSockets
- JavaScript
- MediaRecorder API
What I learned
- The hub and per-client goroutine pattern keeps the concurrency manageable: no shared state outside the hub.
- Designing the message actions first made the frontend and backend easy to build independently.
- Audio over WebSockets works fine for short clips; anything longer should go over HTTP.