A full-featured chess game implementation with a Spring Boot backend, supporting all standard chess rules and features. This project serves as a foundation for a scalable chess platform with future plans for online multiplayer capabilities.
-
Complete Chess Rules Implementation:
- Standard piece movements and captures
- Special moves (castling, en passant)
- Check and checkmate detection
- Stalemate recognition
- Pawn promotion
- Draw conditions (perpetual check, insufficient material)
-
Game Controls:
- Time control options
- Game state persistence
- Move history tracking
-
RESTful API:
- Game creation endpoints
- Move validation and execution
- Game state queries
- Board representation
The project is structured following a clean, modular design:
- Pieces: Abstract base class with specific implementations (Pawn, Rook, Knight, etc.)
- Board: Manages the game state and piece positions
- Game: Coordinates game flow, rules enforcement, and state transitions
- Timer: Handles chess clock functionality for timed games
Provides business logic to the controllers and handles game state management.
RESTful controllers exposing endpoints for game interaction.
Basic web interface for game visualization.
- Online multiplayer capability
- User accounts and authentication
- Game history and statistics
- Rating system
- Tournament support
- Backend: Java 21, Spring Boot 3.4.2
- Build Tool: Maven
- Testing: JUnit, with more than 60 comprehensive test cases
- Frontend: HTML, CSS and JavaScript
The project includes 69 test cases covering various aspects of the chess implementation:
- Piece movement validation
- Special move rules (en passant, castling)
- Check and checkmate scenarios
- Draw conditions
- Game state transitions
This project represents a significant milestone in my development journey. Starting from scratch with the core chess components (pieces, board), I built the entire system layer by layer:
- Implemented the abstract
Piececlass and its concrete implementations - Developed the
Boardrepresentation and state management - Created the
Gamelogic to enforce rules and manage state - Added special chess rules like en passant (particularly challenging)
- Built the service and controller layers
- Implemented comprehensive testing (69 tests)
- Added time control features
src/
├── main/
│ ├── java/
│ │ └── itawi/
│ │ └── chessgame/
│ │ ├── ChessGameApplication.java
│ │ ├── config/
│ │ ├── controller/
│ │ │ └── ChessGameController.java
│ │ ├── core/
│ │ │ ├── board/
│ │ │ ├── enums/
| | | ├── exception/
│ │ │ ├── game/
│ │ │ ├── piece/
│ │ │ ├── timer/
│ │ │ └── util/
│ │ ├── dto/
│ │ └── service/
│ │ └── ChessGameService.java
│ └── resources/
│ ├── static/
│ │ └── js/
│ │ └── chess.js
│ └── templates/
└── test/
└── java/
└── itawi/
└── chessgame/
├── ChessGameApplicationTests.java
└── core/
├── board/
├── game/
├── piece/
└── timer/
- Java 21
- Maven
- Clone the repository
- Run
mvn clean install - Start the application with
mvn spring-boot:run - Access the game at
http://localhost:8080
POST /api/v1/chess/new-game- Start a new gameGET /api/v1/chess/board- Get the current board stateGET /api/v1/chess/status- Get the current game status- Additional endpoints for moves, promotions, and game state management
The most significant challenge during development was implementing the en passant rule correctly, which required careful consideration of piece state tracking and move validation. This project provided valuable experience in:
- Object-oriented design for complex rule systems
- State management in game applications
- Comprehensive test case development
- RESTful API design for interactive applications
Made with ♟️ and ❤️ by Itawi
