Roomy is a real-time media synchronization service that lets you watch videos or even listen to music together with your friends, no matter where they are. This is the backend API for Roomy.
You'll need bun and docker installed on your system.
git clone https://github.com/kaicsm/roomy-backend
cd roomy-backend
bun installcp .env.example .envand edit .env with your own values of each variable.
docker compose up -dbun db:migratebun devRoomy uses websockets and Redis for high-performance real-time communication. To create a new room, the client makes a POST request to the /rooms endpoint and receives its ID along with its metadata. With the room ID and metadata, the client can connect to it via websocket using the /rooms/:roomId/ws endpoint. The websocket messages that the server receives and sends are defined in the ws.types.ts file, highlighting the most important ones:
-
SYNC_REQUEST: Makes a request for the current state of the room. Server responds with aSYNC_FULL_STATEmessage, containing the current room state. This message should be sent whenever a new user enters a room. -
UPDATE_PLAYBACK: Updates the room state with new information. Server sends aPLAYBACK_UPDATEDmessage to all users, containing the updated room state. Sent when the user takes an action, such as play/pause/seek, etc. -
HEARTBEAT: Keeps the room alive in the server's memory. Rooms are automatically deleted after 1 minute of inactivity; therefore, the client must send this message (preferably every 30 seconds) to prevent the room from being cleared.
Bunas the JS runtimeElysia JSas the web frameworkPostgreSQLas the database service (managed with Drizzle ORM)Redisas the caching serviceDockerfor containerization