Lila is the backend codebase powering Lichess, a free, open-source online chess server with millions of users. The architecture handles real-time games, puzzles, tournaments, correspondence chess, streaming, and user profiles, scaling to thousands of simultaneous matches. The system uses functional programming principles (in Scala) to maintain reliability—state transitions, clock management, game rules, and move validation are deterministic, reducing synchronization errors. Lila also integrates rating systems (e.g. Glicko), puzzles generation, AI opponents, and cheat detection systems. A real-time socket layer (WebSocket) streams move updates, chat, and broadcast events, while REST APIs support client and bot integrations. Supporting features like database schema migrations, analytics, moderation tools, and backups are woven into the platform so the community can contribute and host clubs/variants (Chess960, King of the Hill, etc.).