Skip to content

Ghaith00/rummy-online

Repository files navigation

Rami Game Online

Real-time multi-player rummy built with Next.js (App Router) and a Node/Socket.IO realtime server backed by Redis.


Prerequisites

  • Node.js 20+
  • npm 10+
  • A local Redis instance (or hosted URI)

Local Development

Install dependencies and start both the web client (Next.js) and realtime server together:

npm install
npm run dev

By 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_ORIGIN must include the host & port for the realtime service.
Set both RT_ORIGIN and NEXT_PUBLIC_RT_ORIGIN if you change the realtime endpoint.


Production Build (without Docker)

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.


Docker

Two dedicated Dockerfiles are provided:

  • Dockerfile.web – builds the Next.js web application
  • Dockerfile.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 stack

Default 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

Useful Scripts

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

Project Structure Highlights

  • src/app – Next.js App Router pages & components
  • src/lib – shared utilities, card logic, and socket helpers
  • server/src – realtime server (Express + Socket.IO) written in TypeScript
  • docker-compose.yaml – production orchestration for web, realtime, and Redis

Troubleshooting

  • Web client still connects to the wrong socket port: ensure NEXT_PUBLIC_RT_ORIGIN is 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:rt to regenerate server/dist after updating TypeScript sources.
  • Redis connectivity issues: verify REDIS_URL points to a reachable Redis instance and that the container/service is running.

License

See LICENSE (if provided) or consult the project owner.

Releases

No releases published

Packages

No packages published