lila-server
Effect v4 HTTP API for a lichess-style chess scaffold, serving game state, legal moves, and Stockfish analysis.
Overview
lila-server is the backend for the chess scaffold used as the testbed for
the Effect v4 migration in this monorepo. It exposes an HTTP API for creating
games, validating moves via chess.js, persisting game state and events to
Postgres, and requesting Stockfish (wasm) engine analysis or computer moves.
It pairs with apps/lila-web (the Next.js play page) but has no UI of its own.
Status: scaffold. Hot-seat and vs-computer play work end-to-end, but there is no realtime push between browsers and no auth — player IDs are hard-coded.
Stack
- Effect v4 (
effect,@effect/platform-node) for the HTTP server and service layer @repo/chess-domain— branded IDs, Schema types, tagged errors, events@repo/chess-services—GameService(rules + persistence) andEngineService(Stockfish)@repo/realtime— in-processEventBus(PubSub) for game events@repo/telemetryfor observability- Runs via
tsx(no separate build/bundle step)
Develop
# from repo root, after local Postgres + migrations are set up
pnpm --filter lila-server dev # tsx --watch, serves on :3030
# other scripts
pnpm --filter lila-server lint
pnpm --filter lila-server check-typesRequires apps/lila-server/.env (see the app README for the full local
Postgres + Supabase setup):
PORT=3030
CORS_ORIGINS=http://localhost:3031
DATABASE_URL=postgresql://postgres:postgres@127.0.0.1:54322/postgresTest
pnpm --filter lila-server test # vitest
pnpm --filter lila-server test:ci # vitest run + junit reportBuild & deploy
There is no separate build step — dev and start both run the TypeScript
source directly via tsx (start runs node --import tsx src/main.ts).
Deploy target: Internal / not separately deployed.
Structure
src/main.ts— HTTP server entry point (/health,/games,/games/:id,/games/:id/legal-moves,/games/:id/moves,/games/:id/computer-move)- Depends on workspace packages
@repo/chess-domain,@repo/chess-services,@repo/realtimefor domain logic, rules/persistence, and the event bus - Chess schema (
chess_games,chess_game_events) lives inpackages/db/src/schema/chess.ts
See the apps overview and the monorepo overview.