A full-stack poker simulation system with a Python web interface and high-performance C++ API backend.
This monorepo contains:
- Website: Python Flask web server with modern UI for poker simulations
- API: Pure C++ API server for fast game state simulations
┌─────────────────┐
│ Web Browser │
└────────┬────────┘
│ HTTP
▼
┌─────────────────┐
│ Python Flask │ Port 5000
│ Web Server │
└────────┬────────┘
│ HTTP
▼
┌─────────────────┐
│ C++ API │ Port 8080
│ Server │
└─────────────────┘
The Python website serves the user interface and proxies requests to the C++ backend, which handles the computational work of simulating poker game states.
cd api
make
./poker_apiYou should see: 🚀 C++ API Server started on http://localhost:8080
In a new terminal:
cd website
uv venv # Create virtual environment
uv pip install -r requirements.txt # Install dependencies
source .venv/bin/activate # On Windows: .venv\Scripts\activate
python app.pyDon't have uv? Install it first:
curl -LsSf https://astral.sh/uv/install.sh | shYou should see: Running on http://0.0.0.0:5000
Navigate to http://localhost:5000 in your browser and start simulating!
pokersim/
├── README.md # This file
├── website/ # Python Flask web server
│ ├── app.py # Flask application
│ ├── requirements.txt # Python dependencies
│ ├── templates/
│ │ └── index.html # Web UI
│ └── README.md # Website documentation
└── api/ # C++ API server
├── main.cpp # Server implementation
├── CMakeLists.txt # CMake configuration
├── Makefile # Make configuration
└── README.md # API documentation
- ✅ RESTful API for game state simulation
- ✅ Deterministic simulation with seeded RNG
- ✅ Modern, responsive web interface
- ✅ JSON-based communication
- ✅ CORS support for development
- ✅ Error handling and validation
- 🎯 Implement full poker game rules
- 🎯 Add multi-player support
- 🎯 Track hand histories
- 🎯 Calculate win probabilities
- 🎯 Add AI opponents
- 🎯 Visualization of game progression
- Open
http://localhost:5000 - Enter a game state:
{"players": 2, "pot": 100, "cards": ["AS", "KD"]} - Enter a seed:
42 - Click "Simulate Next State"
curl -X POST http://localhost:8080/simulate \
-H "Content-Type: application/json" \
-d '{
"gameState": {
"players": 2,
"pot": 100,
"cards": ["AS", "KD"]
},
"seed": 42
}'Response:
{
"success": true,
"nextGameState": {
"players": 2,
"pot": 130,
"cards": ["AS", "KD", "QH"],
"lastAction": "bet",
"lastBetAmount": 30,
"simulated": true,
"timestamp": 1700000000
}
}- Python 3.8+
- uv (fast Python package manager)
- C++ compiler with C++17 support
- Make or CMake 3.10+
cd website
FLASK_ENV=development python app.pycd api
make clean && make
./poker_apiPORT: Web server port (default: 5000)API_HOST: C++ API hostname (default: localhost)API_PORT: C++ API port (default: 8080)
Example:
PORT=3000 API_HOST=localhost API_PORT=8080 python app.pyPass port as command line argument:
./poker_api 9000The current implementation includes basic example logic. To implement real poker rules:
- Edit
api/main.cpp→GameSimulator::simulateNextState() - Add your poker game logic:
- Hand evaluation
- Betting rounds
- Card dealing
- Winner determination
- Rebuild the API server
- Update the website UI as needed
cd api
# Build and run
make && ./poker_api &
# Test endpoint
curl -X POST http://localhost:8080/simulate \
-H "Content-Type: application/json" \
-d '{"gameState": {"pot": 100}, "seed": 42}'cd website
python app.py &
curl http://localhost:5000- Ensure both servers are running
- Check ports aren't already in use
- Verify environment variables are set correctly
- Verify C++17 compiler support:
g++ --version(need 7.0+) - The first build downloads dependencies (requires internet)
- Activate virtual environment if using one
- Install dependencies:
uv pip install -r requirements.txt
The C++ backend provides:
- Sub-millisecond response times for simulations
- Efficient memory usage
- Deterministic results with seeded RNG
When extending this project:
- Keep the website and API loosely coupled
- Use JSON for all communication
- Add error handling for edge cases
- Update documentation as you add features
This project is provided as-is for poker simulation purposes.
- Implement Poker Rules: Add real poker game logic to
api/main.cpp - Enhance UI: Add visualizations for cards, chips, and players
- Add Database: Store hand histories and statistics
- Implement AI: Add computer opponents with different strategies
- Add Authentication: Support multiple users and sessions
- Deploy: Containerize with Docker for easy deployment
Happy simulating! 🃏