A polished, native cross-platform chess game built with Flutter for the UI
and Rust for the engine + AI, connected through
flutter_rust_bridge.
| Path | Contents |
|---|---|
crates/chess_core/ |
Platform-agnostic Rust core: api, engine, ai, clock, pgn, session, commands. |
crates/chess_core/src/platform.rs |
Trait seams (AppDirs, EventSink, StockfishSpawner) every embedding implements. |
crates/chess_bridge/ |
flutter_rust_bridge crate. Exposes 15 commands + a single BackendEvent stream. |
crates/chess_bridge/binaries/ |
Stockfish desktop sidecars (gitignored). Populated by scripts/fetch-stockfish.sh. |
flutter/ |
Flutter app (lib/main.dart, controllers, board widget, modals, audio synth). |
flutter/lib/src/rust/ |
Auto-generated Dart bindings (do not hand-edit; regenerated by flutter_rust_bridge_codegen generate). |
flutter_rust_bridge.yaml |
Codegen config. |
scripts/fetch-stockfish.sh |
Download Stockfish 17 desktop binaries into crates/chess_bridge/binaries/. |
scripts/build-stockfish-android.sh |
Cross-compile Stockfish 17 for arm64-v8a / armv7 / x86_64 with the Android NDK. |
rustup, stable channel).PATH.ANDROID_NDK_ROOT).# Regenerate Dart bindings whenever you edit crates/chess_bridge/src/api.rs.
flutter_rust_bridge_codegen generate
# Run the headless workspace tests (engine, AI, session, trait seams).
cargo test --workspace
# Static analysis + Dart unit tests.
cd flutter
flutter pub get
flutter analyze
flutter test
cd flutter
flutter run -d macos # or windows / linux / <ios sim> / <android emulator>
Flutter automatically invokes the Xcode build phase (flutter/macos/Runner/Scripts/build_rust.sh)
which compiles crates/chess_bridge and embeds it into the .app bundle.
| Platform | Levels 1-3 | Levels 4-10 |
|---|---|---|
| macOS desktop | Custom Rust engine | Stockfish 17 sidecar (scripts/fetch-stockfish.sh) |
| Windows desktop | Custom Rust engine | Stockfish 17 sidecar |
| Linux desktop | Custom Rust engine | Stockfish 17 sidecar |
| Android | Custom Rust engine | Stockfish 17 (NDK source-built; scripts/build-stockfish-android.sh) |
| iOS | Custom Rust engine | Custom Rust engine (sandbox forbids spawning child processes) |
When Stockfish is unavailable for any reason — missing binary, failed spawn,
running on iOS — chess_core::ai::stockfish::choose_move transparently falls
back to the strongest custom-engine tier (fallback_custom_level in
crates/chess_core/src/ai/difficulty.rs). The user sees a slightly weaker
opponent at high levels, never an error.
bash scripts/fetch-stockfish.sh
This downloads official Stockfish 17 builds into crates/chess_bridge/binaries/
(gitignored). The macOS Xcode build phase picks them up automatically.
export ANDROID_NDK_ROOT=$HOME/Android/Sdk/ndk/26.1.10909125
bash scripts/build-stockfish-android.sh
This drops three binaries into flutter/assets/stockfish/<abi>/stockfish,
which Flutter bundles as part of flutter build apk. If you skip this step,
the Android build still works; AI levels 4-10 just use the custom Rust engine.
15 commands + a single BackendEvent broadcast stream. They live in
crates/chess_core/src/api.rs and are exposed to Dart as:
bridgeInit(dataDir) once at startup.Future<...> commands (newGame, makeMove, …, setSettings).subscribeEvents() returning Stream<BackendEvent> carrying
BackendEvent.moveMade, BackendEvent.aiProgress,
BackendEvent.gameOver, BackendEvent.clockTick.cargo test --workspace # Rust unit + integration tests
flutter test # Dart tests
CI runs both jobs plus a Linux desktop smoke build on every push and pull
request. See .github/workflows/ci.yml.