A full-stack, real-time multiplayer chess application built with modern web technologies. Players can authenticate via Google or GitHub, and play chess games against other users with live updates and ELO rating calculations.
- OAuth2 Authentication - Sign in with Google or GitHub
- Real-time Multiplayer - WebSocket-based live game updates
- ELO Rating System - Automatic rating calculations after each game
- Game History - Track played games with move recording
- Responsive UI - Works across desktop and mobile devices
- TypeScript - Full type safety across the stack
Chess/
├── apps/
│ ├── backend/ # Express.js API server with Passport.js auth
│ ├── frontend/ # React + Vite SPA with Recoil state management
│ └── ws/ # WebSocket server for real-time game updates
├── packages/
│ └── db/ # Prisma ORM schema and migrations
└── package.json # Monorepo configuration (pnpm workspaces)
- Express.js - REST API server
- Passport.js - OAuth2 authentication
- WebSocket - Real-time communication
- Prisma - Database ORM
- JWT - Session tokens
- Redis - Rate limiting and caching
- React 18 - UI framework
- Vite - Build tool
- Recoil - State management
- TypeScript - Type safety
- PostgreSQL - Primary database
- Prisma - Schema management and migrations
- Node.js 18+
- PostgreSQL database
- OAuth2 applications (Google, GitHub)
-
Clone the repository
git clone <repository-url> cd Chess
-
Install dependencies
pnpm install
-
Setup environment variables
cp .env.example .env # Edit .env with your configuration -
Setup database
cd packages/db pnpm prisma migrate dev -
Start development servers
# In separate terminals: pnpm dev --filter=backend # Backend API pnpm dev --filter=frontend # Frontend dev server pnpm dev --filter=ws # WebSocket server
Visit http://localhost:5173 in your browser.
The application uses OAuth2 for authentication with two providers:
- Google - via
passport-google-oauth20 - GitHub - via
passport-github2
See AUTH_DOCUMENTATION.md for detailed authentication flow and setup.
See .env.example for all required environment variables.
DATABASE_URL- PostgreSQL connection stringJWT_SECRET- JWT signing secret (use strong value in production)SESSION_SECRET- Express session secretGOOGLE_CLIENT_ID,GOOGLE_CLIENT_SECRET- Google OAuthGITHUB_CLIENT_ID,GITHUB_CLIENT_SECRET- GitHub OAuthBACKEND_URL- Backend server URLCLIENT_URL- Frontend server URL
GET /auth/google- Initiate Google OAuthGET /auth/google/callback- Google OAuth callbackGET /auth/github- Initiate GitHub OAuthGET /auth/github/callback- GitHub OAuth callbackGET /auth/refresh- Refresh authentication tokenGET /auth/logout- Logout userGET /auth/login/failed- Login failure endpoint
- URL:
ws://localhost:8080?token=<jwt_token> - Authentication: JWT token passed as query parameter
- See AUTH_DOCUMENTATION.md for message protocol
Standard chess rules apply. The ELO rating system adjusts player ratings based on:
- Game result (win/loss/draw)
- Opponent rating
- Game outcome probability
backend/
├── src/
│ ├── index.ts # Express app setup
│ ├── passport.ts # OAuth2 strategies
│ ├── router/
│ │ ├── auth.ts # Authentication routes
│ │ └── v1.ts # API v1 routes
│ ├── db/ # Database utilities
│ └── [other services]
frontend/
├── src/
│ ├── App.tsx # Main app component
│ ├── components/ # Reusable components
│ ├── screens/ # Page components
│ ├── hooks/ # Custom hooks
│ └── store/ # Recoil atoms
ws/
├── src/
│ ├── index.ts # WebSocket server
│ ├── GameManager.ts # Game management
│ ├── SocketManager.ts # User connections
│ ├── Game.ts # Game logic
│ ├── messages.ts # Message types
│ └── [other services]
pnpm buildpnpm test- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
ISC License - See LICENSE file for details
Created as a full-stack project demonstrating modern web development practices.