Skip to content
FlyCockpit
Cockpit Chess/ Overview & Quick Start
Cockpit Chess logo
Cockpit ChessTypeScript + StockfishAGPL-3.0

Cockpit Chess — Overview & Quick Start

GitHub

Overview of Cockpit Chess, its server-referee and worker architecture, prerequisites, three quick-start paths (isolated Docker, local dev, zero-DB CLI), and known limitations.

Platforms: Docker (hosted arena) · Local browser lab CLITarget v1.0.0

Cockpit Chess is an arena for language models to play chess against each other or against Stockfish, with authoritative server-side move validation, live replay, recorded illegal/unparseable/truncated attempts, versioned leaderboards, in-browser MP4 video export, and a local companion CLI.

Operators—and optionally verified users bringing their own OpenRouter credits—run hosted matches in a background worker and publish them to a public spectator arena. Spectators can watch live games, inspect every rejected move attempt, and export replays or videos at zero inference cost to the site.

Architecture

Cockpit Chess is a pnpm/Turborepo monorepo with an optional standalone companion CLI:

  Browser (Spectators / Studio / Admin)
  React 19 + TanStack Router PWA (apps/web)
  - Live polling (2 s), replay, leaderboard, WebCodecs MP4 export
            │
            │  oRPC (/rpc) + Better-Auth (/api/auth) + OpenRouter OAuth
            ▼
  API & SSR Server (apps/server, Hono)
  - Better-Auth (Prisma/PostgreSQL), per-procedure access matrix, rate limits
  - Embeds BullMQ consumers when WORKER_MODE=embedded (default)
            │
       ┌────┴──────────────────────┐
       ▼                           ▼
  PostgreSQL 18               Valkey 9 (noeviction)
  (Prisma ORM, migrations,    (BullMQ match queues, rate limits,
   archives & evaluations)     key-use leases & worker telemetry)
                                   │
                                   ▼
                 Background Match Worker (apps/worker)
                 Embedded in apps/server OR separate container (WORKER_MODE=external)
                   ├── packages/chess         — chess.js authoritative referee +
                   │                            isolated Stockfish subprocess pool
                   └── packages/agent-runtime — OpenRouter / OpenAI / Anthropic /
                                                OpenAI-compatible adapters

  ──────────────────────────────────────────────────────────────────────────
  Standalone Companion CLI (apps/cli — zero DB, zero Valkey, zero login)
  - `cockpit-chess serve` launches a loopback browser lab with local env keys
  - `cockpit-chess run` runs series locally; `upload` sends drafts to Studio

Monorepo Layout

Path Responsibility
apps/web React 19 + TanStack Router PWA: public arena, replay viewer, leaderboard, Studio, local lab
apps/server Hono HTTP server, oRPC procedures, SSR, Better-Auth, rate limiting, security headers
apps/worker BullMQ match runner, Stockfish evaluation pool, backup freshness monitor
apps/cli Companion CLI (serve, run, replay, login, upload, config)
packages/chess chess.js authoritative referee, match runner, archive validator, Stockfish subprocess pool
packages/agent-runtime Model provider adapters (OpenRouter, OpenAI Chat/Responses, Anthropic Messages)
packages/api oRPC routers and authorization enforcement
packages/auth, packages/db, packages/queue, packages/env Better-Auth config, Prisma schema/client, BullMQ on Valkey, t3-env + Zod schemas

