MCPSERV.CLUB
Lichess

Lichess

Self-Hosted

Free, real‑time online chess for all skill levels

Active(100)
17.3kstars
0views
Updated 21 hours ago
Lichess screenshot 1
1 / 5

Overview

Discover what makes Lichess powerful

Lila is the core engine behind the open‑source chess platform lichess.org. Written in **Scala 3** and built atop the **Play 2.8** web framework, it delivers a fully asynchronous server that can handle millions of concurrent users while keeping latency low for real‑time gameplay. The architecture splits responsibilities across several micro‑services: the main HTTP server, a dedicated WebSocket gateway (`lila-ws`), and an AI cluster that runs Stockfish instances via the `fishnet` distributed engine. Communication between services is largely event‑driven and leverages **Akka Streams** for back‑pressure control, while transient state is stored in a Redis cluster to enable fast pub/sub and session persistence.

Language & Framework

Concurrency

Data Stores

AI Integration

Overview

Lila is the core engine behind the open‑source chess platform lichess.org. Written in Scala 3 and built atop the Play 2.8 web framework, it delivers a fully asynchronous server that can handle millions of concurrent users while keeping latency low for real‑time gameplay. The architecture splits responsibilities across several micro‑services: the main HTTP server, a dedicated WebSocket gateway (lila-ws), and an AI cluster that runs Stockfish instances via the fishnet distributed engine. Communication between services is largely event‑driven and leverages Akka Streams for back‑pressure control, while transient state is stored in a Redis cluster to enable fast pub/sub and session persistence.

Technical Stack

  • Language & Framework: Scala 3, Play 2.8 (MVC + JSON API), Scalatags for server‑side templating.
  • Concurrency: Scala Futures, Akka Streams, and Play’s async HTTP pipeline.
  • Data Stores: MongoDB (raw game records), Elasticsearch (full‑text search over millions of games), Redis (pub/sub, WebSocket session state).
  • AI Integration: Stockfish binaries orchestrated by the fishnet cluster; communication via gRPC‑style sockets.
  • Client Side: TypeScript + Snabbdom for virtual DOM diffing, Sass for CSS preprocessing.
  • Testing & CI: BrowserStack for cross‑browser testing, IP2Proxy database for proxy detection.

Core Capabilities

  • REST & WebSocket APIs: Expose game creation, move streams, tournament standings, and user data. Endpoints are versioned (/api/v3/...) and support JSON‑only payloads, making them ideal for mobile or third‑party clients.
  • Event Bus: Internal lila-event bus publishes domain events (e.g., GameFinished, UserRated) that can be subscribed to by plugins or external services via Redis streams.
  • Plugin System: Lila exposes a lightweight plugin API; developers can register custom handlers for game events, add new REST endpoints, or hook into the search index. The plugin repository is documented in docs/plugins.md.
  • Webhooks: External services can subscribe to user or game events via configurable webhooks, enabling real‑time integrations (e.g., Discord bots, analytics dashboards).

Deployment & Infrastructure

Lila is container‑friendly: the source repository includes Dockerfiles for both the HTTP server and WebSocket gateway. A typical production stack uses:

  1. Docker Compose or Kubernetes manifests (see deploy/k8s/).
  2. Nginx as a reverse proxy for HTTPS termination and HTTP caching.
  3. Redis Cluster (≥ 3 nodes) for session storage and pub/sub.
  4. MongoDB Replica Set (≥ 3 nodes) for durability of game records.
  5. Elasticsearch Cluster for search indexing, optionally sharded by user or game type.

Horizontal scaling is straightforward: new HTTP workers can be spun up behind the load balancer, while WebSocket nodes handle real‑time traffic via Redis pub/sub. The AI cluster is entirely decoupled; any machine with a CPU can join fishnet, allowing community‑driven scaling.

Integration & Extensibility

  • SDKs: A minimal Scala client library (lila-client) is available for building custom bots or analytics tools.
  • GraphQL Support: While not yet fully featured, the platform is gradually adopting GraphQL for flexible data retrieval.
  • Custom Themes & UI: The TypeScript front‑end is modular; developers can fork the ui repo, replace components, or add new widgets that communicate via the existing WebSocket protocol.
  • Community Plugins: The ecosystem includes a handful of community plugins (e.g., lichess-puzzle‑generator, lichess-bot‑framework) that demonstrate the extensibility model.

Developer Experience

  • Documentation: Comprehensive API docs (docs/api.md), architecture guide (docs/architecture.md), and a dev‑setup tutorial in the README.
  • Community: Active Discord channel, GitHub discussions, and a dedicated issue tracker for plugin development.
  • Licensing: MIT license for the core server, allowing commercial use without copyleft obligations.
  • Testing: Unit tests written in ScalaTest and integration tests orchestrated via Docker Compose; continuous integration runs on GitHub Actions.

Use Cases

  1. Self‑hosted Chess Server: Small clubs or schools can deploy Lila to provide a private, ad‑free chess environment.
  2. Custom Bot Development: Using the WebSocket API and fishnet, developers can build sophisticated chess engines or training bots.
  3. Analytics Platform: Pull game data via the REST API, index it in Elasticsearch, and build dashboards for player performance or tournament statistics.
  4. Educational Tools: Integrate Lila’s tactical trainer into e‑learning platforms, exposing the training API to students.

Advantages

  • Performance: Scala’s type safety combined with Play’s async I/O yields low‑latency, high‑throughput handling of game streams.
  • Flexibility: The plugin architecture and event bus allow developers to inject custom logic without touching the core codebase.
  • Scalability: Decoupled services (HTTP, WS, AI) and use of Redis/MongoDB/Elasticsearch

Open SourceReady to get started?

Join the community and start self-hosting Lichess today

Weekly Views

Loading...
Support Us
Most Popular

Infrastructure Supporter

$5/month

Keep our servers running and help us maintain the best directory for developers

Repository Health

Loading health data...

Information

Category
other
License
AGPL-3.0
Stars
17.3k
Technical Specs
Pricing
Open Source
Database
MongoDB
Supported OS
Linux
Author
lichess-org
lichess-org
Last Updated
21 hours ago