How gabriel-logan/stockfish works
Stockfish is a chess platform spanning a React client, a Rust multiplayer API, and a Go Stockfish engine server. Players can play computer games, analyze or study PGNs, save games, and play online. The principal online flow runs from the web client through API routes into room/game handling and live WebSocket coordination; the computer-play and PGN-analysis flows use the separate engine service. Source excerpts show some routing and engine communication, but not all client pages or engine handlers, so unsampled connections are omitted or marked unverified.
Main entry points: routes.rs HTTP and WS routes · games.rs Game rules and clocks · App.tsx Page routing · PlayOnline.tsx Online play
Components 24
Web client
- Page routing
web/src/App.tsx - Online play
web/src/pages/PlayOnline.tsx - PGN review
web/src/pages/PgnViewer.tsx - Chess board
web/src/components/Board.tsx - Review analysis
web/src/utils/pgnReview.ts - Engine client
web/src/utils/analysisEngine.ts - Opening data
web/src/data/openings.ts - API client
web/src/lib/apiInstance.ts - Auth state
web/src/store/authStore.ts
Multiplayer API
- HTTP and WS routes
api/crates/api-server/src/routes.rs - Authentication
api/crates/api-server/src/auth.rs - Rooms and matchmaking
api/crates/api-server/src/rooms.rs - Game rules and clocks
api/crates/api-server/src/games.rs - Live game sockets
api/crates/api-server/src/ws.rs - Live game hub
api/crates/api-server/src/hub.rs - Saved games
api/crates/api-server/src/saved_games.rs - User profile
api/crates/api-server/src/users.rs - API data models
api/crates/api-server/src/models.rs
Chess engine
- Engine server
engine/main.go - REST engine
engine/rest.go - Engine WebSocket
engine/ws.go - Stockfish process
engine/stockfish.go
Other components
- Player
- PostgreSQL
Connections 31
- Player → Page routing: uses
web/src/App.tsx - Page routing → Online play: routes to
web/src/App.tsx - Page routing → PGN review: routes to
web/src/App.tsx - Online play → API client: calls API
web/src/pages/PlayOnline.tsx - Online play → Chess board: renders
web/src/pages/PlayOnline.tsx - PGN review → Chess board: renders
web/src/pages/PgnViewer.tsx - PGN review → Review analysis: analyzes moves
web/src/pages/PgnViewer.tsx - Review analysis → Engine client: requests analysis
web/src/utils/pgnReview.ts - Review analysis → Opening data: looks up openings
web/src/utils/pgnReview.ts - Engine client → Engine WebSocket: sends analysis
web/src/utils/analysisEngine.ts - API client → Auth state: reads tokens
web/src/lib/apiInstance.ts - API client → HTTP and WS routes: sends requests
- HTTP and WS routes → Authentication: routes auth
api/crates/api-server/src/routes.rs - HTTP and WS routes → Rooms and matchmaking: routes rooms
api/crates/api-server/src/routes.rs - HTTP and WS routes → Game rules and clocks: routes games
api/crates/api-server/src/routes.rs - HTTP and WS routes → Live game sockets: routes sockets
api/crates/api-server/src/routes.rs - HTTP and WS routes → Saved games: routes saves
api/crates/api-server/src/routes.rs - HTTP and WS routes → User profile: routes profile
api/crates/api-server/src/routes.rs - Live game sockets → Live game hub: coordinates live play
api/crates/api-server/src/ws.rs - Live game sockets → Game rules and clocks: dispatches game actions
api/crates/api-server/src/ws.rs - Rooms and matchmaking → Game rules and clocks: starts games
api/crates/api-server/src/rooms.rs - Authentication → User profile: uses user records
api/crates/api-server/src/auth.rs - Authentication → PostgreSQL: reads and writes
api/crates/api-server/src/auth.rs - Rooms and matchmaking → PostgreSQL: reads and writes
api/crates/api-server/src/rooms.rs - Game rules and clocks → PostgreSQL: reads and writes
api/crates/api-server/src/games.rs - Saved games → PostgreSQL: stores saved games
api/crates/api-server/src/saved_games.rs - User profile → PostgreSQL: reads user data
api/crates/api-server/src/users.rs - Engine server → REST engine: serves REST
- Engine server → Engine WebSocket: serves WebSocket
- REST engine → Stockfish process: uses engine
- Engine WebSocket → Stockfish process: uses engine