How lichess-org/chessground works
Chessground is a browser-based chessboard UI library, not a chess-rules engine. The main workflow is an application creating a board, then using its API and browser interactions to change position or draw annotations; the library updates and animates the DOM and exposes callbacks. The graph also preserves documented FEN, premove, styling, and piece-rendering capabilities. Some links rely on the SOURCE INDEX’s import/reference lists rather than full excerpts; unsampled implementation details are not inferred.
Main entry points: board.ts Board operations · chessground.ts Board factory · api.ts Board API · state.ts Board state
Components 21
Board setup
- Board factory
src/chessground.ts - Board API
src/api.ts - DOM wrapper
src/wrap.ts
Board interaction
- Input events
src/events.ts - Drag handling
src/drag.ts - Drop handling
src/drop.ts - Board operations
src/board.ts - Premoves
src/premove.ts - Shape drawing
src/draw.ts
Rendering and display
- Shape synchronization
src/sync.ts - SVG shapes
src/svg.ts - Auto pieces
src/autoPieces.ts - DOM renderer
src/render.ts - Piece animation
src/anim.ts - Board and piece styles
assets
Position and state
- Board state
src/state.ts - Configuration
src/config.ts - FEN conversion
src/fen.ts - Piece glyphs
src/glyph.ts - Shared types
src/types.ts
Other components
- Application user
Connections 31
- Application user → Board factory: creates board
README.md - Board factory → Board API: creates API
src/chessground.ts - Board factory → Input events: binds input
src/chessground.ts - Board factory → DOM renderer: sets rendering
src/chessground.ts - Board factory → DOM wrapper: wraps board
src/chessground.ts - Board factory → Board state: creates state
src/chessground.ts - Board API → Configuration: configures
src/api.ts - Board API → Board operations: mutates position
src/api.ts - Board API → FEN conversion: exports FEN
src/api.ts - Board API → Piece animation: animates changes
src/api.ts - Board API → Board state: exposes state
src/api.ts - Input events → Drag handling: dispatches drag
src/events.ts - Input events → Shape drawing: dispatches drawing
src/events.ts - Input events → Drop handling: dispatches drop
src/events.ts - Drag handling → Board operations: uses board ops
src/drag.ts - Drop handling → Board operations: uses board ops
src/drop.ts - Board operations → Premoves: computes premoves
src/board.ts - Shape drawing → Board operations: maps pointer
src/draw.ts - Shape synchronization → Shape drawing: reads shapes
src/sync.ts - SVG shapes → Shape drawing: renders shapes
src/svg.ts - Auto pieces → Board operations: reads position
src/autoPieces.ts - Auto pieces → Shape drawing: uses auto shapes
src/autoPieces.ts - Auto pieces → Shape synchronization: synchronizes
src/autoPieces.ts - DOM renderer → Piece animation: reads animation
src/render.ts - DOM renderer → Board operations: uses orientation
src/render.ts - DOM renderer → Board state: renders state
src/render.ts - DOM wrapper → Board state: uses state
src/wrap.ts - DOM wrapper → SVG shapes: manages SVG
src/wrap.ts - Board state → FEN conversion: loads position
src/state.ts - Configuration → Board state: configures state
src/config.ts - Application user → Board and piece styles: selects styles
README.md