An open API service indexing awesome lists of open source software.

https://github.com/arunsai63/chess-engine-rust


https://github.com/arunsai63/chess-engine-rust

Last synced: about 2 months ago
JSON representation

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)

![image](https://github.com/user-attachments/assets/37197b96-b6d9-4f5b-b375-3683b48ba2e0)

## πŸš€ 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 styling

The 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
β€’ Vite

Steps

# 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