Real-time multi-player rummy built with Next.js (App Router) and a Node/Socket.IO realtime server backed by Redis.
- Node.js 20+
- npm 10+
- A local Redis instance (or hosted URI)
Install dependencies and start both the web client (Next.js) and realtime server together:
npm install
npm run devBy default the web app runs on http://localhost:3000 and the realtime server on http://localhost:4000.
Environment variables you may want to set in a .env file:
| Variable | Used By | Default | Description |
|---|---|---|---|
REDIS_URL |
Realtime server & web | redis://localhost:6379 |
Redis connection string |
RT_PORT |
Realtime server | 4000 |
Port the realtime server listens on |
RT_ORIGIN |
Realtime server | http://localhost:4000 |
Public URL the server reports to web clients |
NEXT_PUBLIC_RT_ORIGIN |
Web client | http://localhost:4000 |
Socket.IO endpoint the browser connects to |
NEXT_PUBLIC_RT_ORIGINmust include the host & port for the realtime service.
Set bothRT_ORIGINandNEXT_PUBLIC_RT_ORIGINif you change the realtime endpoint.
npm run build # Next.js production build
npm run build:rt # Compile the realtime server (server/dist)
npm run start # Serve Next.js on RT_PORT (default 3000)
npm run start:rt # Serve realtime server on RT_PORT (default 4000)Ensure server/dist is rebuilt whenever backend TypeScript changes.
Two dedicated Dockerfiles are provided:
Dockerfile.web– builds the Next.js web applicationDockerfile.server– builds the realtime server
The supplied docker-compose.yaml launches all services (web, realtime, redis) in production mode:
docker compose build # builds web & realtime images
docker compose up -d # starts the stackDefault port mappings:
| Service | Host Port | Container Port |
|---|---|---|
| Web (Next.js) | 3000 | 3000 |
| Realtime (Socket.IO) | 4004 | 4004 |
| Redis | 6379 | 6379 |
The compose file forwards NEXT_PUBLIC_RT_ORIGIN / RT_ORIGIN to the web container and sets RT_PORT=4004 for the realtime service. Adjust these values in docker-compose.yaml if you deploy under different hosts or ports.
To stop and clean up:
docker compose down| Command | Description |
|---|---|
npm run dev |
Run Next.js (Turbopack) and realtime server (tsx watch) together |
npm run build |
Production build for the web app |
npm run build:rt |
Compile the realtime server to server/dist |
npm run start |
Start the Next.js production server |
npm run start:rt |
Start the compiled realtime server |
src/app– Next.js App Router pages & componentssrc/lib– shared utilities, card logic, and socket helpersserver/src– realtime server (Express + Socket.IO) written in TypeScriptdocker-compose.yaml– production orchestration for web, realtime, and Redis
- Web client still connects to the wrong socket port: ensure
NEXT_PUBLIC_RT_ORIGINis set in your environment (or compose file) and rebuild the web container. - Realtime server can’t find shared modules at runtime: run
npm run build:rtto regenerateserver/distafter updating TypeScript sources. - Redis connectivity issues: verify
REDIS_URLpoints to a reachable Redis instance and that the container/service is running.
See LICENSE (if provided) or consult the project owner.