Multiplayer-first Tetris built for the 42 network β fast Socket.IO backend, sleek Vite/React frontend, and persistent player history backed by MongoDB.
Caution
The latest release of the project is not intended to be submitted at 42.
- Overview
- Feature Highlights
- Architecture
- Getting Started
- Remote Start
- Docker Workflow
- Quality & Tooling
- Release & Versioning
- Further Reading
Red Tetris is a full-stack remake of the classic game with a focus on social play. Players can spin up private lobbies, spectate friends, or speed-run solo βjourneys.β The backend/ service implements the game engine, line-clear logic, and persistence layer, while the frontend/ Vite app handles routing, lobby UX, notifications, and the arena views (grid, specter boards, next queue, and live line-clear feed). MongoDB keeps the latest five results per player so the /history view can recap recent runs.
The project is still evolving, but the gameplay loop, lobby flow, stats storage, and CI checks are already in place.
- Real-time multiplayer powered by Socket.IO rooms, owner hand-offs, and configurable game modes (
classic,fast-paced,invisible-falling-pieces,morph-falling-pieces). - Solo Journey mode auto-starts a private arena with your preferred difficulty and routes you straight to gameplay.
- Lobby management with owner-only controls, mode previews, accessible form labels, and animated background/notification system to keep players informed.
- Spectator view & specter columns so eliminated players can keep watching opponents and follow the line-clear log.
- Persistent player history stored in MongoDB via
backend/statistics.js, surfaced in the/historypage through Redux slices. - Automation-friendly tooling: GitHub Actions CI, Makefile helpers, Docker Compose stack, and release automation with
standard-version.
.
βββ backend/ # Node.js + Socket.IO game server, MongoDB stats, Jest specs
βββ frontend/ # React 18 + Vite + Redux Toolkit + styled-components UI
βββ docker-compose.yml
βββ Makefile # Developer ergonomics (env, deps, lint, tests, docker, etc.)
βββ .github/workflows/ci.yml
- Node.js 20.x (matches the CI matrix in
.github/workflows/ci.yml) - npm 10.x (ships with Node 20)
- Docker Desktop / Docker Engine (optional but recommended for parity)
From the repo root you can install everything with one target:
make deps # runs npm install in frontend/ and backend/Or install manually if you prefer:
cd frontend && npm install
cd ../backend && npm install- Copy the template and let the Makefile inject the host name used by Vite:
make env # creates .env from .env.template when missing - Fill in the Mongo credentials (
MONGO_INITDB_ROOT_USERNAME,MONGO_INITDB_ROOT_PASSWORD,MONGO_INITDB_DATABASE) and tweakVITE_SOCKET_URLfor your setup. - Optional backend knobs:
PORT(defaults to3000)SOCKET_ALLOWED_ORIGINS(comma-separated list) to lock down CORS origins.MONGO_URIif you want to override the host/port combo defined above.
Backend (Node + Socket.IO + MongoDB driver):
cd backend
npm start # listens on :3000Frontend (Vite dev server + React Fast Refresh):
cd frontend
npm run dev # serves on http://localhost:5173Key routes:
/β username onboarding + animated background./menuβ choose Solo journey vs Multiplayer./joinβ enter or create a lobby name (owners pick the mode, others wait)./historyβ last five games pulled from the stats slice/MongoDB./:room/:player_nameβ arena router that decides Solo, Multi, or Spectator view.
MongoDB stores player history in the statistics collection (see backend/statistics.js). When running locally without Docker you can point MONGO_URI at a local or cloud Mongo instance.
Need to host Red Tetris on a remote VM or via SSH? Use the familiar commands with a few tweaks so browsers can reach the dev servers.
-
Provision the machine
git clone https://github.com/okbrandon/red-tetris.git cd red-tetris make env make depsUpdate
.envwith the help of.env.template. -
Start the services
- Run
make docker-buildandmake docker-upon the remote host instead and skip the manual servers.
- Run
Everything can also run in containers (backend, frontend, MongoDB):
make docker-up # builds images and starts the stack
make docker-logs # tails all services
make docker-down # stop containers (volumes preserved)
make docker-reset # stop containers and wipe the MongoDB volumedocker-compose.yml exposes:
frontendonhttp://localhost:8080backendonhttp://localhost:3000
The MongoDB data lives in the mongo-data named volume so you can wipe it independently with make docker-clean-volumes.
CONTRIBUTING.mdβ branching model, commit message style, and PR checklist.CHANGELOG.mdβ history of notable fixes and features.docker-compose.ymlβ environment variables consumed by each service.frontend/README.mdβ the base Vite docs if you are new to the tooling.
Have fun stacking red tetrominoes! Contributions, bug reports, and play-test feedback are very welcome. Dive into an issue, fire up a lobby, and let us know what breaks.