A competitive online multiplayer Snake game built with Rust (backend + WebAssembly frontend).
- Backend: Rust server with WebSocket connections, gRPC for inter-server communication, and Raft consensus
- Frontend: React + WebAssembly (compiled from Rust)
- Database: PostgreSQL with automatic migrations
- Infrastructure: Docker containers, designed for AWS Fargate deployment
# Start database and server with auto-reload on code changes
./dev.sh
# In another terminal, build and start the client
cd client
wasm-pack build --target web --out-dir pkg
cd web
npm install
npm start# Start database and server (rebuilds on each change)
docker-compose up --buildThe game will be available at:
- Frontend: http://localhost:3000 (webpack dev server)
- WebSocket Server: ws://localhost:8080 (Docker container)
- gRPC Server: localhost:50051 (Docker container)
- Database: localhost:5432 (Docker container)
-
Start PostgreSQL:
docker-compose up -d db
-
Run the server:
cargo run --bin server
-
Build and run the client:
cd client wasm-pack build --target web --out-dir pkg cd web npm install npm start
# Run all tests
cargo test
# Run server tests with logging
RUST_LOG=info cargo test -p server -- --nocapturecargo run -p bot -- --url http://localhost:8080 --mode duel --bots 40 --games 10 --queue-mode quickmatchcommon/- Shared game logic (compiled to both native and WASM)server/- Game server with WebSocket and gRPC supportclient/- WebAssembly client moduleterminal/- Terminal-based game viewer and replay playerspecs/- TLA+ specifications for distributed systems design
See server/docker-readme.md for detailed Docker and AWS Fargate deployment instructions.
MIT