albertonline.org docs
Packages

Games (chess & draughts)

Domain, services, and UI packages for the chess and draughts games — plus their local type shims and a Blind 75 algorithms package.

These packages split the two board games into per-concern layers (domain schemas, Effect services, React UI, rules engines) so chess-services and chess-ui — or draughts-rules and draughts-ui — can be tested and versioned independently. @repo/algorithms and the two @types/* shims are grouped here because they only exist to support this games code.

@repo/chess-domain

Schema-first domain types shared between the chess server and client: no UI, no I/O. Everything is effect Schema classes/unions, so decoded values are the only shapes the rest of the chess code is allowed to see.

  • ChessError — tagged ChessError and its reason union (illegal move, not your turn, game not found, game over, join code not found, game already full, cannot join own game, not a participant)
  • ChessGameSide, Outcome, GameStatus, Variant, Move, GameState, and the GameEvent union (GameCreated, PlayerJoined, MoveMade, GameEnded)
  • ChessId — branded GameId, PlayerId, JoinCode schemas
  • ChessRpc — the OnlineRpc RpcGroup, Unauthorized error, and the GuestSession / GuestSessionMiddleware RPC middleware
  • ChessSignalSignalKind and SignalEvent schemas for WebRTC signaling
  • ChessEvent — a small define/registered event-registry helper used to build the tagged events above

@repo/chess-services

Effect services that implement chess gameplay: the engine integration and the game/matchmaking logic, backed by @repo/db and @repo/realtime.

  • EngineService — a Context.Service wrapping the stockfish UCI engine (via @repo/stockfish-types) for move analysis/best-move requests
  • GameService — a Context.Service for creating, joining, and advancing chess games (row ⇄ GameState mapping, side resolution, event ids)
  • detectOutcome / rulesForVariant (from rules-adapter) — adapts chess.js into the shared GameRules/MoveApplication shape and detects checkmate/stalemate/draw outcomes

@repo/chess-ui

React components and hooks for rendering a chess board and its game-end celebration, built on @repo/chess-domain types.

  • Board — the chess board component
  • isWin, outcomeLabel, type Outcome — outcome-to-label helpers
  • fireConfetti, fireOutcomeConfetticanvas-confetti wrappers
  • useOutcomeConfetti — fires confetti on a win outcome
  • useDialogCloseHandlers — shared close-handling for game-end dialogs

@repo/draughts-rules

Effect-based rules engines for draughts, covering three variants behind one DraughtsRules interface.

  • rulesFor(variant) — picks the rules implementation for "international" | "english" | "russian"
  • internationalRules — wraps @jortvl/draughts (via @repo/jortvl-draughts-types) as the authoritative rules oracle for international draughts
  • englishRules, russianRules — hand-rolled rules implementations (handrolled.ts)
  • boardsquareToCell, squareToAlgebraic, algebraicToSquare, cellToSquare, buildFen, parsePosition square/FEN helpers
  • variantVariant, Player, Outcome, DraughtsMove schemas
  • rules — the shared DraughtsRules / MoveResult types

@repo/draughts-ui

A single React board component for draughts, mirroring @repo/chess-ui's role for the chess game.

  • DraughtsBoard, type DraughtsBoardProps — the draughts board component, built on @repo/draughts-rules types

@repo/algorithms

A standalone learning/reference package of Blind 75 algorithm solutions and generic data structures (TypeScript, with parallel Go/Kotlin/Python/Rust solutions); it isn't imported by the games code and isn't published as @repo/* (its package name is bare algorithms).

  • Heap<T> — generic min/max heap backed by an array and a comparator
  • ListNode, TreeNode, TrieNode — linked-list, binary-tree, and trie node types used across the solutions
  • src/blind-75-solutions/typescript/** — the 65 Blind 75 solutions grouped by category (array, binary, dynamic-programming, graph, heap, interval, linked-list, matrix, strings, tree)

@repo/stockfish-types

A local @types/stockfish shim for the stockfish npm package, which ships no published types. Declares only the surface EngineService relies on.

  • StockfishEngine — the UCI engine handle type (listener, sendCommand, terminate)
  • initEngine(flavor?) — default export, initializes an engine instance

@repo/jortvl-draughts-types

A local @types/jortvl__draughts shim for @jortvl/draughts, which also ships no published types. Declares only the surface @repo/draughts-rules' international adapter uses.

  • JortvlMove — one legal move (from, jumps, takes, to)
  • Draughts — default-exported class: moves(), move(), fen(), turn(), gameOver()

Both @types/* packages are private, workspace-only shims for libraries that ship no types of their own — they exist purely so the declarations resolve wherever the consuming package is type-checked, not just locally.

See the packages overview and the architecture guide.

On this page