A multi-variant poker game engine and REST API server written in Rust.
rust-poker implements a multi-variant poker game engine as a backend with a RESTful API. It supports Texas Hold'em, Omaha, Omaha Hi-Lo, Five-Card Draw, and Seven-Card Stud β all in a single crate. Designed to be consumed by frontend applications (web, mobile, CLI) and serves as a demo/educational project showcasing Rust and its ecosystem.
Part of a family of poker implementations across languages (Rust, Go, TypeScript) sharing the same API contract.
- π 5 poker variants β Texas Hold'em, Omaha, Omaha Hi-Lo, Five-Card Draw, Seven-Card Stud
- π― Pure game engine β no I/O, fully testable
- π REST API with Axum
- π Hand evaluator β evaluates any combination of cards, supports Hi-Lo
- π° Side pot management β correct pot distribution for all-in scenarios
- π Full action history tracking
- π³ Docker support (< 15 MB image)
- β Comprehensive tests (unit + integration)
| Variant | Hole | Community | Betting | Players |
|---|---|---|---|---|
| Texas Hold'em | 2 | 5 | No Limit | 2β10 |
| Omaha | 4 | 5 | Pot Limit | 2β9 |
| Omaha Hi-Lo | 4 | 5 | Pot Limit | 2β9 |
| Five-Card Draw | 5 | 0 | Fixed Limit | 2β6 |
| Seven-Card Stud | 7 | 0 | Fixed Limit | 2β8 |
See docs/variants.md for detailed rules.
cargo run
# Server starts on http://localhost:8084# Create a Texas Hold'em game
curl -s -X POST http://localhost:8084/api/games \
-H 'Content-Type: application/json' \
-d '{"variant": "texas_holdem"}' | jq
# Join players
curl -s -X POST http://localhost:8084/api/games/{id}/join \
-H 'Content-Type: application/json' \
-d '{"name": "Alice", "chips": 1000}' | jq
curl -s -X POST http://localhost:8084/api/games/{id}/join \
-H 'Content-Type: application/json' \
-d '{"name": "Bob", "chips": 1000}' | jq
# Start the hand
curl -s -X POST http://localhost:8084/api/games/{id}/start | jq
# Submit an action
curl -s -X POST http://localhost:8084/api/games/{id}/action \
-H 'Content-Type: application/json' \
-d '{"player_id": "...", "action": "call"}' | jquse rumenx_poker::engine::game::Game;
use rumenx_poker::engine::types::PlayerAction;
use rumenx_poker::rules::texas_holdem;
let ruleset = texas_holdem::ruleset();
let mut game = Game::new(ruleset, 10, 20);
game.join("Alice", 1000).expect("should join");
game.join("Bob", 1000).expect("should join");
game.start_hand().expect("should deal");
println!("Phase: {}", game.phase());| Method | Endpoint | Description |
|---|---|---|
GET |
/health |
Health check |
GET |
/api/rulesets |
List poker variants |
POST |
/api/games |
Create new game |
GET |
/api/games |
List active games |
GET |
/api/games/{id} |
Get game state |
DELETE |
/api/games/{id} |
Delete game |
POST |
/api/games/{id}/join |
Join a game |
POST |
/api/games/{id}/leave |
Leave a game |
POST |
/api/games/{id}/start |
Start a hand |
POST |
/api/games/{id}/action |
Player action (fold/check/call/raise/all-in/discard) |
GET |
/api/games/{id}/player/{pid} |
Player-specific view |
GET |
/api/games/{id}/history |
Action history |
See docs/api-reference.md for full details.
| Document | Description |
|---|---|
| Hand Rankings | Complete hand ranking chart with tiebreakers |
| Variants | All 5 poker variants and their rules |
| Betting | Betting structures and round mechanics |
| API Reference | Full REST API documentation |
| Glossary | Poker terminology reference |
# Build
cargo build
# Run tests
cargo test
# Lint
cargo clippy --all-targets --all-features -- -D warnings
# Format
cargo fmt --all
# All checks (format + lint + test)
make check
# Coverage report
make coverage
# Run example
cargo run --example basic_game# Build image
docker build -t rust-poker .
# Run container
docker run -p 8084:8084 --rm rust-poker
# Check image size (target: < 15 MB)
docker images rust-poker| Variable | Default | Description |
|---|---|---|
PORT |
8084 |
Server port |
HOST |
0.0.0.0 |
Bind address |
RUST_LOG |
rumenx_poker=info |
Log level |
src/
βββ main.rs # Server entry point
βββ lib.rs # Library root
βββ config.rs # Environment configuration
βββ engine/ # Pure game logic (no I/O)
β βββ types.rs # Card, Rank, Suit, HandRank, GamePhase, etc.
β βββ deck.rs # 52-card deck with shuffle
β βββ evaluator.rs # Hand evaluation (5-card, best-of-N, Omaha, Hi-Lo)
β βββ player.rs # Player state and chip management
β βββ pot.rs # Main pot and side pot management
β βββ betting.rs # Betting round logic with structure validation
β βββ game.rs # Game state machine
βββ rules/ # Variant definitions
β βββ mod.rs # RuleSet struct, EvalMode, evaluate_hand
β βββ texas_holdem.rs
β βββ omaha.rs
β βββ omaha_hilo.rs
β βββ five_card_draw.rs
β βββ seven_card_stud.rs
βββ api/ # REST API layer
βββ router.rs # Route definitions
βββ handlers.rs # Endpoint handlers
βββ models.rs # JSON DTOs
βββ state.rs # Shared state
βββ errors.rs # Error types
This project is part of a multi-language poker family. Other implementations are planned:
| Language | Repository | Status |
|---|---|---|
| Rust | rust-poker | β v0.1.0 |
| Go | go-poker | π Planned |
| TypeScript | npm-poker | π Planned |
All implementations share the same REST API contract for interoperability.
Check out the other Rust game engines in this family:
| Project | Description | Links |
|---|---|---|
| rust-blackjack | Blackjack engine & API | GitHub Β· crates.io |
| rust-chess | Chess engine with AI | GitHub Β· crates.io |
| rust-sixtysix | Sixty-Six card game engine | GitHub Β· crates.io |
See CONTRIBUTING.md for guidelines.
See SECURITY.md for reporting vulnerabilities.