The King's Game: Modular Chess Platform
A chess platform in Java 17 and JavaFX 21 with three Maven modules: a desktop client, a game engine without dependencies, and a TCP server for online play with accounts and matchmaking. Standard chess and Chess 960.
Overview
The project has three Maven modules. application is the JavaFX desktop client, core is the game engine for standard chess and Chess 960, and server hosts online games over TCP, with accounts, matchmaking and persistence. core has no external dependencies, and client and server depend on core only. Neither knows about the other.
I started it in my second year at university. The client was rewritten from Swing to JavaFX in March 2026, and the server keeps user accounts, sessions and games in SQLite. I use the project to see how spec-driven and test-driven agent workflows hold up on a codebase where architecture rules and tests can check the result.

Features
- Local play for two players on the same machine
- Online play with a TCP lobby, join codes and automatic matchmaking
- Standard chess and Chess 960, selectable per game
- Full rule enforcement: castling, en passant, promotion with a piece-selection dialog, stalemate, the 50-move rule, threefold repetition and insufficient material
- Six themes: Midnight, Ember and Abyss (dark), Manuscript, Fjord and Sakura (light)
- English and German through
ResourceBundle - A headless mode for programmatic game control (
noguiflag) - An animated main menu drawn in code, which a Reduced Motion setting turns off

Architecture
Five rules hold across the modules:
corehas no dependency onapplicationorserver. Client and server depend oncoreonly, never on each other.- All access to the game engine goes through the
Chess.javafacade. Code outsidecoredoes not instantiateGamesubclasses directly. - UI components implement
GameObserverand register withchess.addObserver(). Nothing polls. coreis logic only: no UI imports, no JavaFX, no I/O.- A new rule variant implements the
Rulesetinterface.Gamedoes not branch on the variant.
Design patterns
| Pattern | Implementation | Purpose |
|---|---|---|
| Facade | Chess.java | One entry point for all access to the engine |
| Observer | GameObserver / Observable | Pushes state changes to the UI and the network layer without coupling them to core |
| Strategy | Ruleset with StandardChessRuleset and Chess960Ruleset | Rule variants without conditionals in the game logic |
| Factory Method | Game.createGame() / Game.createServerGame() | Keeps constructors package-private, which enforces the module boundaries |
| Template Method | Game.executeMove() | Fixes the order of a move, and OnlineGame overrides the step that relays it over the network |
Multiplayer server
The server accepts TCP connections on a configurable port (default 54321) and speaks a line-based text protocol. Port, game limit, timeouts and expiry come from server.properties.
- Up to 40 games at once by default, limited by a semaphore.
- Join codes have 12 characters from A–Z and 0–9, shown as
XXXX-XXXX-XXXX. They come fromSecureRandomand expire after 10 minutes by default. - A matchmaking queue pairs opponents who do not use a join code.
- Login, registration and token-based sessions, with SQLite storing users, sessions and games.
- Every move is validated by the same engine before it is relayed, and illegal moves are rejected.
- When a player disconnects, the game pauses. If the player has not returned after 300 seconds (the default), the opponent wins by timeout.

Testing
The three modules together have 75 test classes.
| Module | Test classes | Focus |
|---|---|---|
core | 34 | Board state, move generation, all piece types, both rulesets, castling, observer notifications, game factory, online game protocol |
application | 31 | Facade API, i18n, settings, theme manager, menu components, controller logic, CSS validation |
server | 10 | Server lifecycle, configuration, game management, client handler, matchmaking, authentication, persistence |


Tech stack
| Layer | Technology |
|---|---|
| Language | Java 17 |
| UI | JavaFX 21 (FXML and CSS theming) |
| Build | Maven (multi-module) |
| Testing | JUnit 5, Mockito |
| Networking | Java standard library (ServerSocket, ConcurrentHashMap, Semaphore) |
| Persistence | SQLite (user accounts, sessions and games on the server) |
| Localization | ResourceBundle (EN/DE) |
| Theming | CSS (three dark, three light) |