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