Free, independent review of completed public Chess.com games. The product plan combines Stockfish analysis, replay for both players, and chess-only guidance.
Sprint planning, evidence and contributor notes are kept out of this repository. The product and its tests are self-contained.
This is a local development project, not a production release. Game Review now
includes automatic per-ply template coaching, optional ElevenLabs playback,
independent calibrated accuracy, a selectable evaluation graph and legal free
analysis. Analyze starts a bounded Standard server review; Settings also offers
Thorough review and local WASM depth/thread controls. The recorded game stays
unchanged when exploring branches. Manual accessibility gates remain open. S7
is unstarted; its 43 inherited test specifications remain visible and keep the aggregate make verify gate red;
CI reports them in a separate non-blocking job.
The review board and coach follow one visual language:
- Arrows start near the base of the moving piece, are translucent and
slightly thick. Green is the engine's suggested move; red is the opponent's
best reply. Both use the shared
ARROW_COLORSinapps/web/src/features/guidance/arrows.ts. - The last move's squares are tinted with that move's classification colour
(
classificationTint), not a neutral flash. - Best move for X enters the engine line at its starting position with a
green arrow and the coach explains it from reviewed template text plus typed
engine values (
bestMoveExplanation.ts); it never names an unproven tactic. - The coach is an ASCII queen. Its dialogue bubble reserves the final text height so typing never shifts the page, and the page never scrolls sideways.
- Buttons share the
--btn-*tokens inapps/web/src/revamp.css.
Set CHESS_ELEVENLABS_API_KEY in the API environment or local .env and restart
the API. Play requests synthesis of the selected move's reviewed note. The
application sends only that note to ElevenLabs George (Multilingual v2).
Play and mute are independent, and changing plies stops playback. When provider audio is unavailable, playback uses a device voice where supported.
The text coach remains available across both audio paths. Audio generation can use ElevenLabs account credits.
From apps/web: npm run check (types, ESLint, Prettier), npm test
(Vitest) and npm run test:e2e (Playwright; run
npx playwright install chromium once). Some E2E specs predate the current UI and are
reported by the non-blocking CI job (see Verification).
Use Python 3.14.7, Node 24.6.0, npm 11.5.1, uv 0.11.2, and Docker Desktop/Engine with Compose. Toolchain files and both lockfiles are tracked.
make setup
docker compose up -d --wait postgres redis
make verify-requiredPostgreSQL stores imported games and analysis evidence, and Redis queues the Stockfish worker, so both are required to run the app, not only the tests.
make setup installs locked dependencies and the Playwright Chromium browser.
Linux may also need cd apps/web && npx playwright install --with-deps chromium.
The gate needs the local PostgreSQL/Redis services, but no Chess.com or AI calls.
Run the entire development stack:
make upOpen http://localhost:5173. FastAPI health endpoints are at http://localhost:8000/api/v1/health/live and http://localhost:8000/api/v1/health/ready; OpenAPI docs are at http://localhost:8000/docs. Published ports bind only to loopback. The Compose credentials are for local development; this setup is not a public deployment.
Alternatively, keep only data services in Docker and run these in separate shells:
uv run --frozen uvicorn services.api.app.main:create_app --factory --reload
make engine-install
uv run --frozen python -m services.worker.main
npm --prefix apps/web run devRun make migrate before starting the API outside Compose. Compose runs its
migration service before starting the API.
Defaults match the local data services. Copy .env.example to .env only when
overriding configuration. API settings use the CHESS_ prefix and reject invalid
URLs/origins and unsafe production defaults. The frontend proxies /api to the
local API; no backend secrets enter its bundle.
If .env does not exist, create it from the template:
cp .env.example .envIn .env, uncomment CHESS_PUBAPI_USER_AGENT and replace the example contact
with your real operator email or project contact URL. Keep ChessTutor/0.1 as
the application name and version, then run make up to load the setting.
Editing .env.example alone does not configure the application. The .env file
is ignored by Git; keep personal contact details and credentials there.
The template setting is commented out so a fake contact is never sent upstream.
Without this setting the page explains that public lookup is not configured.
Health checks and fixture tests still work. A host-run API also reads .env;
Compose forwards this setting to its API.
Enter a public Chess.com username. The newest archive month opens by default; choose another month or filter by player color, exact opponent username, and time class. Filters apply only to that month. Click Analyze to validate/import the game and automatically open a Standard review. Select either player's recorded move or use icon navigation; accessible names and keyboard Left/Right/Home/End remain available. Flip preserves the selected ply. Expand “Text position and FEN” for textual board access. The NPC coach follows selected moves without questions; Coach options contains alternatives, arrow text and explanation level. Voice is opt-in and uses local English device voices, with text fallback.
Desktop fits board, coach, graph and navigation together; narrow, short and zoomed screens reflow. Engine Settings contains bounded Standard/Thorough server reviews and local depth 1–40 (default 18), 1–4 supported threads and a ten-second local search cap. Achieved depth may be lower. Refine a position locally or enable Self-analysis / Free play for legal branches, promotion, undo/redo and return. Local Stockfish.js 17.1 scores stay client-unverified; they never replace server Stockfish 19 coaching or game accuracy. Free analysis requires the backend for legal moves and PV validation. No WebGPU support is claimed.
Accuracy uses versioned backend best-versus-played Win% loss with harmonic and volatility-weighted aggregation. Missing/uncertain scores remain unavailable; coverage is shown. It is an independent Lichess-inspired metric, not Chess.com CAPS. Source links open Chess.com; no password or provider key is used.
Run make up after pulling S3 to rebuild the stack. Compose starts two workers
with verified Stockfish 19, one thread and 128 MiB hash each. Its pinned worker
image is Linux x86-64; Docker Desktop on ARM uses emulation. Native installation
supports macOS ARM64 and Linux x86-64 through make engine-install. Unsupported
platforms fail explicitly. Workers and jobs are partitioned by executable checksum.
Quick searches each pre-move position for 100 ms with two candidates, then the played move for 100 ms at that same root; Deep uses 750 ms and three candidates, then 750 ms for the played move. Job deadlines are 90/540 seconds. Progress is persisted per ply; cancellation, failure and timeouts retain partial evidence. Retry creates a new job subject to quotas. A crashed attempt can recover once using its original deadline. Polling does not reset replay selection.
Select a recorded move to see its pre-move alternatives and White-perspective evaluation. Mate distance is separate from centipawns. WDL and PV evidence is stored; unstable comparisons still receive a label but cannot earn badges. Compatible v1 server results also show independent move labels and coverage-aware summaries. Legacy cached results retain their original provenance and do not receive new labels. Template coaching uses compatible stored evidence. Completed cached Deep results offered for Quick retain their Deep label and consume no engine quota.
A signed anonymous HttpOnly session owns active jobs and cancellation; retain
the browser cookie while a job runs. Analysis submission and cancellation require
the configured frontend Origin. Limits are one active job/session, five Quick and two Deep jobs per
rolling hour/session, 20 jobs/hour/IP by default, 50 queued and two running.
Shared-network limits show retry feedback. General readiness checks PostgreSQL
and Redis; submissions separately require a verified, live engine worker.
For production set a private CHESS_SESSION_SECRET of at least 32 characters,
stable across API restarts, plus the existing production settings. Configure
CHESS_ANALYSIS_IP_JOBS_PER_HOUR deliberately for shared networks.
API clients first receive 409 session_required and a signed cookie if no valid
session exists; that response allocates no work. Resend the same submission with
the cookie. The browser does this once automatically; blocked cookies show an
error. This keeps the first accepted job retryable after a lost response.
Limits: 300 plies, 1 MiB UTF-8 PGN, 50 MiB monthly JSON, and 1 MiB archive index. Downloads request uncompressed responses and reject unexpected content encoding before reading the body. Stale cached data is explicitly labeled; source cache entries are retained up to seven days, subject to provider directives. Cache freshness is separate from the game's end time. All redirects are rejected.
This branch includes a browser Stockfish experiment, separate from the S3 server workflow. With dependencies installed and local PostgreSQL/Redis running:
make browser-experimentOpen http://127.0.0.1:5175/?engine=browser, find/open a game and select Browser Quick review. The full pinned Stockfish 17.1 engine runs in a Web Worker on your device. The first full-engine download is approximately 70 MiB; later starts use browser caching. Use Deepen selected move for more work on one position. Cancellation retains locally cached positions for resume. A lightweight API on port 8001 validates legal variations against imported history; this experiment still needs that API and is not an offline application.
Results remain provisional personal evidence; they do not populate the trusted server analysis cache or receive server-verified badges. Screening uses smaller node budgets than S3 Deep. Closing the tab stops computation. A two-thread cap is available with browser isolation support; otherwise use the single-thread fallback. Hardware/browser quality and performance gates remain open.
The original Docker stack on http://127.0.0.1:5173 is left intact for comparison.
The experiment's ?engine=server view requires a matching native worker; use the
original stack to compare its existing Linux workers. See the
experiment evidence for measured results,
the reproduced Quick defect and limitations. This is not an S4 implementation
or a production rollout.
make migrate applies Alembic revision 0002. Revision 0001 creates pending provider records
and canonical game versions; unchanged PGN imports reuse a version. Row locks
serialize imports, and an import rejects a provider update that raced validation.
PGN text/hash, metadata, starting FEN, SAN/UCI, and every resulting position are
stored. Comments remain data and are excluded from the position sequence.
Revision 0002 adds analysis jobs, dispatch/recovery state and per-ply evidence.
After stopping API and workers, uv run --frozen alembic downgrade 0001 removes
only analysis data; imported games remain. Reapply with make migrate.
Back up the database before rollback, for example using your PostgreSQL backup
process. Stop API writers, then run uv run --frozen alembic downgrade base only
when intentionally removing the Sprint 1 tables and their imported games.
Restore a backup to recover those games, or rerun make migrate and discover and
import them again from public archives. The integration gate verifies upgrade,
rollback, and reapply in a disposable database; it never rolls back your app data.
Automated retention/purge and broader backup/restore proof remain Sprint 7 work.
| Command | Checks |
|---|---|
make migrate |
Apply versioned PostgreSQL schema |
make contracts |
Export FastAPI OpenAPI and regenerate TypeScript types |
make contracts-check |
Regenerate contracts and reject unstaged drift |
make check |
Ruff, formatting, mypy, TypeScript, ESLint, function-length limits |
make test-unit |
Deterministic Python and TypeScript tests for implemented behaviour |
make test-future |
S7 executable specifications; failing until S7 is built |
make engine-install |
Install/verify the pinned engine with license and provenance |
make test-integration |
Disposable PostgreSQL, real Redis, pinned engine, lifecycle/recovery |
make test-e2e |
Fixture-backed browser shell at five viewport sizes |
make build |
Python source/wheel and frontend production bundle |
make verify-required |
Contracts, checks, unit, integration and build; must pass |
make verify-pending |
test-future and test-e2e; known-open gates |
make verify |
Both of the above; stays red until the pending gates close |
Browser tests use port 5174 so they can run alongside the app on port 5173.
The GitHub Actions workflow runs verify-required plus Compose build/startup as
the blocking job, and verify-pending as a separate non-blocking job so open
gates stay visible without blocking merges.
Local success does not mean hosted CI has run.
Stop the local stack with make down; volumes are retained. Deleting volumes
with docker compose down --volumes removes local data and should be deliberate.
All application endpoints use /api/v1. The authoritative contract is
OpenAPI; FastAPI serves interactive docs at /docs.
| Method | Endpoint | Purpose |
|---|---|---|
| GET | /api/v1/health/live, /api/v1/health/ready |
Process and dependency health |
| GET | /api/v1/players/{username}/archives |
Public archive months |
| GET | /api/v1/players/{username}/games |
Monthly games; requires year and month |
| GET | /api/v1/games/{game_id} |
Validate/import and retrieve a discovered public game |
| POST | /api/v1/analyses |
Start bounded Quick/Deep analysis |
| GET | /api/v1/analyses/{analysis_id} |
Read analysis evidence and progress |
| POST | /api/v1/analyses/{analysis_id}/cancel |
Owner-only cancellation |
| POST | /api/v1/games/{game_id}/sandbox |
Stateless legal branch and local-PV validation; signed session/origin required |
| POST | /api/v1/games/{game_id}/browser-evidence |
Experimental legal-line validation; scores remain untrusted |
Analysis submission/cancellation and browser-evidence POSTs require an exact configured Origin. Analysis submission also requires a signed session-cookie roundtrip; cancellation checks ownership. Public game records are public data. Inputs are validated at API, provider, and chess-domain boundaries; external text is rendered through React text escaping. The server constructs allowlisted Chess.com URLs and rejects redirects.
Keep credentials in ignored .env files or server environment variables. Never
put secrets in VITE_* variables, source, fixtures, URLs, or Git remotes. The
checked-in .env.example contains local development placeholders. Git ignore
rules do not remove secrets already committed; rotate exposed credentials and
handle history remediation separately if an exposure is found. Production
proxy/security headers, abuse testing, retention, and release checks remain S7
gates. See the audit record for the actual review scope.
Application source: GPL-3.0-or-later; see LICENSE and dependency notices. Stockfish artifact checksums and source provenance are in the engine manifest. Engine binaries, models, archives, secrets, and runtime data stay outside Git.
This project is not affiliated with Chess.com. Its analysis and move-label rules are independent. Optional provider accuracy values are not used as its own score.