https://github.com/arunsai63/chess-engine-rust
https://github.com/arunsai63/chess-engine-rust
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/arunsai63/chess-engine-rust
- Owner: arunsai63
- License: mit
- Created: 2025-03-26T15:52:24.000Z (about 2 months ago)
- Default Branch: main
- Last Pushed: 2025-03-26T19:16:51.000Z (about 2 months ago)
- Last Synced: 2025-03-26T19:34:17.747Z (about 2 months ago)
- Language: TypeScript
- Size: 241 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# βοΈ Chess Engine in Rust + WebAssembly + React
Live Demo: [arunsai63.github.io/chess-engine-rust](https://arunsai63.github.io/chess-engine-rust)

## π Overview
This project is a full-stack chess game built with:
- π¦ **Rust** β for the core chess engine logic
- π **WebAssembly (WASM)** β to run high-performance Rust code in the browser
- βοΈ **React + Vite** β for a fast, modern UI
- π¨ **TailwindCSS** β for rapid, utility-first stylingThe goal was to create a performant, interactive chess game where the heavy-lifting game logic runs via compiled WebAssembly, bringing native-like speed to the browser.
## π§ Features
- Full chess rules engine implemented in **Rust**
- Compile-time optimized with **`wasm-pack`**
- Seamless integration with **React frontend** via WebAssembly bindings
- Interactive chessboard UI built with **React and TailwindCSS**
- **Stateless rendering** for a responsive and minimalistic UX
- Lightweight and extremely fast β thanks to **Rust + WASM**
- Deployed on **GitHub Pages** using Vite's static export## π¦ Tech Stack
| Layer | Technology |
|--------------|--------------------------|
| Game Engine | Rust |
| WASM Binding | `wasm-bindgen`, `wasm-pack` |
| Frontend | React (Vite) |
| Styling | TailwindCSS |
| Deployment | GitHub Pages |## π οΈ Rust Game Engine
The chess engine is written entirely in Rust, designed with:
- **Bitboard representation** for performance
- **Move generation** (legal moves, captures, castling, etc.)
- **Check/checkmate logic**
- **Board evaluation** (optional extension)It compiles to WebAssembly and exposes functions to JavaScript using `wasm-bindgen`.
### π§© Example Rust β JS Binding
```rust
#[wasm_bindgen]
pub fn generate_legal_moves(fen: &str) -> JsValue {
let board = Board::from_fen(fen).unwrap();
let moves = board.generate_moves();
JsValue::from_serde(&moves).unwrap()
}π₯οΈ React Frontend
The UI is built using React + TailwindCSS and communicates with the Rust engine via the WASM bindings.
β’ React hooks to manage state and game flow
β’ WASM functions are called via async JS
β’ Chessboard rendered with a simple grid system
β’ No external chess libraries β all logic is nativeπ Project Structure
chess-engine-rust/
βββ src/
β βββ engine/ # Rust chess engine (compiled to WASM)
β βββ web/ # React frontend with Vite
βββ pkg/ # WASM output package
βββ public/
βββ index.html
βββ README.mdπ§ͺ Running Locally
Prerequisites
β’ Rust
β’ wasm-pack
β’ Node.js + npm
β’ ViteSteps
# Build the Rust engine to WASM
cd src/engine
wasm-pack build --target web# Move to frontend
cd ../web
npm install
npm run devπ Deployment
Deployed using GitHub Pages via Viteβs static export.
npm run build
# Push the build directory to GitHub Pagesπ Why This Project?
This project demonstrates:
β’ Systems-level programming with Rust
β’ Real-world WASM integration into a frontend stack
β’ Building optimized web applications without bloated dependencies
β’ Clean UI/UX using Tailwind and React
β’ Deploying full Rust-to-React pipelines for modern web appsπΌ Ideal For
If youβre hiring for roles involving:
β’ Rust / WASM / Systems programming
β’ Frontend/backend web integration
β’ High-performance browser apps
β’ Cross-language architecture (Rust β JS)This project showcases end-to-end capability in building modern, high-performance web apps with low-level languages.
βΈ»
π« Letβs Connect!
If youβre interested in collaborating, hiring, or just chatting about systems programming, feel free to reach out via GitHub.
---
Let me know if you'd like a one-liner for your resume or LinkedIn too!
# Todo:
- en passant
- pawn promotion