WIP: feat: NCS-37 Quarkus integration #29
Reference in New Issue
Block a user
Delete Branch "feat/NCS-37"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Implements the full REST API defined in
docs/api-spec.yamlas a newmodules/backcoreQuarkus 3.32.4 module. The module follows the exact sameQuarkus + Scala 3.5.1 setup established on the
feat/quarkusbranch (plugin, BOM, Jakarta CDI,@QuarkusTest+ JUnit 5), and sits as a cleanadapter layer on top of the existing
api,core,io, andrulemodules — none of which were modified.Endpoints implemented
POST/api/board/gameGET/api/board/game/{gameId}GET/api/board/game/{gameId}/streamPOST/api/board/game/{gameId}/move/{uci}GET/api/board/game/{gameId}/moves?square=e2filter)POST/api/board/game/{gameId}/undoPOST/api/board/game/{gameId}/redoPOST/api/board/game/{gameId}/resignPOST/api/board/game/{gameId}/draw/{action}POST/api/board/game/import/fenPOST/api/board/game/import/pgnGET/api/board/game/{gameId}/export/fenGET/api/board/game/{gameId}/export/pgnArchitecture
Why a separate module (not embedded in
core)coreis a framework-agnostic domain library used by the terminal UI and future CLIs. Adding Quarkus to it would force all consumers to pull inthe entire runtime and violate the existing architectural principle ("GameEngine never imports UI code").
backcoreis the web adapter — a thirddelivery mechanism alongside
ui.Key design decisions
GameStore(@ApplicationScoped) — in-memoryMap[String, GameSession]withsynchronizedaccess. Holds oneGameSessionper game.GameEngine—GameEnginewas designed for the terminal (auto-resets after checkmate, observer pattern).backcorecallsRuleSet.applyMovedirectly and managesGameContextstate inGameStore, giving full lifecycle control.CommandInvokerfor undo/redo — reused frommodules/core. Each move is stored as aMoveCommandwithpreviousContextfor undo andmoveResult.newContextfor redo.GameResultsealed trait — captures why a game ended (Checkmate,Stalemate,Resign,AgreedDraw,FiftyMoveDraw,InsufficientMaterial), decoupled fromGameStatusstrings in the API spec.GameSession.drawOfferedBy: Option[Color]. The offer persists across moves (REST model has noimplicit withdrawal on move, unlike OTB chess).
{"type":"gameFull","game":{...}}\n) rather than a persistent SSEconnection.
GameState— populated with SAN move text viaPgnExporter.exportGame(Map.empty, moves), which returns move-text-only whengiven no headers.
Module structure
modules/backcore/
├── build.gradle.kts
├── src/main/
│ ├── resources/application.yml
│ └── scala/de/nowchess/backcore/
│ ├── config/JacksonConfig.scala # registers DefaultScalaModule
│ ├── dto/Dtos.scala # all request/response DTOs
│ ├── game/
│ │ ├── GameId.scala # 8-char alphanumeric ID generator
│ │ ├── GameMapper.scala # GameSession → DTOs, status computation
│ │ ├── GameResult.scala # sealed trait for game-over reasons
│ │ ├── GameSession.scala # per-game state (context + invoker + metadata)
│ │ └── GameStore.scala # @ApplicationScoped in-memory store
│ └── resource/
│ ├── GameResource.scala # game lifecycle, resign, draw, export, stream
│ ├── ImportResource.scala # FEN/PGN import
│ └── MoveResource.scala # move, legal moves, undo, redo
└── src/test/scala/de/nowchess/backcore/
├── BackcoreStartupTest.scala
└── resource/
├── GameResourceTest.scala
├── ImportExportTest.scala
├── MoveResourceTest.scala
├── ResignDrawTest.scala
└── UndoRedoTest.scala
Tests
34
@QuarkusTestintegration tests, all passing. Each TDD cycle wrote tests before implementation:BackcoreStartupTestGameResourceTestMoveResourceTestUndoRedoTestResignDrawTestImportExportTestBuild
020941e404todb955c08a5Why is there bot stuff in Quarkus branch? :( the diff is so big now too

Doesn't matter the branch is deprecated and will not be merged. Refactor in NCS-51
Pull request closed