A chess engine application with three different bot difficulty levels and a React-based frontend interface.
- Backend: FastAPI-based REST API with three chess engines
- Frontend: React + Vite with chess.js and react-chessboard
- Bot V1: Simple alpha-beta pruning engine
- Bot V2: Enhanced with iterative deepening, transposition tables, and late move reduction
- Bot VIP: Advanced engine with static exchange evaluation, aspiration windows, and pawn hash tables
docker-compose up -dServices will be available at:
- Backend API: http://localhost:8000/docs
- Frontend: http://localhost:5000
- Create production environment file:
cp .env.prod.example .env.prod- Configure environment variables in
.env.prod:
# Docker Hub credentials
DOCKERHUB_USERNAME=your_dockerhub_username
# Frontend API URL - IMPORTANT!
# Use relative path /api for nginx reverse proxy setup
VITE_API_URL=/api
# Or use full URL if not using reverse proxy:
# VITE_API_URL=https://your-domain.com/api- Build images with production config:
# Use the build script (recommended)
./scripts/build-prod.sh
# Or manually with docker-compose
docker-compose -f docker-compose.prod.yml build
# Or build directly with docker
docker build --build-arg VITE_API_URL=/api -t username/chess-bot-frontend:latest ./Frontend- Deploy: ./scripts/deploy.sh
> **Note**: `VITE_API_URL` is a build-time variable for Vite. If you change it, you must rebuild the frontend image.
### Stop Services
```bash
docker-compose down
docker-compose logs -f- Navigate to Backend folder:
cd Backend- Install dependencies:
pip install -r requirements.txt- Run the server:
uvicorn main:app --reload --host 0.0.0.0 --port 8000API documentation: http://localhost:8000/docs
- Navigate to Frontend folder:
cd Frontend- Setup environment variables:
cp .env.example .envEdit .env to configure API URL:
VITE_API_URL=http://localhost:8000
- Install dependencies:
5pm install- Run development server:
npm run devApplication: http://localhost:5173
- Build for production:
npm run buildPOST /api/v1/best-move
POST /api/v2/best-move
POST /api/vip/best-move
Request body:
{
"fen": "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",
"depth": 4
}Response:
{
"move": "e2e4",
"eval": 0.5
}Backend:
cd Backend
pytestFrontend:
cd Frontend
npm run lint- FastAPI
- python-chess
- uvicorn
- numpy
- pydantic-settings
- React 19
- Vite
- chess.js
- react-chessboard
- axios
- Backend: Python 3.11-slim based (approximately 150-200MB)
- Frontend: Multi-stage Nginx Alpine based (approximately 25-35MB)
This project includes automated CI/CD pipeline for deploying to Google Cloud Platform.
- Docker Hub: Create account and access token
- GCP VM: Setup Ubuntu VM with Docker installed
- GitHub Secrets: Configure deployment secrets
- Nginx: Setup reverse proxy on GCP
- Deploy: Push to GitHub β Auto deploy!
- CI/CD Quick Start - 10-step setup guide
- Complete Deployment Guide - Detailed documentation with monitoring and troubleshooting
Pipeline automatically:
- β Builds Docker images
- β Pushes to Docker Hub with version tags
- β Deploys to GCP via SSH
- β Runs health checks
Triggers on:
- Push to
mainorprodbranch - Manual workflow dispatch
| Secret | Description |
|---|---|
DOCKERHUB_USERNAME |
Docker Hub username |
DOCKERHUB_TOKEN |
Docker Hub access token |
GCP_HOST |
GCP VM public IP |
GCP_USERNAME |
SSH username |
GCP_SSH_KEY |
SSH private key |
After deployment, access your application:
- Frontend:
http://YOUR_GCP_IP/ - API Docs:
http://YOUR_GCP_IP/docs - API Endpoint:
http://YOUR_GCP_IP/api/
[Add your license here]