How lichess-org/lila works
Lila is the Scala server behind Lichess, a realtime online chess service. A player enters through HTTP routes to create or join a game; game state and records are handled by the game domain, while live connections use the separately hosted WebSocket service. Analysis is a distinct follow-on capability, with distributed engine work supplied by fishnet. The map also retains the README’s major community, learning, competition, and API capabilities. README documents the external architecture; source excerpts sampled here are limited, so uncertain module-to-module wiring is omitted.
Main entry points: LilaController.scala HTTP routes · controllers/Game.scala Game routes · main/Game.scala Game domain · GameRepo.scala Game records
Components 28
Web entry
- Lila server
app/Lila.scala - HTTP routes
app/controllers/LilaController.scala - Server views
app/views/round/player.scala
Chess play
- Game routes
app/controllers/Game.scala - Game domain
modules/game/src/main/Game.scala - Game records
modules/game/src/main/GameRepo.scala - PGN encoding
modules/game/src/main/PgnStorage.scala - Live rounds
app/controllers/Round.scala - WebSocket service
- Challenges
modules/challenge/src/main/ChallengeApi.scala - Lobby
modules/api/src/main/LobbyApi.scala
Analysis
- Analysis routes
app/controllers/Analyse.scala - Computer analysis
modules/analyse/src/main/Analyser.scala - Fishnet workers
modules/fishnet/src/main/FishnetApi.scala - Fishnet cluster
Community and learning
- Shared studies
app/controllers/Study.scala - Tournaments
app/controllers/Tournament.scala - Simultaneous games
app/controllers/Simul.scala - Forums
modules/forum/src/main/ForumTopicApi.scala - Teams
app/controllers/Team.scala - Tactic trainer
app/controllers/Puzzle.scala - Learning
app/controllers/Learn.scala
Data and APIs
- Redis
- Public API
modules/api/src/main/GameApi.scala - MongoDB
- Game search
modules/api/src/main/AnySearch.scala - Elasticsearch
Other components
- Player
Connections 28
- Player → HTTP routes: sends requests
- Lila server → HTTP routes: serves routes
- HTTP routes → Game routes: dispatches
- Game routes → Game domain: handles games
- Game domain → Game records: reads and writes
- Game records → MongoDB: stores records
- Game domain → PGN encoding: encodes moves
- Player → Live rounds: plays live
- Live rounds → WebSocket service: uses live sockets
- WebSocket service → Redis: communicates through
- Game routes → Challenges: manages challenges
- Player → Lobby: browses games
- Player → Analysis routes: requests analysis
- Analysis routes → Computer analysis: serves analysis
- Computer analysis → Fishnet workers: dispatches engine work
- Fishnet workers → Fishnet cluster: requests computation
- Player → Shared studies: shares analysis
- Player → Tournaments: enters competition
- Player → Simultaneous games: joins simul
- Player → Forums: posts discussions
- Player → Teams: uses teams
- Player → Tactic trainer: trains tactics
- Player → Learning: learns chess
- Player → Public API: accesses API
- Public API → MongoDB: reads game data
- Player → Game search: searches games
- Game search → Elasticsearch: queries index
- HTTP routes → Server views: renders pages