A full-stack, real-time multiplayer chess application built with microservices architecture. Play chess with friends through matchmaking or private matches, featuring real-time gameplay, live chat, and time controls.
- Features
- Architecture
- Tech Stack
- Project Structure
- Prerequisites
- Installation & Setup
- Running the Application
- API Documentation
- Folder Structure
- Configuration
- Troubleshooting
- Contributing
- ⚡ Real-time Multiplayer Chess - Play with opponents in real-time using WebSocket
- 🎯 Matchmaking System - Quick match with players of similar skill
- 🔒 Private Matches - Create and share match IDs to play with friends
- ⏱️ Time Controls - Blitz (3+0) and Rapid (10+0) game modes
- 💬 In-game Chat - Communicate with your opponent during matches
- 🏆 Game Outcomes - Win, loss, draw, and resignation tracking
- 🔐 JWT Authentication - Secure token-based authentication
- 🌐 OAuth 2.0 Integration - Login with Google and GitHub
- 👤 User Profiles - Manage your account and view game history
- 🎨 Modern UI - Beautiful, responsive interface with Tailwind CSS
- 🔄 Service Discovery - Eureka for automatic service registration
- 🌉 API Gateway - Centralized routing and load balancing
- 📡 WebSocket Support - Real-time bidirectional communication
- 🗄️ PostgreSQL - Reliable data persistence
This project follows a microservices architecture with the following services:
┌─────────────────────────────────────────────────────────────┐
│ FRONTEND │
│ React + TypeScript │
│ (Port 5173/8081) │
└──────────────┬─────────────────────────┬────────────────────┘
│ │
REST API│ │WebSocket (Direct)
│ │
▼ ▼
┌──────────────────┐ ┌──────────────────────┐
│ API GATEWAY │ │ MATCH SERVICE │
│ (Port 8080) │ │ (Port 8082) │
└────────┬─────────┘ │ - Game Logic │
│ │ - WebSocket Server │
│ │ - Matchmaking │
┌────────┴─────────┐ │ - Chat │
│ │ └──────────────────────┘
▼ ▼
┌─────────────┐ ┌──────────────────┐
│USER SERVICE │ │ MATCH SERVICE │
│(Port 8083) │ │ (Port 8082) │
│- Auth │ │- Match CRUD │
│- JWT │ │- REST APIs │
│- OAuth2 │ └──────────────────┘
└─────────────┘
│
▼
┌──────────────────┐
│ EUREKA SERVER │
│ (Port 8761) │
│- Service Registry│
└──────────────────┘
- REST APIs → Routed through API Gateway (Port 8080)
- WebSocket → Direct connection to Match Service (Port 8082)
- Service Discovery → All services register with Eureka
- Java 17 - Primary programming language
- Spring Boot 3.2 - Application framework
- Spring Cloud - Microservices infrastructure
- Eureka Server - Service discovery
- Spring Cloud Gateway - API Gateway
- Spring Security - Authentication & authorization
- Spring WebSocket - Real-time communication
- PostgreSQL - Primary database
- JWT - Token-based authentication
- OAuth 2.0 - Social login (Google, GitHub)
- Maven - Dependency management
- React 18 - UI framework
- TypeScript - Type-safe JavaScript
- Vite - Build tool and dev server
- Tailwind CSS - Utility-first CSS framework
- shadcn/ui - Component library
- React Router - Client-side routing
- STOMP.js - WebSocket client
- SockJS - WebSocket fallback
IndiChess-MicroServices/
│
├── Api-Gateway/ # API Gateway Service
│ ├── src/
│ │ └── main/
│ │ ├── java/
│ │ │ └── com.Api_Gateway/
│ │ │ └── ApiGatewayApplication.java
│ │ └── resources/
│ │ ├── application.properties
│ │ └── application.yaml # Gateway routes & CORS config
│ └── pom.xml
│
├── Eureka-Server/ # Service Registry
│ ├── src/
│ │ └── main/
│ │ ├── java/
│ │ │ └── com.Eureka_Server/
│ │ │ └── EurekaServerApplication.java
│ │ └── resources/
│ │ └── application.properties
│ └── pom.xml
│
├── Match-Service/ # Game Logic & WebSocket
│ ├── src/
│ │ └── main/
│ │ ├── java/
│ │ │ └── com.Match_Service/
│ │ │ ├── Config/
│ │ │ │ ├── SecurityConfig.java
│ │ │ │ ├── WebSocketConfig.java
│ │ │ │ └── WebSocketAuthInterceptor.java
│ │ │ ├── Controller/
│ │ │ │ ├── MatchController.java
│ │ │ │ ├── MatchmakingController.java
│ │ │ │ ├── GameWebSocketController.java
│ │ │ │ └── ChatController.java
│ │ │ ├── Service/
│ │ │ │ └── MatchService.java
│ │ │ ├── Model/
│ │ │ ├── Repository/
│ │ │ ├── Security/
│ │ │ └── dto/
│ │ └── resources/
│ │ └── application.properties
│ └── pom.xml
│
├── User-Service/ # Authentication & User Management
│ ├── src/
│ │ └── main/
│ │ ├── java/
│ │ │ └── com.User_Service/
│ │ │ ├── Config/
│ │ │ ├── Controller/
│ │ │ ├── Service/
│ │ │ ├── Model/
│ │ │ ├── Repository/
│ │ │ └── Security/
│ │ └── resources/
│ │ ├── application.properties
│ │ ├── static/ # OAuth2 success pages
│ │ └── templates/
│ └── pom.xml
│
└── frontend/ # React Frontend
├── src/
│ ├── components/ # Reusable UI components
│ ├── contexts/ # React contexts (Auth, etc.)
│ ├── hooks/ # Custom React hooks
│ ├── lib/ # Utilities and API client
│ │ └── api.ts # API service layer
│ ├── pages/ # Page components
│ │ ├── ChessGame.tsx # Main game interface
│ │ ├── Play.tsx # Matchmaking page
│ │ ├── CreateMatch.tsx
│ │ ├── Dashboard.tsx
│ │ ├── Login.tsx
│ │ └── Register.tsx
│ └── types/ # TypeScript type definitions
├── public/
├── package.json
├── tailwind.config.js
├── tsconfig.json
└── vite.config.ts
Before you begin, ensure you have the following installed:
- Java 17 or higher - Download
- Maven 3.8+ - Download
- Node.js 18+ - Download
- PostgreSQL 14+ - Download
- Git - Download
- IntelliJ IDEA or Eclipse - For Java development
- VS Code - For frontend development
- Postman - For API testing
git clone https://github.com/yourusername/IndiChess-MicroServices.git
cd IndiChess-MicroServices# Connect to PostgreSQL
psql -U postgres
# Create databases
CREATE DATABASE user_service_db;
CREATE DATABASE match_service_db;
# Exit psql
\qUpdate database credentials in each service's application.properties:
User-Service (User-Service/src/main/resources/application.properties):
spring.datasource.url=jdbc:postgresql://localhost:5432/user_service_db
spring.datasource.username=postgres
spring.datasource.password=yourpasswordMatch-Service (Match-Service/src/main/resources/application.properties):
spring.datasource.url=jdbc:postgresql://localhost:5432/match_service_db
spring.datasource.username=postgres
spring.datasource.password=yourpasswordBoth User-Service and Match-Service need the same JWT secret for token validation.
User-Service (application.properties):
jwt.secret=your-very-long-secret-key-min-256-bits-recommended-for-hs384Match-Service (application.properties):
jwt.secret=your-very-long-secret-key-min-256-bits-recommended-for-hs384To enable Google/GitHub login, add credentials to User-Service:
application.properties:
# Google OAuth2
spring.security.oauth2.client.registration.google.client-id=your-google-client-id
spring.security.oauth2.client.registration.google.client-secret=your-google-client-secret
# GitHub OAuth2
spring.security.oauth2.client.registration.github.client-id=your-github-client-id
spring.security.oauth2.client.registration.github.client-secret=your-github-client-secretHow to get credentials:
- Google: Google Cloud Console
- GitHub: GitHub Developer Settings
# Build Eureka Server
cd Eureka-Server
mvn clean install
cd ..
# Build API Gateway
cd Api-Gateway
mvn clean install
cd ..
# Build User Service
cd User-Service
mvn clean install
cd ..
# Build Match Service
cd Match-Service
mvn clean install
cd ..cd frontend
npm installServices must be started in this specific order:
cd Eureka-Server
mvn spring-boot:runWait for: Eureka Server started on port 8761
Verify at: http://localhost:8761
cd User-Service
mvn spring-boot:runWait for: User Service started on port 8083
cd Match-Service
mvn spring-boot:runWait for: Match Service started on port 8082
cd Api-Gateway
mvn spring-boot:runWait for: API Gateway started on port 8080
cd frontend
npm run devFrontend will start on: http://localhost:5173
- Go to http://localhost:5173/register
- Create an account with email/password
- Or use Google/GitHub OAuth
- Click "Play" from dashboard
- Select game mode (Blitz or Rapid)
- Wait for opponent
- Game starts automatically when matched
- Click "Create Private Match"
- Share the Match ID with a friend
- Friend enters Match ID to join
- Game starts when both players ready
- Make Moves: Click piece → Click destination
- Chat: Use chat panel to message opponent
- Resign: Click flag icon to resign
- Time: Watch your clock and opponent's clock
POST /auth/register
POST /auth/login
GET /auth/mePOST /match/create-private
POST /match/{id}/join
GET /match/{id}
POST /match/{id}/resignCONNECT /ws (Port 8082)
SUBSCRIBE /topic/matchmaking/{email}
SUBSCRIBE /topic/game/{matchId}
SUBSCRIBE /topic/game/{matchId}/chat
SEND /app/matchmaking/join
SEND /app/game/{matchId}/move
SEND /app/game/{matchId}/chat
| Service | Port | Description |
|---|---|---|
| Frontend | 5173 | React development server |
| Frontend (Build) | 8081 | Production build (optional) |
| API Gateway | 8080 | Main entry point for REST APIs |
| User Service | 8083 | Authentication & user management |
| Match Service | 8082 | Game logic & WebSocket |
| Eureka Server | 8761 | Service registry |
Create .env file in frontend/:
VITE_API_URL=http://localhost:8080CORS is configured in API Gateway (application.yaml):
spring:
cloud:
gateway:
globalcors:
cors-configurations:
'[/**]':
allowed-origins:
- "http://localhost:5173"
- "http://localhost:8081"
allowed-methods:
- GET
- POST
- PUT
- DELETE
allow-credentials: trueSymptom: Service doesn't appear in Eureka dashboard
Solution:
- Ensure Eureka Server is running first
- Check
eureka.client.service-url.defaultZoneinapplication.properties - Verify network connectivity to
localhost:8761
Symptom: org.postgresql.util.PSQLException
Solution:
# Check PostgreSQL is running
sudo service postgresql status
# Verify databases exist
psql -U postgres -l
# Check credentials in application.propertiesSymptom: "blocked by CORS policy"
Solution:
- Ensure you're using correct ports (REST→8080, WebSocket→8082)
- Check
ChessGame.tsxuseshttp://localhost:8082/wsfor WebSocket - Verify API Gateway CORS configuration
Symptom: "Invalid token" or 401 Unauthorized
Solution:
- Ensure same JWT secret in User-Service and Match-Service
- Clear browser localStorage and re-login
- Check token expiration (default 24 hours)
Symptom: "Failed to connect to WebSocket"
Solution:
- Verify Match Service is running on port 8082
- Check browser console for exact error
- Ensure JWT token is valid
- Try hard refresh (Ctrl+Shift+R)
Symptom: Port 8080 already in use
Solution:
# Find process using port
lsof -i :8080
# Kill process (replace PID)
kill -9 PID
# Or change port in application.properties
server.port=8081Backend (Hot Reload with Spring DevTools):
cd User-Service
mvn spring-boot:run -Dspring-boot.run.profiles=devFrontend (Hot Reload):
cd frontend
npm run devBackend:
# Each service
mvn clean package -DskipTests
# Run JAR
java -jar target/service-name.jarFrontend:
npm run build
npm run preview # Test production buildUsing Flyway (if configured):
mvn flyway:migrate- Total Services: 4 (Eureka, Gateway, User, Match)
- Lines of Code: ~15,000+
- Frontend Components: 20+
- API Endpoints: 15+
- WebSocket Events: 6+
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Manisha Priya
- Chess piece Unicode symbols
- Spring Boot team for excellent microservices framework
- React community for frontend tools
- shadcn/ui for beautiful components
For support, email manishapriya1325@gmail.com or open an issue in the repository.
- Add ELO rating system
- Implement game analysis with AI
- Add replay functionality
- Tournament mode
- Mobile app (React Native)
- Docker containerization
- Kubernetes deployment
- CI/CD pipeline
Made with ❤️ by Chess Enthusiasts