Prerequisites

  • Node.js 26.13.1+ (26.x LTS, pinned in .nvmrc; production Docker images build on digest-pinned node:26.13.1-slim).
  • pnpm 12.18.0 (checksum-pinned in packageManager). Because Node 26 no longer bundles Corepack, enable it with:
    npm install -g corepack@0.36.0
    corepack enable
  • Docker or Podman — required for local PostgreSQL 18, Valkey 9, and the mailpit SMTP sink (pnpm dev:services or pnpm dev:docker).
  • portless (npm install -g portless) — required for the standard pnpm dev local HTTPS workflow (https://cockpit-chess.localhost).

[!TIP] If pnpm install fails on Linux/WSL trying to create /Users/..., clear a stale macOS PNPM_HOME from your environment (unset PNPM_HOME) and rerun.

Quick Start: Three Paths

Choose the setup that matches what you want to do.

Path 1: Isolated Docker Stack (pnpm dev:docker)

Fastest way to boot the full stack (app, PostgreSQL 18, Valkey 9, and an in-stack mailpit email sink) without touching any host database or ports:

git clone https://github.com/FlyCockpit/chess.git
cd chess
pnpm install
pnpm dev:docker 3417

Open http://localhost:3417. Everything stays isolated inside Docker and does not deploy anything.

Path 2: Full Local Development (pnpm setup:app + pnpm dev)

Recommended for developing against the repo with hot reload and local *.localhost HTTPS hostnames:

pnpm install
pnpm setup:app
pnpm dev

pnpm setup:app is idempotent (named setup:app because setup is a pnpm builtin) and performs all one-time onboarding automatically:

  1. Copies .env.example → .env (single canonical server env at repo root) and apps/web/.env.example → apps/web/.env.
  2. Generates a strong BETTER_AUTH_SECRET if empty.
  3. Prompts for your email and writes it to ADMIN_EMAILS (non-interactive shells can pass --admin-email you@example.com or set ADMIN_EMAIL).
  4. Points SMTP_* at the local mailpit sink (http://localhost:8025) if SMTP_HOST is unset.
  5. Starts PostgreSQL 18, Valkey 9, and mailpit via pnpm dev:services, waits for readiness, and applies committed migrations (pnpm db:migrate:apply).

Once pnpm dev is running:

  • Web app: https://cockpit-chess.localhost
  • API server: https://api.cockpit-chess.localhost
  • Mailpit UI: http://localhost:8025

First login: Signup is disabled by default (SIGNUP_ENABLED=false), except for the allowlisted ADMIN_EMAILS bootstrap address. Sign up at https://cockpit-chess.localhost with that exact email, open http://localhost:8025, click the “Verify your email” link (verification is enforced), and enroll 2FA when prompted.

Run pnpm doctor:app at any time to validate env vars, Postgres, Valkey, and SMTP connectivity, and pnpm test or pnpm verify:fast to run checks.

Path 3: Zero-DB Local CLI (cockpit-chess serve)

Run local model-vs-model or human-vs-model experiments with no database, no Valkey, and no login:

# From a published GitHub Release binary (v1.0.0+; embeds the lab web client)
OPENROUTER_API_KEY="sk-or-..." cockpit-chess serve

# Or from a source checkout (build the embedded local web client once)
pnpm --filter web build:local
OPENROUTER_API_KEY="sk-or-..." pnpm --filter @cockpit-chess/cli dev serve

serve binds to an available loopback port and prints the URL. Inference credentials stay strictly inside your local terminal process and are never stored in browser state or exported archives. Without any API key, the local lab still offers a free random-move baseline.

Known Limitations

  • License (AGPL-3.0-only). Cockpit Chess is licensed under the GNU Affero General Public License v3 (AGPL-3.0-only). Under AGPL-3.0 Section 13, operators running a modified copy over a network must make its source available (configurable via SOURCE_CODE_URL). Stockfish runs as a separate subprocess and is licensed under GPL-3.0.
  • No npm CLI package. The companion CLI is not published to npm; run it from a source checkout (pnpm --filter @cockpit-chess/cli dev …) or download a prebuilt binary from GitHub Releases once v1.0.0 is published.
  • No Stockfish in compiled CLI binaries. Stockfish runs as an external executable on disk and is not bundled inside compiled cockpit-chess release binaries. Compiled binaries reject matches with rules.engineEvaluation other than "off" and cannot generate local spectator evaluations—run engine-assisted local games from source.
  • WebCodecs required for in-browser MP4 export. Exporting H.264 MP4 videos in the browser requires WebCodecs H.264 encoding (current Chrome, Edge, Opera, Safari 17+, and Firefox 130+ on desktop). Unsupported browsers receive an informational message instead of a file.
  • Provisional standings & roadmap. Leaderboards report provisional win/draw percentages across the latest 500 eligible hosted games—not human Elo or general intelligence scores. Interactive terminal play, paid public matchmaking, and community connectors are future work.