user@gryczka.dev: ~/garden/cloudflare-chess
$ cat ~/garden/cloudflare-chess/README.md
Cloudflare Chess — Edge-Native Multiplayer Chess screenshot

Cloudflare Chess — Edge-Native Multiplayer Chess

July 1, 2026 | Patrick Gryczka

## Overview

An edge-native chess platform with no origin server. One ChessMatch Durable Object per game holds the authoritative board, clocks, chat, and presence over WebSocket Hibernation, while two global-singleton Durable Objects — Matchmaker and GameLobby — handle pairing and spectator-TV coordination. Player profiles and Elo history live in D1 for cross-player queries (leaderboards, per-time-control ratings), R2 stores immutable PGN/JSON game archives, a Queue drives async Workers AI post-game coaching (via AI Gateway), and Browser Run screenshots the final board for social-preview recap images. An opening explorer indexes every archived game's positions into D1 for move-frequency and win-rate lookups from any position.

## Highlights

  • -> One ChessMatch Durable Object per game — authoritative board, clocks, chat, and presence over WebSocket Hibernation
  • -> Global-singleton Matchmaker + GameLobby Durable Objects for pairing and live spectator TV
  • -> D1-backed Elo ratings (per-time-control) and an opening explorer indexed from archived games
  • -> Async Workers AI post-game coaching via a Queue + AI Gateway, with recap images via Browser Run
  • -> Anonymous signed-cookie identity (HMAC-SHA256) with a one-time recovery secret, never stored in plaintext

## Architecture

Cloudflare Chess architecture diagram
Browser (WebSocket + HTTP)
    ▼
Cloudflare Worker (Astro SSR)
    ├── ChessMatch DO (one per game)
    │       ├── SQLite: board, moves, clocks, chat
    │       ├── WebSocket Hibernation (players + spectators)
    │       └── Alarm: clock enforcement, archival retries
    ├── Matchmaker DO (global singleton) ── queue + pairings → D1 profiles/ratings
    ├── GameLobby DO (global singleton) ─── active games → spectator TV
    ├── R2 ── immutable PGN + JSON archives, AI coaching output
    ├── KV ── leaderboard cache
    └── Queue → Workers AI (via AI Gateway) → D1 opening explorer
                                            → Browser Run (recap image)

## Tech Stack

WorkersDurable ObjectsD1R2KVQueuesWorkers AIBrowser RunWebSocketsAstroTypeScript
$ _