Sudoku
A touch-optimized Sudoku web application with multiple solver implementations, built with Rust compiled to WebAssembly and a TypeScript React frontend.
Features
- Multiple Sudoku grid sizes (4x4, 9x9, 16x16, 25x25)
- Three solver implementations
- strategic solver using human-like deduction strategies (naked singles, hidden singles, X-Wing, etc.)
- SAT-based solver using
varisatfor larger grids - backtracking solver adapted from
tdoku
- Puzzle generator
- Generates puzzles based on the strategies required to solve it
- Multi-shot generation: generate multiple puzzles in parallel, optimizing for a grid metric
- Touch-optimized input with normal and sticky edit modes
- Puzzle import/export via clipboard
- Light and dark theme
- Offline-capable PWA with service worker support
- Published on Google Play using
bubblewrap
Technical notes
Architecture
- Rust core library (
sudoku-rs): generic over grid size using a compile-timeBaseparameter, enabling monomorphized solver code for each supported size- Extensive test suite: 600+ tests achieving >80% coverage
- Performance focus:
- benchmark suite using
criterion - encapsulated
unsafeusage for hot paths - verified by running test suite with
miri
- benchmark suite using
- WebAssembly bridge (
sudoku-wasm): exposes the Rust library viawasm-bindgenwith multi-threaded support throughwasm-bindgen-rayon - Web Worker offloading: expensive WASM computation runs in a web worker via
comlink, keeping the UI responsive during generation and solving- Optimized Web Worker communication using
postcardencoded binary data passed between main thread and worker usingComlink.transfer()
- Optimized Web Worker communication using
Languages
- Rust
- Edition 2024
- nightly channel enabling multi-threaded WASM
- TypeScript
Libraries
Rust:
varisatfor SAT solving, forked for WASM compatibility- Varisat is not actively maintained, but in 2024 was the fastest Rust-only SAT solver with a permissive license. This project targets
wasm32-unknown-unknown, which complicates cross-language linking.
- Varisat is not actively maintained, but in 2024 was the fastest Rust-only SAT solver with a permissive license. This project targets
rayonfor parallel puzzle generationserdefor (de)serialization in conjunction withserde-wasm-bindgenandpostcardts-rsfor generating TypeScript types from Rust structs, enabling end-to-end type safetywasm-bindgen,wasm-packandwasm-bindgen-rayon
Web:
- React with Material UI
- Jotai for state management
- Vite as build tool
- Vitest for browser testing and benchmarking
Deployment
- Caddy container serving the static Vite build
- COOP/COEP security headers enabling
SharedArrayBufferfor multi-threaded WASM
- COOP/COEP security headers enabling
- CI/CD via GitHub Actions
- Deployed to self-managed Coolify instance running on Hetzner Cloud