Relay is an elegant tool for replaying and analyzing bughouse games from chess.com. It loads both boards of a bughouse match (the “partner” game), merges the moves into a single timeline, and gives you a powerful two-board UI for drops, variations, live replay, and fast navigation.
- Paste a chess.com live game ID (e.g.
159878252255) - Or open a link directly:
https://bughouse.aronteh.com/?gameId=159878252255 - Open shared games: Use
?sharedId=<uuid>to open games shared by other users - Sample games: When visiting without a game ID, Relay suggests a random sample game to explore
- Partner board auto-detection
- If chess.com provides
partnerGameId, Relay uses it. - Otherwise, Relay probes nearby IDs to find the paired board.
- If chess.com provides
- Two synchronized boards (A and B) side-by-side.
- Merged move timeline ordered by timestamp so you can step through the match as it actually unfolded (including simultaneous-move quirks).
- Clocks shown per player (as provided by chess.com), synchronized to the current position.
- Clock advantage visualization: See time differences between teams with color-coded indicators
- Material tracking: Track signed capture totals. The default Bughouse preset uses pawn=1.5, knight/bishop=3, rook=4, queen=7; Settings also offers Standard values (1, 3, 3, 5, 9). Captured promoted pieces count as pawns.
- Chess title badges: Player titles (GM, IM, FM, etc.) are displayed next to usernames
- Live replay mode: play the match back in (approximate) real time using the original timestamps, with play/pause + seeking.
- Make moves directly on the board (drag-and-drop).
- Bughouse drops
- Click a reserve piece to “arm” a drop, then click a target square.
- Or drag reserve pieces onto the board.
- Promotion picker: when a move needs promotion, Relay asks you to pick a piece.
- Reserves update correctly: captures on one board feed the partner’s reserve.
- Branching analysis tree: explore alternative lines from any position.
- Variation selector: when a node has multiple continuations, stepping forward can open a selector.
- Move list with inline variations: a 4-column layout (A/B × white/black) with side lines shown under the relevant move.
- Tools
- Promote variation (make a side line the mainline)
- Delete from here (truncate continuations)
- Board annotations: add highlights/arrows to help reason about lines.
- Keyboard navigation
- Left/Right: back/forward
- Up/Down: jump to start/end of the current line
- f: flip boards
- Live replay intentionally disables most editing/navigation so playback stays stable.
- Toasts: clear feedback for load states, illegal moves, promotions, etc.
- Responsive layout: boards resize to fit available width; reserves support a compact density mode.
If you're playing a bughouse match consisting of multiple consecutive games, Relay can help you discover and step through subsequent games with the same four players and the same team pairings (rate-limited to be gentle to chess.com).
- Match discovery: Scans monthly archives for nearby games, bounded by time gaps and archive availability. Choose the same four-player match or one partner pair playing against changing opponents; results may be incomplete.
- Match score tracking: See wins, losses, and draws across the match
- Board orientation: Automatically maintains correct board orientation as teams swap colors
- Navigation controls: Jump between games in a match with forward/backward navigation
- Share games and matches: Share individual games or entire matches with other users
- Shared games browser: Browse all shared games at
/shared-games - Advanced filtering: Filter shared games by player names (supports team-aware filtering)
- Descriptions: Add optional descriptions (up to 100 characters) when sharing
- Profanity filtering: Automatic filtering of inappropriate content in descriptions
- Share links: Each shared game gets a unique URL that can be shared directly
- Google sign-in: Authenticate with your Google account to unlock sharing features
- Username reservation: Reserve a unique username (one-time, cannot be changed later)
- Profile page: Manage your account and view your shared games
- Settings: Customize your experience
- Board annotation color: Choose your preferred color for board highlights and arrows
- Piece values: Choose Bughouse or Standard capture-material scoring
- Live replay auto-advance: Continue to the next discovered match game
- Cross-device sync: Preferences sync across devices for authenticated users
- Local storage fallback: Non-authenticated users can still save preferences locally
- Installable: Add Relay to your home screen for a native app-like experience
- Landscape preference: The manifest requests landscape orientation for Android phone user agents; enforcement depends on the browser/install mode
- Network requirements: Replay and analysis use in-memory game state once loaded. There is no service worker or guaranteed offline reload; fetching games, remote artwork, sharing, and account operations still need a connection.
- Bookmarklet: one-click bookmark to open the current game in Relay (see
user_scripts/bookmarklet.md) - TamperMonkey: adds "Ellipviewer" buttons to bughouse games in chess.com
game history (see
user_scripts/ellipviewer_installation.md)
- Next.js (App Router) + React + TypeScript
- Tailwind CSS for styling
- chess.js for rules/legality and FEN state
- chessboard.js (with jQuery) for board rendering
- Vitest for unit tests + Cypress Component Testing for UI components
For detailed contracts and maintenance workflows, see the architecture guide, development guide, and data and service guide.
-
Opening-explorer production trial:
app/opening-explorer/page.tsx,app/components/opening-explorer/. This is a separate one-board surface and does not share viewer replay, analysis, move-tree, or URL state. -
Player Insights:
app/player-insights/page.tsx,app/components/player-insights/, and the checked static projection atapp/data/player-*.json. This route has no runtime data API. -
Core bughouse rules / move application:
app/utils/analysis/applyMove.ts -
Analysis tree + navigation + promotions/variations:
app/components/moves/useAnalysisState.ts -
Clock simulation + live replay primitives:
app/utils/analysis/buildBughouseClockTimeline.ts,app/utils/analysis/liveReplay.ts -
Move ordering + chess.com ingestion:
app/utils/board/moveOrdering.ts,app/chesscom_movelist_parse.ts -
Replay controller (imperative stepping + undo):
app/utils/replay/replayController.ts -
Main UI:
app/components/viewer/GameViewerPage.tsx,app/components/viewer/BughouseAnalysis.tsx -
Shared games:
app/utils/shared-games/sharedGamesService.ts,app/shared-games/SharedGamesPageClient.tsx -
User preferences:
app/utils/preferences/userPreferencesService.ts,app/components/modals/SettingsModal.tsx -
Authentication:
app/auth/AuthProvider.tsx,app/auth/useAuth.ts -
Username service:
app/utils/preferences/usernameService.ts -
Match discovery:
app/utils/discovery/matchDiscovery.ts,app/components/match/MatchNavigation.tsx
The opening explorer remains isolated from the two-board viewer and is now
available as a production trial at
/opening-explorer. It reads
only bounded, versioned responses through a same-origin proxy; the browser never
loads the packed artifact or receives the service credential.
For local development, run two processes: the Python loopback reader from the
sibling bughouse-opening-explorer repository, then this Next.js app pointed at
that service.
- Start the opening service (from
bughouse-opening-explorer):
cd ~/Desktop/Coding_Adventures/bughouse-opening-explorer PYTHONPATH=. .venv/bin/python -m bughouse_explorer.opening.service artifacts/opening/full-position-graph-through-202608-v2 --port 8765
Replace the second argument with whatever artifact you want to build the tree
on; keep --port 8765 unless you also change OPENING_EXPLORER_SERVICE_URL
below.
- Start this application (from
bughouse-chess):
cd ~/Desktop/Coding_Adventures/bughouse/bughouse-chess OPENING_EXPLORER_SERVICE_URL=http://127.0.0.1:8765 \ npm run dev
Visit /opening-explorer or use the Opening explorer sidebar icon. Route,
sidebar, and proxy are always available in local, Preview, and Production
builds; no availability feature flag is required.
The local Python reader is a separate process; npm run dev does not start it.
If the reader is absent, the always-present page shows a bounded unavailable
state and the proxy returns 503. On first visit the browser requests metadata,
then one root or deep-link neighborhood capped at 500 nodes/256 KiB by default;
it does not download or initialize the packed artifact in browser memory.
The hosted service origin, exact origin allowlist, timeout, and bearer token are
server-only OPENING_EXPLORER_SERVICE_* variables. Never expose them through a
NEXT_PUBLIC_* variable. Unknown proxy operations return not-found behavior;
unavailable upstream services return a bounded 503 response.
Production metadata checked on 3 October 2026 reports the August position graph:
6,747,980 games, dataset 68a97678c3df093d243473e0844b373d669ac335, in
packed-position-graph-v2 format; that dated production observation was not
rechecked during this local update. The validated local October-only incremental
candidate contains 7,019,712 games, dataset
dbcc296735e87541e82e1f2cdac06a5c17e61174, and 3,526,334,311 bytes including
its v2 manifest. It passed the routine incremental integrity/delta/regression and
local behavior gates. Independent full A/B comparisons were intentionally
cancelled under the revised workflow; no full-rebuild parity is claimed.
Current evidence is recorded in
OPENING_INCREMENTAL_RESULT_2026-11-02.md.
The page now emits low-cardinality browser performance marks and the proxy adds
its upstream duration to Server-Timing. A local candidate does not
change the served dataset; upload, protected Preview and Production cutover remain
separate approval gates. The server-side proxy defaults to 45 seconds, with a
60-second maximum; an explicit deployment override may be shorter.
Possible next moves are ordered by descending game support and use White-win,
draw, and Black-win bars. Use Up/Down to select a continuation, Right to play
it, and Left to return along the cached played line. At desktop widths the board
expands beside a dedicated played-line move list; the far-right controls stack
the player filter, possible next moves, and instrumentation. The filter accepts
one corpus-backed player and a White/Black seat choice; autocomplete remains
visible while typing, and Apply stays disabled until the input exactly matches
an indexed username. A game ending at the current state appears as an
unclickable - row. A continuation supported by exactly one game becomes a
link to that source game in Relay's Bughouse
analysis board and shows both players plus the result; keyboard navigation
deliberately stops at that boundary. The analysis link opens in a new tab. The
packed graph retains moves through the last shared placement plus one move (or
the actual game end). Source links use bounded
edge-game metadata requests. The earlier bounded multi-game inspection panel is
intentionally omitted from the user-facing UI.
/player-insights is an isolated, searchable host for insights about the
permanently tracked player cohort. Its first two chips show lifetime net
material and net material per analyzed game. The page follows the user's
Bughouse or Standard piece-value preference. Its Net and individual piece
columns are click-to-sort controls: the first click ranks the most won, and a
second click reverses toward the most lost. The Games column follows the same
interaction for the number of analyzed games. In the per-game view, each
piece's won, lost, and net figures use the same analyzed-game denominator as
the overall score.
The third chip, Average King Height, shows how far each player's king reaches from its own back rank. Every player card includes a nullable weighted average and an eight-bucket probability chart. Average King Height and Touchdowns are separate sort toggles; activating the selected metric again reverses its direction. An expandable, scroll-contained panel opens every public game in which the player's king reached the opposite back rank in Relay's Bughouse analysis board; the UI calls these rare games touchdowns. These links open in a new tab. The minimum-games filter defaults to 1000 and accepts only non-negative integers. White and Black directions are normalized before aggregation, and players with no analyzed games show an em dash and remain last in average-height sorting when the minimum is cleared. Desktop rows reserve a fixed-height, internally scrolling touchdown area so expansion does not move the surrounding leaderboard; mobile cards continue to expand naturally. Small mobile layouts hide both explanatory paragraphs and use tighter header, navigation, search, sort, and filter spacing so the first player arrives earlier.
The fourth chip, Piece Drop Heat Maps, shows where each player places
reserve pawns, knights, bishops, rooks, and queens. Combined reflects only
Black's ranks so both colours advance upward from their own back rank while the
a through h files retain their chess meaning. White and Black expose
their exact, unnormalized source-square distributions. Individual-player
comparisons use colour-specific analyzed game counts. Both single-colour modes
are drawn from White's perspective, with rank 8 at the top.
With no selection, one All tracked players row sums the existing permanent cohort colour channels by piece and square, with five compact boards in one row. Its header uses the dataset-level analyzed-game count rather than summing player counts. A searchable multi-select with removable chips replaces that aggregate with a piecewise player comparison: piece types form columns and chosen players stack top-to-bottom within each column. The comparison becomes an internal horizontal scroller on narrow screens, so the page itself stays viewport-width. Every occupied square shows both its count and its percentage of that row's drops of the active piece, with the same exact values in accessible labels and hover text. Boards in the cohort and single-player galleries have a 248-pixel minimum width, grow evenly, wrap into centered rows, and stack into one centered column on narrow screens. Multi-player comparisons retain their piece-column layout and scroll horizontally when the container is narrower than the five-column table. Secondary orientation copy is hidden on mobile to keep the filters compact.
The fifth chip, Material Game Highs, shows each player's three greatest positive or negative single-game net material results. Most won and Most lost use the same signed captured-minus-lost calculation as the first two material insights. Bughouse and Standard values have independently precomputed top-three sets, so changing the piece-value preference never rescans a game history in the browser. Captured promoted pawns count as pawns.
Players are ranked by their first qualifying game in the selected direction; search, a non-negative minimum-games filter, and pagination preserve those global ranks. Every retained game has its signed result, date, player colour, and a static final position using the analysis board's square palette and piece artwork. The board is oriented for that player and disables all moves and annotations. Each card links to the game in Relay. Desktop rows show three equal boards; phone rows keep 272-pixel cards in an internal horizontal scroller so the page itself does not overflow.
Each Player Insights chip has a stable shareable query value:
| Insight | URL parameter |
|---|---|
| Net Material | ?insight=net-material |
| Net Material per Game | ?insight=net-material-per-game |
| Average King Height | ?insight=average-king-height |
| Piece Drop Heat Maps | ?insight=piece-drop-heatmaps |
| Material Game Highs | ?insight=material-game-highs |
Opening one of these URLs selects that insight after hydration. Switching chips
updates the insight value in place while preserving other query parameters
and the URL fragment. A missing or unknown value falls back to Net Material.
The route remains statically prerendered and no insight data is fetched again.
The route imports app/data/player-material-insights.json at build time. The
current 1,170-player file is 223,633 bytes uncompressed and 60,427 bytes with
deterministic gzip -9 -n. The lazy-loaded projections are 875,320 bytes raw /
152,968 bytes gzipped for king height, 2,087,933 / 648,779 bytes for drop heat
maps, and 2,543,982 / 445,266 bytes for material game highs. None is part of the
initial material view. The browser needs no
SQLite reader, runtime database, route handler, or opening-explorer service
request. Material rows use a full desktop table and compact five-piece ledgers
on smaller screens; king height uses a purpose-built responsive card chart;
drop maps use semantic CSS checkerboards; game highs use static analysis-style
final boards.
The source of truth remains the checked Player Insights SQLite artifact in the
sibling bughouse-opening-explorer repository. After building and validating a
future database, refresh this tracked frontend projection from that repository
with its recorded checksum:
.venv/bin/python scripts/run_monthly_refresh.py \ --frontend-data-dir ../bughouse/bughouse-chess/app/data \ --publish
That first-of-month command updates Chess.com acquisition, creates a checked immutable snapshot, rebuilds all registered insights once, double-exports their projections, and validates the full set before replacing any file here. It does not deploy. For a manual single-projection recovery from an already verified artifact, use the lower-level exporters:
.venv/bin/python scripts/export_player_insights.py \ artifacts/insights/<snapshot>/player-insights.db \ ../bughouse/bughouse-chess/app/data/player-material-insights.json \ --database-sha256 <player-insights-db-sha256> \ --replace .venv/bin/python scripts/export_king_height_insights.py \ artifacts/insights/<snapshot>/player-insights.db \ ../bughouse/bughouse-chess/app/data/player-king-height-insights.json \ --database-sha256 <player-insights-db-sha256> \ --replace .venv/bin/python scripts/export_drop_heatmap_insights.py \ artifacts/insights/<snapshot>/player-insights.db \ ../bughouse/bughouse-chess/app/data/player-drop-heatmap-insights.json \ --database-sha256 <player-insights-db-sha256> \ --replace .venv/bin/python scripts/export_material_game_highs.py \ artifacts/insights/<snapshot>/player-insights.db \ ../bughouse/bughouse-chess/app/data/player-material-game-highs.json \ --database-sha256 <player-insights-db-sha256> \ --replace
The exporters read the database immutably, validate each projection's row shape and invariants, and atomically replace the static JSON. Review the JSON metadata and checksums, then run this repository's tests, lint, build, and production-build browser checks before publication.
The sibling data repository owns the durable contract for adding other insight
shapes and refreshing them from later snapshots. See its
Player Insights development guide
and
reusable session prompt.
Relay supports:
- Firestore Admin SDK for the global game-load metric, server-rendered shared game summaries, social previews, and maintenance scripts
- Firestore Web SDK for browser shared-game reads/writes, private preferences, username reservations, and each user's shared-game index
- Firebase Analytics (Web SDK) for basic interaction tracking (e.g. "Load Game" clicks)
- Firebase Authentication for Google sign-in
Privacy design:
- The browser talks directly to Firestore for sharing, profiles, and preferences;
these operations are governed by the checked-in
firestore.rules. - The app uses server routes (e.g.,
/api/metrics/game-load) which increment/read counters stored at Firestore documentmetrics/global. - The metric is intentionally anonymous and low-cardinality (no per-game IDs stored). Its GET and POST routes are public; POST validates the body but does not verify an authentication or App Check token.
- Shared games are public and can be viewed by anyone, but only authenticated users with a reserved username can create them.
- User preferences are private and only accessible by the user who created them.
- Create a Firebase project
- Enable Firestore (Native mode)
- Enable Firebase Analytics for your web app (Project settings → Integrations → Google Analytics)
- Create a Service Account and copy the JSON credentials
- Register your web app in Firebase Console (Project settings → General → Your apps → Add app → Web)
- Set these environment variables (recommended in
.env.local):
Server-side (Firestore Admin SDK):
FIREBASE_PROJECT_ID="your-project-id" FIREBASE_CLIENT_EMAIL="[email protected]" # Important: keep the quotes and use \\n for newlines FIREBASE_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\\n...\\n-----END PRIVATE KEY-----\\n"
Client-side (Auth + Firestore, with optional Analytics and App Check):
NEXT_PUBLIC_FIREBASE_API_KEY="your-api-key" NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN="your-project-id.firebaseapp.com" NEXT_PUBLIC_FIREBASE_PROJECT_ID="your-project-id" NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET="your-project-id.appspot.com" NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID="123456789012" NEXT_PUBLIC_FIREBASE_APP_ID="1:123456789012:web:abcdef123456" NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID="G-XXXXXXXXXX" NEXT_PUBLIC_FIREBASE_APPCHECK_SITE_KEY="your-recaptcha-v3-site-key"
Deploy the checked-in firestore.rules for browser-backed features. Deny-all
rules would disable sharing, username reservation, and preference sync. Admin
SDK reads/writes bypass rules, so successful server reads do not establish that
browser access is configured correctly.
Relay keeps Firestore index definitions in firestore.indexes.json so indexes
can be deployed alongside rules with the Firebase CLI:
firebase deploy --only firestore:indexes
Relay supports Google sign-in via Firebase Authentication. When enabled, users can sign in to unlock authenticated features like sharing games and syncing preferences across devices.
Setup steps:
- In Firebase Console, go to Authentication → Sign-in method → Google and enable it.
- Set a support email for the Google provider.
- Go to Authentication → Settings → Authorized domains and add:
localhost(for local development)- Your production domain (e.g.
bughouse.aronteh.com)
- Ensure your web app is registered (Project settings → General → Your apps →
Web) and your
.env.localcontains theNEXT_PUBLIC_FIREBASE_*values listed above.
No additional environment variables are needed — Firebase Auth uses the same
client-side config (NEXT_PUBLIC_FIREBASE_*) already required for Analytics.
The authentication UI is accessible via the Profile button in the left sidebar. Users can sign in with Google popup and sign out from the profile page.
When using Firebase features, Relay creates the following Firestore structure:
metrics/global- Global game load counter (server-only access)sharedGames/{sharedId}- Public shared games collectionsharedGames/{sharedId}/games/{index}- Game data subcollection
users/{userId}/userPreferences/settings- User preferences (private)users/{userId}/sharedGames/{sharedId}- User's shared games indexusernames/{username}- Username reservation registry
See firestore.rules for security rules that enforce privacy and access
control.
npm ci npm run dev
Open http://localhost:3000. Use Node.js 22.12+ (or a compatible newer LTS)
for the current dependency set. The basic viewer needs no Firebase credentials;
account features require the configuration above. See the
development guide for emulator tests and optional services.
npm run lint: TypeScript check + ESLintnpm run format: ESLint auto-fixnpm run test:unit: Vitest unit tests oncenpm run test:component: Cypress component tests headlesslynpm run test:e2e: Cypress browser flows with owned demo emulators and Next.jsnpm run test:all: unit, component, and end-to-end suitesnpm run build/npm start: production build and local production servernpm run fixtures:record -- <gameId>: record chess.com fixtures for testsnpm run fixtures:record:match -- <gameId>: record a discovered match
Fixture recording accesses live Chess.com and rewrites fixture files. Database migration commands and their dry-run behavior are documented in the data and service guide.
- Unit tests (Vitest) cover deterministic domain logic (move rules, clock simulation, parsing).
- Component tests (Cypress) cover UI components like promotion selection, variation selection, move tree rendering, and reserve interactions.
- End-to-end tests (Cypress) cover game loading, authentication, sharing,
settings, and previews with recorded Chess.com responses and Firebase emulators.
See
tests/env/README.mdfor environment isolation.
Contributions are welcome — especially around:
- bughouse edge cases / legality correctness
- UI/UX polish and accessibility
- performance improvements for large games
- more fixtures + regression tests for tricky chess.com payloads
If you’re adding new domain logic, prefer pure functions in app/utils/** and
accompany them with unit tests under tests/unit/**.
Game links (?gameId=..., including legacy gameid) and saved shares
(?sharedId=...) expose a 1200 × 630 PNG through /api/social-preview in their
server-rendered Open Graph and Twitter metadata. The existing share URLs work
without changes:
ply=N: both boards after N moves in the combined timeline (0 is the initial position).- No
ply: the final position; saved matches and partner series use their first stored game. - Homepage, unavailable games, missing partner boards, or replay failures: the Relay artwork.
The renderer reuses the replay engine and bundled board artwork. Direct links read Chess.com; saved shares read only their public parent document and first indexed game using the existing Firebase Admin configuration. No database migration or image-storage service is required. Source reads revalidate after five minutes; rendered images can be cached by the CDN for one hour. Social platforms also cache previews independently, so previously posted links may retain their old thumbnail.
Deploy the changes through the normal release process, then verify a new game,
position, and match link in the target social app. Ensure NEXT_PUBLIC_SITE_URL
points to the public deployment and the existing Firebase Admin variables are
configured. Local fixture tests do not establish live Discord or Firebase success.