Skip to content
case file #003

2026 · Author

Alekhine's Counter-Gambit

A distributed chess platform: play Stockfish or a friend live, with moves validated, streamed, analysed and observed on Kubernetes.

Shipped

Problem

why this exists

Playing chess online looks simple; the platform behind it is a full tour of distributed systems — authoritative rules on the server, live move streaming, compute-heavy analysis that never blocks play, clocks, ratings that update exactly once.

Architecture

napkin sketch, cleaned up
  1. Web clientWebSockets
  2. GatewayGraphQL
  3. Game serviceGo + Erlang
  4. Engine workersStockfish
  5. Kafkapost-game analysis

Independently scalable services over gRPC and a Kafka event bus, with durable storage, live WebSocket fan-out, full metrics and traces, and a GitOps pipeline onto Kubernetes.

Technical decisions

and the trade-offs
  • Never trust the client

    Rules are enforced authoritatively on the server.

  • Asynchronous analysis

    Finished games are analysed by a Kafka-fed worker pool so engine work never blocks play.

Screenshots

taped in
  • Alekhine's Counter-Gambit: Playing StockfishPlaying Stockfish
  • Alekhine's Counter-Gambit: Post-game analysisPost-game analysis
  • Alekhine's Counter-Gambit: Grafana under loadGrafana under load
  • Alekhine's Counter-Gambit: One move across three servicesOne move across three services

Key engineering challenges

the bruises
  1. 1

    Clocks and ratings

    Clocks must never flag-fall a decided game, and ratings must update exactly once.

  2. 2

    Observability

    A single move request is traced across gateway → game-service → engine-worker in Jaeger.

Results

  • ✔ Six services over gRPC and Kafka: gateway, game, session (Erlang/OTP), engine worker, analysis worker, spectator fan-out
  • ✔ Move generation verified by perft: 197,281 nodes to depth 4 from the start position
  • ✔ 17.6k lines, 118 tests and five architecture decision records
  • ✔ Runs on Kubernetes, reconciled from the repo by Argo CD

Learnings

  • ✎ One supervised Erlang process per game means killing a game never touches another.
  • ✎ Verify the move generator with perft before trusting anything built on top of it.