Sudoku

Project preview

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 varisat for 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-time Base parameter, enabling monomorphized solver code for each supported size
    • Extensive test suite: 600+ tests achieving >80% coverage
    • Performance focus:
  • WebAssembly bridge (sudoku-wasm): exposes the Rust library via wasm-bindgen with multi-threaded support through wasm-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 postcard encoded binary data passed between main thread and worker using Comlink.transfer()

Languages

  • Rust
    • Edition 2024
    • nightly channel enabling multi-threaded WASM
  • TypeScript

Libraries

Rust:

  • varisat for 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.
  • rayon for parallel puzzle generation
  • serde for (de)serialization in conjunction with serde-wasm-bindgen and postcard
  • ts-rs for generating TypeScript types from Rust structs, enabling end-to-end type safety
  • wasm-bindgen, wasm-pack and wasm-bindgen-rayon

Web:

Deployment

  • Caddy container serving the static Vite build
    • COOP/COEP security headers enabling SharedArrayBuffer for multi-threaded WASM
  • CI/CD via GitHub Actions
  • Deployed to self-managed Coolify instance running on Hetzner Cloud