A modern, web-based implementation of Laser Chess (also known as Khet) - the strategic board game where players use mirrors and lasers to capture pieces and outmaneuver their opponent.
This monorepo contains:
server/ – Authoritative game server built with Node.js, Express, Socket.IO and SQLite for game persistenceclient/ – Interactive game client with 3D board view (React, Vite, Three.js) and 2D board view (HTML/CSS) with animated laser effectsshared/ – Core TypeScript game engine handling rules, laser mechanics, and game state, shared between client and servernpm install --workspaces
# Terminal 1 – Server
npm run dev --workspace server
# Terminal 2 – Client
npm run dev --workspace client
Open the client at the URL Vite prints (typically http://localhost:5173). The client expects the server at http://localhost:3001.
# Build all workspaces
npm run build --workspaces
# Start production server
NODE_ENV=production npm run start --workspace server
Production builds are optimized and minified. The client build outputs to client/dist/ and can be served statically or deployed to CDN/hosting platforms like Cloudflare Pages or Vercel.
server/.env):PORT=3001 # Server port
HOST=0.0.0.0 # Server host (0.0.0.0 for external access)
CLIENT_URLS=http://localhost:5173,http://127.0.0.1:5173 # Allowed client origins
NODE_ENV=development # Environment mode
# Discord OAuth (optional)
DISCORD_CLIENT_ID=your_discord_client_id
DISCORD_CLIENT_SECRET=your_discord_client_secret
DISCORD_REDIRECT_URI=http://localhost:3001/auth/discord/callback
# Security
JWT_SECRET=your_secure_random_string
CSRF_SECRET=your_csrf_secret_key
client/.env):VITE_SERVER_URL=http://localhost:3001 # Server URL
For network access, update CLIENT_URLS in server/.env and create client/.env.local:
# server/.env
CLIENT_URLS=http://localhost:5173,http://192.168.x.x:5173
# client/.env.local
VITE_SERVER_URL=http://192.168.x.x:3001
OpenSphinx/
├─ server/
├─ client/
└─ shared/
games.db) on the serverGET /api/games - List all saved gamesDELETE /api/games/:id - Delete a saved gameGET /auth/discord - Discord OAuth loginGET /auth/discord/callback - Discord OAuth callbackPOST /auth/logout - User logoutgame:save - Save current game stategame:load - Load a saved gamegame:saved - Confirmation of save operationroom:create - Create a new game roomroom:join - Join an existing roomgame:move - Submit a player movegame:state - Receive game state updatesFull API documentation is available at https://neofuzz.github.io/OpenSphinx/
CLIENT_URLS in server/.env includes your client URLnetstat -an | findstr :3001 (Windows) or lsof -i :3001 (Unix)PORT in server/.env and VITE_SERVER_URL in client/.envnpx kill-port 3001 5173server/games.db on first rungames.db to reset all saved gamesrm -rf node_modules package-lock.json && npm install --workspacesnode --versionnpm run type-check --workspaces to identify issuesContributions are welcome! Please follow these guidelines:
git checkout -b feature/your-featurenpm run build --workspacesgit commit -m "Add: feature description"git push origin feature/your-featureGNU Affero General Public License v3.0 - see LICENSE file for details.
This project is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. If you modify this program and provide it as a network service, you must make the source code available to users.
shared/src/engine.env.local files are gitignored for local overrides