Skip to content
CheckoraPublic

About

Chess platform with an AI opponent powered by minimax search with alpha-beta pruning, built on Django and a C++ engine. Discord: https://discord.gg/ymvGzP5NBu

Resources

Code of conduct

Contributing

Security policy

Stars

139 stars

Watchers

3 watching

Forks

Latest commit

Β 

History

2,377 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Checkora

An open-source chess platform with an AI opponent powered by minimax search with alpha-beta pruning.

Built on Django with a high-performance C++ engine and a Python fallback for maximum compatibility.

Python Django C++ License: MIT CI/CD Pipeline Issues PRs Welcome Discord

The Checkora landing page, with a 3D chess board beside the headline

Join our Discord community for updates, support, and games: https://discord.gg/DvW3xVXw8g

Core Maintainers

EDWARD-012
@EDWARD-012
Follow EDWARD-012
triemerge
@triemerge
Follow triemerge

Click a profile or follow badge for release drops, roadmap notes, and engine updates.


Contributors

0rbiT-ai2005rishabhANISHA-RAWATAdityaM-IITHAshvin-KSBistNaveenSinghCodeMaster11000DebasmitaBose0DeepeshKafalatiyaEDWARD-012EnKruptosFTS18Gurkaran18Harsh2865HarshMrigankKhushi-VerseKinara2020KrishKyadaLakshayg136MahalaxmiKannanManthan29-codeMouni-SanaboyinaNakshathra-2808NayansiDupareNihal-ioNiranjanRSoorej06OmanshiRajPRODHOSHPooja-V4Pranav-0440Pranava116Pum14Rajal-uiRuchiSheoranRuhanikaChotwaniSakina-786-viSaptadeepMondalSara-ThakurSecureAditiShashank-8pShrishagkSiRa111Siddh2024Siddharth-sdeSilverMenaceSoumipal56SrashtiChauhanSreekuttan-007Steel-roger-moondradevUjsGitVITianYash42Vaishnav-Hub9Xenon010101YASHcode-IIITVYashKrTripathiYashisinghal285Yogender-vermaaayushbamalakash3911akashgoudsidduluriakhilmodi29akshatsinghai6682-sketchamarpratapsingh2452amm-09aniketchauhan16ankitasahu83964anshiikaa001anshul23102anwitamishraartiverma-00ash1shkumarasnaassalambh462007bhatiakavishachekr-maxcozyneuronsdebugger1711deepsikha-dashdhhhhruvdiptipradeepdivya-d510enoshdevgowthamrdyyharsh-kr9harshitkr13hetbharodiyaitsdakshjainjancysenjayesh-durgekartik12421kavin553khushi-in-techkrishkhinchikush-mehra1manish354200manurajgoelmaria-453mikotomisakaa2mishtiagrawal02-cloudmittalsonalnayana888ksnipundeeptnishtha-agarwal-211niy-atiniyatijoshi707nkc-ghparthc6416parthpatidar03pratyuxxhhradhikaa188rajat552rajatsurana19renganathcrichachauhan15rmagdaleena2508-01roneet0916saswatdutta1310shauryaparth1902-blipshreyamahesh07-gitshrutip04shrutisharma-shshubhamjrd4559-sudosom996somu0571soniya28guptasreevyaraosricharan-213ssuyashhhhsujithputta02sureshsuriyatazmeen24tharunika-19the404packettriemergeunnati-jaiswal24vikrantkulkarni07vishwassinfinityyuvraj-k-singhzqleslie

Features

Feature Description
AI Opponent Minimax search with alpha-beta pruning, at four levels from easy to master
Hybrid Engine C++ binary for maximum speed with an automatic Python fallback
Full Move Validation Legal moves enforced for all pieces including castling, en passant, and promotion
Game Timer Per-player countdown clocks with pause support
Material Score Panel Live material advantage tracking that updates dynamically during gameplay
REST API Clean JSON endpoints powering a decoupled frontend
PvP & PvE Modes Play against a friend or challenge the AI
Accounts Email sign-up or "Continue with Google", a settings page, and a profile picture (a piece or an upload)
Rating and progress An Elo rating against the engine level played, ranks from Pawn to King, points, levels and streaks

Documentation


Quick Start

# 1. Clone the repository
git clone https://github.com/Checkora/Checkora.git
cd Checkora

# 2. Set up a virtual environment
python -m venv venv
venv\Scripts\activate        # Windows
source venv/bin/activate     # macOS / Linux

# Note: Django 6.0 requires Python 3.12 or higher. If you have multiple
# versions on Windows, use a compatible installed version, e.g.:
# py -3.12 -m venv venv

# 3. Install dependencies
pip install -r requirements.txt

# 4. Set up environment variables
# Copy example env file
# Windows (PowerShell)
copy .env.example .env

# macOS / Linux
cp .env.example .env

# Open `.env` and set SECRET_KEY if needed
# Keep the DEBUG=True line that .env.example ships with: DEBUG is off unless .env turns it on
# Configure EMAIL_HOST_USER and EMAIL_HOST_PASSWORD for OTP and password reset emails
# Optional: GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET turn on "Continue with Google" (see .env.example)
# 5. Run migrations and start the server
python manage.py migrate
python manage.py runserver

Open http://127.0.0.1:8000/ in your browser. This is the landing page; the board is at /play/. The terminal shows this same address β€” always use http://, never https://, because the development server does not support SSL.

Compile the C++ Engine (optional but recommended)

The compiled binary is not committed to the repository. Each contributor compiles for their own platform. If the binary is absent, Checkora automatically falls back to the Python engine.

# Windows
g++ -O2 -std=c++17 game/engine/main.cpp -o game/engine/main.exe

# macOS / Linux
g++ -O2 -std=c++17 game/engine/main.cpp -o game/engine/main

Run the same command again after every pull that changes game/engine/main.cpp. A binary built from older sources is detected (it does not answer the protocol version the bridge asks for), and the Python engine plays until the binary is rebuilt.

Project Structure

Checkora follows a modular project structure to separate the frontend, backend, engine logic, and documentation clearly.

The tree below shows the main directories and files with a line on each. It does not list every file:

Checkora/
β”œβ”€β”€ .github/                       # GitHub configurations
β”‚   β”œβ”€β”€ ISSUE_TEMPLATE/            # Issue blueprints for contributors
β”‚   β”‚   β”œβ”€β”€ bug_report.md          # Form for reporting software bugs
β”‚   β”‚   └── feature_request.md     # Form for proposing feature improvements
β”‚   β”œβ”€β”€ workflows/                 # CI/CD automation pipelines
β”‚   β”‚   β”œβ”€β”€ ci.yml                 # Main test and lint automation workflow
β”‚   β”‚   β”œβ”€β”€ contributors.yml       # Automatically maintains the contributor catalog in README
β”‚   β”‚   └── label-gssoc.yml        # Automatically labels issues for GSSoC contributors
β”‚   └── PULL_REQUEST_TEMPLATE.md   # PR template establishing code quality requirements
β”œβ”€β”€ api/                           # Serverless API configurations
β”‚   └── wsgi.py                    # Vercel-specific WSGI application configuration
β”œβ”€β”€ core/                          # Django project core configuration
β”‚   β”œβ”€β”€ __init__.py                # Package initialization marker
β”‚   β”œβ”€β”€ asgi.py                    # Entry point for ASGI-compatible web servers
β”‚   β”œβ”€β”€ settings.py                # Global settings (DB config, middleware, security headers)
β”‚   β”œβ”€β”€ urls.py                    # Root URL router mapping to views
β”‚   └── wsgi.py                    # Entry point for WSGI-compatible web servers
β”œβ”€β”€ docs/                          # Detailed architecture guides
β”‚   β”œβ”€β”€ images/                    # Images used by the README, FEATURES.md and structure.md
β”‚   β”œβ”€β”€ API.md                     # Raw technical spec for REST API endpoints
β”‚   β”œβ”€β”€ SECURITY_HEADERS_AUDIT.md  # Deep security analysis and policy audit reports
β”‚   β”œβ”€β”€ design-system.md           # Base template, CSS tokens and components for building pages
β”‚   β”œβ”€β”€ development.md             # Local setup and everyday commands
β”‚   β”œβ”€β”€ engine_architecture.md     # Detailed minimax and communication workflow analysis
β”‚   β”œβ”€β”€ frontend-guide.md          # What each JavaScript module does
β”‚   └── testing.md                 # Where the tests are and how to run them
β”œβ”€β”€ game/                          # Core Chess application module
β”‚   β”œβ”€β”€ engine/                    # The AI Chess engine directory
β”‚   β”‚   β”œβ”€β”€ main.cpp               # High-performance C++17 Minimax + Alpha-Beta pruning engine
β”‚   β”‚   β”œβ”€β”€ main.py                # Pure Python 3.12 fallback replica of the C++ engine
β”‚   β”‚   β”œβ”€β”€ opening_book.json      # Structured dictionary mapping classic opening moves
β”‚   β”‚   └── persistent_server.py   # Keeps one engine process running per game
β”‚   β”œβ”€β”€ migrations/                # Database schema version histories
β”‚   β”‚   β”œβ”€β”€ 0001_initial.py        # Relational schema for GameResult and Profiles
β”‚   β”‚   β”œβ”€β”€ 0002_add_missing...   # Database schema patch adding draw reason records
β”‚   β”‚   β”œβ”€β”€ 0003_alter_game...     # Migration establishing foreign key user associations
β”‚   β”‚   β”œβ”€β”€ 0004_gameresult...     # Migration adding active game player color records
β”‚   β”‚   β”œβ”€β”€ ...                    # Later migrations, in order
β”‚   β”‚   β”œβ”€β”€ 0044_rated_games...    # Adds GameResult.rated, PuzzleStats.last_daily_date and the PuzzleSolve table
β”‚   β”‚   β”œβ”€β”€ 0045_seed_achiev...    # Creates the Achievement rows that game/services.py unlocks
β”‚   β”‚   β”œβ”€β”€ 0046_fix_seed_pu...    # Replaces the seven built-in daily puzzles with valid mates in one
β”‚   β”‚   β”œβ”€β”€ 0047_google_account.py # Adds the GoogleAccount table
β”‚   β”‚   β”œβ”€β”€ 0048_profiles_rat...   # Picture preset, upload time, time zone and rename date on UserProfile, best day streak, RatingHistory.game_result
β”‚   β”‚   └── __init__.py            # Package initialization marker
β”‚   β”œβ”€β”€ selenium_tests/            # UI browser integration tests
β”‚   β”‚   β”œβ”€β”€ __init__.py            # Package initialization marker
β”‚   β”‚   β”œβ”€β”€ base.py                # Setup, teardown, and WebDriver helpers for integration runs
β”‚   β”‚   β”œβ”€β”€ test_boards.py         # Automated UI click-and-drag gameplay flow tests
β”‚   β”‚   └── test_navigation.py     # Automated browser routing and navigation validation tests
β”‚   β”œβ”€β”€ static/                    # Frontend client-side resources
β”‚   β”‚   └── game/                  # Main namespace directory
β”‚   β”‚       β”œβ”€β”€ css/               # Modular stylesheet templates
β”‚   β”‚       β”‚   β”œβ”€β”€ app.css        # Design system: tokens, both themes, shared components, toasts
β”‚   β”‚       β”‚   β”œβ”€β”€ account.css    # Sign-in, registration, password reset, profile, picture, settings and account deletion pages
β”‚   β”‚       β”‚   β”œβ”€β”€ community.css  # Forum, leaderboard, achievements, stats and match history
β”‚   β”‚       β”‚   β”œβ”€β”€ cursor.css     # Custom cursor styles
β”‚   β”‚       β”‚   β”œβ”€β”€ error.css      # 404 and 500 pages
β”‚   β”‚       β”‚   β”œβ”€β”€ landing.css    # Landing page
β”‚   β”‚       β”‚   β”œβ”€β”€ learn.css      # Lessons, puzzles, opening trainer and rules pages
β”‚   β”‚       β”‚   └── play.css       # Play page: setup, the board, both side panels and the dialogs
β”‚   β”‚       β”œβ”€β”€ js/                # Client-side dynamic scripts
β”‚   β”‚       β”‚   β”œβ”€β”€ app.js         # Shared behaviour loaded on every page: navbar, menus, dialogs, reveals
β”‚   β”‚       β”‚   β”œβ”€β”€ auth.js        # Validates dynamic auth form submissions
β”‚   β”‚       β”‚   β”œβ”€β”€ board.js       # Chess grid events, capture drawers, API calls, clock tickers
β”‚   β”‚       β”‚   β”œβ”€β”€ perf.js        # Chooses the performance tier (high or low) before the first paint
β”‚   β”‚       β”‚   β”œβ”€β”€ play_view.js   # Board theme, 3D view and setup screen of the play page
β”‚   β”‚       β”‚   β”œβ”€β”€ scene3d.js     # three.js scenes: the landing page board and the turning piece
β”‚   β”‚       β”‚   β”œβ”€β”€ toast.js       # Manages toast alert popups and life-cycles
β”‚   β”‚       β”‚   └── ...            # The other modules are listed in docs/frontend-guide.md
β”‚   β”‚       β”œβ”€β”€ board/             # Wood textures of the board: maple.webp, walnut.webp, frame.webp
β”‚   β”‚       β”œβ”€β”€ pieces/            # Piece pictures: staunton/ and staunton-single/ (WebP, the default), and the SVG sets classic/, wood/ and outline/
β”‚   β”‚       β”œβ”€β”€ vendor/three/      # Vendored three.js build used by scene3d.js
β”‚   β”‚       β”œβ”€β”€ sounds/            # Gameplay sound effects
β”‚   β”‚       β”‚   β”œβ”€β”€ capture.mp3    # Capture sound alert
β”‚   β”‚       β”‚   β”œβ”€β”€ check.wav      # Check sound warning
β”‚   β”‚       β”‚   β”œβ”€β”€ draw.mp3       # Game draw chime
β”‚   β”‚       β”‚   β”œβ”€β”€ move.wav       # Chess piece move tick
β”‚   β”‚       β”‚   └── ...            # draw_end.mp3, loss.mp3, timeout.mp3 and win.mp3
β”‚   β”‚       β”œβ”€β”€ checkora_icon_only.png # Project brand mark
β”‚   β”‚       └── favicon.jpeg       # Small browser favicon
β”‚   β”œβ”€β”€ templates/                 # Server-side HTML render blueprints
β”‚   β”‚   β”œβ”€β”€ 404.html               # Custom 404 error page template
β”‚   β”‚   β”œβ”€β”€ 500.html               # Custom 500 error page template (standalone, does not extend base.html)
β”‚   β”‚   β”œβ”€β”€ robots.txt             # Web crawler configuration instructions
β”‚   β”‚   β”œβ”€β”€ sitemap.xml            # SEO indexing guide
β”‚   β”‚   └── game/                  # Namespace folder matching Django conventions
β”‚   β”‚       β”œβ”€β”€ includes/          # Reusable UI partial layout blocks
β”‚   β”‚       β”‚   β”œβ”€β”€ avatar.html    # A player's picture or initial, drawn by the {% avatar %} tag
β”‚   β”‚       β”‚   β”œβ”€β”€ footer.html    # Site footer
β”‚   β”‚       β”‚   β”œβ”€β”€ google_button.html # "Continue with Google", shown only when a Google client is set up
β”‚   β”‚       β”‚   β”œβ”€β”€ legal.html     # Privacy policy, terms and disclaimer dialogs opened from the footer
β”‚   β”‚       β”‚   β”œβ”€β”€ logo.html      # Checkora logo and wordmark, linking to the landing page
β”‚   β”‚       β”‚   β”œβ”€β”€ messages.html  # Banner rendering Django alert notifications
β”‚   β”‚       β”‚   β”œβ”€β”€ navbar.html    # Site navigation, theme toggle and account menu
β”‚   β”‚       β”‚   β”œβ”€β”€ privacy_text.html # Privacy policy text, used by /privacy/ and the footer dialog
β”‚   β”‚       β”‚   β”œβ”€β”€ rank_badge.html   # Rank badge, drawn by the {% rank_badge %} tag
β”‚   β”‚       β”‚   └── terms_text.html   # Terms text, used by /terms/ and the footer dialog
β”‚   β”‚       β”œβ”€β”€ account.html       # Account settings at /account/
β”‚   β”‚       β”œβ”€β”€ avatar.html        # Picture picker: preset pieces or an upload
β”‚   β”‚       β”œβ”€β”€ base.html          # Base template the pages extend (see docs/design-system.md)
β”‚   β”‚       β”œβ”€β”€ board.html         # Interactive gameplay chessboard and player cards
β”‚   β”‚       β”œβ”€β”€ confirm_delete_account.html # Confirmation page opened by the emailed account deletion link
β”‚   β”‚       β”œβ”€β”€ google_username.html # A new Google player picks a username here
β”‚   β”‚       β”œβ”€β”€ landing.html       # Landing page served at /
β”‚   β”‚       β”œβ”€β”€ leaderboard.html   # Rating and puzzle leaderboards
β”‚   β”‚       β”œβ”€β”€ login.html         # Sign-in form interface
β”‚   β”‚       β”œβ”€β”€ privacy.html       # Privacy policy page at /privacy/
β”‚   β”‚       β”œβ”€β”€ profile.html       # Rating, rank, level and streaks of the signed-in player
β”‚   β”‚       β”œβ”€β”€ register.html      # Create account interface
β”‚   β”‚       β”œβ”€β”€ terms.html         # Terms page at /terms/
β”‚   β”‚       β”œβ”€β”€ verify_email_change.html # Code entry for a new email address
β”‚   β”‚       β”œβ”€β”€ verify_otp.html    # Two-factor verification panel
β”‚   β”‚       β”œβ”€β”€ rules.html         # Gameplay and chess educational rules guide
β”‚   β”‚       β”œβ”€β”€ stats.html         # User match metrics, profiles, and scoreboards
β”‚   β”‚       β”œβ”€β”€ welcome_email.html # HTML email template sent to users after successful registration
β”‚   β”‚       β”œβ”€β”€ password_reset.html # Password reset trigger page
β”‚   β”‚       β”œβ”€β”€ password_reset_complete.html # Confirmation of successful reset
β”‚   β”‚       β”œβ”€β”€ password_reset_confirm.html  # Verification form link target
β”‚   β”‚       β”œβ”€β”€ password_reset_done.html     # Outlines password email delivery status
β”‚   β”‚       β”œβ”€β”€ password_reset_email.html    # HTML layout for reset emails
β”‚   β”‚       └── password_reset_subject.txt   # Email subject text file
β”‚   β”œβ”€β”€ templatetags/
β”‚   β”‚   └── players.py             # {% avatar %} and {% rank_badge %}
β”‚   β”œβ”€β”€ __init__.py                # Package initialization marker
β”‚   β”œβ”€β”€ accounts.py                # Account rules: usernames, emails, Google signups, renames
β”‚   β”œβ”€β”€ apps.py                    # Django configuration class definition
β”‚   β”œβ”€β”€ avatars.py                 # Preset piece pictures, and uploads re-encoded for /u/<id>/avatar/
β”‚   β”œβ”€β”€ context_processors.py      # Tells templates whether Google sign-in is set up
β”‚   β”œβ”€β”€ engine.py                  # ChessGame: the game's state, the engine commands and their replies
β”‚   β”œβ”€β”€ engine_client.py           # Finds, starts and talks to the engine server of each game
β”‚   β”œβ”€β”€ forms.py                   # Forms for registration, account settings, pictures and the forum
β”‚   β”œβ”€β”€ google_auth.py             # The Google side of "Continue with Google" (OpenID Connect with PKCE)
β”‚   β”œβ”€β”€ icon.jpeg                  # Main project thumbnail graphic
β”‚   β”œβ”€β”€ middleware.py              # Security headers, and the player's time zone from the tz cookie
β”‚   β”œβ”€β”€ models.py                  # Database schemas mapping matches and profiles
β”‚   β”œβ”€β”€ progression.py             # Rating, rank, points, levels and streaks
β”‚   β”œβ”€β”€ services.py                # Standalone functions managing core business logic
β”‚   β”œβ”€β”€ tests.py                   # The largest Django test module
β”‚   β”œβ”€β”€ test_*.py                  # Further test modules, such as test_accounts.py and test_engine_rules.py
β”‚   β”œβ”€β”€ urls.py                    # Application level router mapping endpoints
β”‚   β”œβ”€β”€ views.py                   # Django controller layer dispatching API and HTML requests
β”‚   β”œβ”€β”€ views_account.py           # Profile, picture, account settings and account deletion
β”‚   β”œβ”€β”€ views_google.py            # Google sign-in, linking, and the username step for new players
β”‚   └── views_seo.py               # The sitemap: main pages, every lesson and every opening
β”œβ”€β”€ scripts/
β”‚   β”œβ”€β”€ engine_match.py            # Plays two engine builds or levels against each other and reports the Elo difference
β”‚   β”œβ”€β”€ render_pieces.mjs          # Renders the Staunton piece pictures
β”‚   └── render_wood.mjs            # Draws the wood textures of the board
β”œβ”€β”€ .env.example                   # Baseline local configuration variables blueprint
β”œβ”€β”€ .gitignore                     # Configures Git to ignore builds, caches, and database logs
β”œβ”€β”€ CODE_OF_CONDUCT.md             # Contributor environment code of conduct guidelines
β”œβ”€β”€ CONTRIBUTING.md                # Guide detailing branch formats and pull request rules
β”œβ”€β”€ LICENSE                        # Open-source MIT license deed
β”œβ”€β”€ README.md                      # Primary project overview
β”œβ”€β”€ board.test.js                  # Jest tests for board.js
β”œβ”€β”€ forum.test.js                  # Jest tests for forum.js
β”œβ”€β”€ requirements.txt               # Required Python packages
β”œβ”€β”€ requirements-dev.txt           # requirements.txt plus test-only packages (python-chess)
β”œβ”€β”€ manage.py                      # Django CLI control center script
β”œβ”€β”€ package.json                   # Jest dependencies and the `npm test` script
β”œβ”€β”€ package-lock.json              # Locked frontend dependency version tree
β”œβ”€β”€ structure.md                   # Extended architectural blueprint documentation
└── vercel.json                    # Configuration for serverless Django routing on Vercel

Architecture

Checkora uses a clean three-layer architecture:

Browser (JS/HTML/CSS)
       |
       v
Django Views (views.py)          <- HTTP request handling & session state
       |
       v
ChessGame Wrapper (engine.py)    <- Translates board state into engine commands
       |
       v
Engine client (engine_client.py) <- One engine server per game (persistent_server.py)
       |
       |---> C++ Binary (main.exe / main)   <- Primary: fast minimax AI
       +---> Python Script (main.py)        <- Fallback: identical logic in Python
Layer Technology Path
Frontend HTML, CSS, JavaScript game/templates/game/board.html
Backend Django 6.x game/views.py, game/engine.py, game/engine_client.py
Engine (Primary) C++17 game/engine/main.cpp
Engine (Fallback) Python 3.12+ game/engine/main.py

For a full deep-dive into the backend components, execution flow, and AI internals, see the Architecture Guide.

How It Works

When a player makes a move, the request flows through three layers:

  1. Browser sends a POST request with the move coordinates
  2. Django (views.py) receives it and delegates to the ChessGame wrapper in engine.py
  3. engine.py serializes the board into a flat 64-character string and builds the command line. game/engine_client.py hands it to the game's engine server, game/engine/persistent_server.py, which keeps one engine process running per game and talks to it over stdin and stdout. A one-off engine process answers when that server is not available

The engine speaks a simple text-based protocol:

Command Example Response
VERSION VERSION VERSION 2
MOVES MOVES <board64> <rights> <turn> <epRow> <epCol> row col MOVES tr tc is_capture is_promotion ...
ATTACKED ATTACKED <board64> <rights> <attackerColor> row col YES / NO
PROMOTE PROMOTE <board64> <rights> <turn> <epRow> <epCol> fr fc tr tc [piece] PROMOTE <newBoard64> / INVALID <reason>
STATUS STATUS <board64> <rights> <turn> <epRow> <epCol> STATUS CHECK / CHECKMATE / STALEMATE / DRAW / OK
NOTATION NOTATION <board64> <rights> <turn> <epRow> <epCol> fr fc tr tc [piece] NOTATION <san> / NOTATION ? for an illegal move
EVAL EVAL <board64> <rights> <turn> <epRow> <epCol> EVAL <centipawns>
PERFT PERFT <board64> <rights> <turn> <epRow> <epCol> <depth> PERFT <leaf nodes>
BESTMOVE BESTMOVE <board64> <rights> <turn> <epRow> <epCol> <depth> [timeLimitMs [halfmoveClock [alternatives [earlier positions...]]]] BESTMOVE fr fc tr tc EVAL <cp> ... / BESTMOVE NONE

This is version 2 of the protocol. Every command gets exactly one reply line, and a line that cannot be parsed is answered with ERROR <reason>. The header comments of game/engine/main.cpp and game/engine/main.py define it, and docs/engine_architecture.md explains each command, the search and the difficulty levels.

flowchart TD
    A[Browser\nJS / HTML] -->|HTTP POST /api/move/| B[Django Views\nviews.py]
    B -->|delegates to| C[ChessGame Wrapper\nengine.py]
    C -->|board64 + command via stdin| D{Engine}
    D -->|C++ binary\nmain.exe / main| E[Minimax + Alpha-Beta\nPrimary]
    D -->|Python fallback\nmain.py| F[Minimax + Alpha-Beta\nFallback]
    E -->|response via stdout| C
    F -->|response via stdout| C
    C -->|updated state| B
    B -->|JSON response| A
Loading

API Reference

Checkora features a decoupled API layer. Below is the endpoint catalog accompanied by explicit request and response structures to assist frontend integrations.

Note

All state-modifying requests (POST) require a CSRF token passed via the X-CSRFToken HTTP header, except for /api/cron/cleanup-stale-games/, which is CSRF-exempt and checks a bearer token instead.

Method Endpoint Description Request Example
GET / Render the landing page (/home/ redirects here) N/A (Standard HTML Page)
GET /play/ Render the board UI N/A (Standard HTML Page)
GET /api/state/ Retrieve full game state from session /api/state/
POST /api/move/ Execute a move on the board /api/move/
GET /api/valid-moves/ Get all legal moves for a selected piece /api/valid-moves/?row=6&col=4
POST /api/new-game/ Start a new PvP or PvE game /api/new-game/
GET /api/check-promotion/ Check if a pawn reaches the promotion rank /api/check-promotion/?from_row=1&from_col=0&to_row=0
POST /api/ai-move/ Request the engine to compute the best move /api/ai-move/
POST /api/pause/ Pause/Resume game timer countdown /api/pause/
POST /api/timeout/ End the game on time once the server's clock has run out /api/timeout/
POST /api/resume/ Resume a previously saved game /api/resume/
POST /api/resign/ Resign the current game /api/resign/
POST /api/draw/ Offer or accept a draw in PvP mode /api/draw/
GET /api/check-username/ Check if a username is available /api/check-username/?username=player1
POST /api/analyze-game/ Analyze a completed game and return statistics (login required) /api/analyze-game/
POST /api/opening-stats/ Save the result of an opening trainer run (login required) /api/opening-stats/
GET /api/puzzle-stats/ Retrieve puzzle streak and statistics /api/puzzle-stats/
POST /api/puzzles/<id>/solve/ Check a puzzle solution and count the solve (login required) /api/puzzles/12/solve/
GET, POST /api/cron/cleanup-stale-games/ Secure cron-triggered cleanup for abandoned games /api/cron/cleanup-stale-games/

The full reference, with every field and error response, is in docs/API.md. It also covers sign-in with a password or with Google, the account settings forms and the profile picture endpoints.


Request/Response JSON Examples

1. Retrieve Game State (GET /api/state/)

Called on board load to restore ongoing match positions and clocks.

Response (Success - 200 OK):

{
  "board": [
    ["r", "n", "b", "q", "k", "b", "n", "r"],
    ["p", "p", "p", "p", "p", "p", "p", "p"],
    [null, null, null, null, null, null, null, null],
    [null, null, null, null, null, null, null, null],
    [null, null, null, null, null, null, null, null],
    [null, null, null, null, null, null, null, null],
    ["P", "P", "P", "P", "P", "P", "P", "P"],
    ["R", "N", "B", "Q", "K", "B", "N", "R"]
  ],
  "version": 0,
  "current_turn": "white",
  "white_time": 600,
  "black_time": 600,
  "time_limit": 600,
  "increment": 0,
  "paused": true,
  "move_history": [],
  "captured_pieces": {"white": [], "black": []},
  "mode": "pvp",
  "player_color": "white",
  "difficulty": "medium",
  "white_name": "White",
  "black_name": "Black",
  "fen": "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",
  "pgn": "[Event \"Checkora Match\"]",
  "game_status": "active",
  "in_check": false,
  "draw_reason": null,
  "threefold_warning": false,
  "opening_name": null,
  "opening_moves": null,
  "rated": false
}

Note: in_check is true while the side to move is in check; game_status stays "active" during a check. rated is true only for a logged-in user playing the AI from the standard starting position. If a clock has run out, this request ends the game: game_status is "timeout" and a winner field is added. Logged-in users also get day_streak.

2. Execute a Move (POST /api/move/)

Triggered when a player releases a piece onto a destination square.

Request Body:

Note: promotion_piece is optional ("q", "r", "b", "n") and required only if check-promotion is true.

{
  "from_row": 6,
  "from_col": 4,
  "to_row": 4,
  "to_col": 4,
  "promotion_piece": "q"
}

Response (Success - 200 OK):

Note: board is an 8x8 array reflecting the updated state. message is the move in algebraic notation. game_status can be "ok", "check", "checkmate", "stalemate", "draw", or "timeout".

{
  "valid": true,
  "message": "e4",
  "captured": null,
  "board": [],
  "current_turn": "black",
  "white_time": 595,
  "black_time": 600,
  "time_limit": 600,
  "increment": 0,
  "move_history": [
    {"notation": "e4", "piece": "P", "from": [6, 4], "to": [4, 4], "captured": null, "color": "white", "promoted_to": null}
  ],
  "opening_name": "King's Pawn Game",
  "opening_moves": "e4",
  "captured_pieces": {"white": [], "black": []},
  "game_status": "ok",
  "draw_reason": null,
  "threefold_warning": false,
  "fen": "rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3 0 1",
  "pgn": "[Event \"Checkora Match\"]",
  "white_name": "White",
  "black_name": "Black",
  "version": 0
}

Response (rejected move - 200 OK with valid false):

Note: the body is the same object as above with the position unchanged; only the fields that differ are shown.

{
  "valid": false,
  "message": "Illegal move.",
  "game_status": "active"
}

Response (Error): 400 Bad Request with {"error": "Invalid board coordinates"} for missing or out-of-range coordinates, 403 Forbidden when it is the computer's turn in an AI game, and 409 Conflict when a logged-in user's game changed in the meantime.

3. Get Valid Moves (GET /api/valid-moves/)

Instructs the frontend UI where the selected piece can legally go.

Request Parameters: ?row=6&col=4

Response (Success - 200 OK):

{
  "valid_moves": [
    {"row": 4, "col": 4, "is_capture": false, "is_promotion": false},
    {"row": 5, "col": 4, "is_capture": false, "is_promotion": false}
  ]
}

4. Request AI Move (POST /api/ai-move/)

Triggers background minimax engine search. Returns the move calculated by the C++/Python engine.

Response (Success - 200 OK):

Note: board is an 8x8 array reflecting the updated state. move_history contains the list of moves. message and game_status work as in /api/move/.

{
  "valid": true,
  "message": "d5",
  "captured": null,
  "board": [],
  "current_turn": "white",
  "white_time": 600,
  "black_time": 598,
  "time_limit": 600,
  "increment": 0,
  "move_history": [],
  "opening_name": "Queen's Pawn Game",
  "opening_moves": "d4 d5",
  "captured_pieces": {"white": [], "black": []},
  "ai_move": {
    "from_row": 1,
    "from_col": 3,
    "to_row": 3,
    "to_col": 3
  },
  "game_status": "ok",
  "draw_reason": null,
  "threefold_warning": false,
  "fen": "rnbqkbnr/ppp1pppp/8/3p4/3P4/8/PPP1PPPP/RNBQKBNR w KQkq d6 0 2",
  "pgn": "[Event \"Checkora Match\"]",
  "white_name": "White",
  "black_name": "Black",
  "opening": "",
  "version": 0
}

Response (Error): 400 Bad Request when there is no AI game, the game is over or paused, or it is the player's turn; 429 Too Many Requests when the rate limit is reached; 503 Service Unavailable when the engine returns no move for a position that is not finished.

5. Start New Game (POST /api/new-game/)

Resets current session variables and starts a fresh match.

Request Body:

Note: mode can be "pvp" or "ai".

{
  "mode": "ai"
}

Response (Success - 200 OK):

Note: board is an 8x8 array containing the clean initial board configuration. forfeited is true when a logged-in user's rated game in progress was ended and recorded to make way for this one.

{
  "valid": true,
  "board": [],
  "current_turn": "white",
  "move_history": [],
  "captured_pieces": {"white": [], "black": []},
  "mode": "ai",
  "player_color": "white",
  "white_name": "White",
  "black_name": "β™— Tactical Bishop",
  "difficulty": "medium",
  "time_limit": 600,
  "increment": 0,
  "fen": "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",
  "pgn": "[Event \"Checkora Match\"]",
  "game_status": "active",
  "in_check": false,
  "draw_reason": null,
  "opening": "",
  "version": 0,
  "rated": false,
  "forfeited": false
}

6. Analyze Game (POST /api/analyze-game/)

Analyzes a completed game based on its move history and returns statistics. The user must be logged in; an anonymous request gets 401 Unauthorized.

Request Body:

{
  "moves": ["e4", "e5", "Nf3", "Nc6"],
  "result": "White wins",
  "reason": "checkmate"
}

Response (Success - 200 OK):

Note: move_analysis_details has one entry per analysed half-move, and move_analysis lists their classes ("Best", "Inaccuracy", "Mistake", "Blunder" or "Unknown").

{
  "result": "White wins",
  "end_reason": "checkmate",
  "opening": "King's Pawn Game",
  "captures": 0,
  "checks": 0,
  "checkmates": 0,
  "promotions": 0,
  "blunders": 0,
  "mistakes": 0,
  "accuracy": 100,
  "total_moves": 2,
  "move_analysis_details": [
    {"move_num": 1, "color": "White", "played": "e4", "best": "Nf3", "class": "Unknown", "eval": null},
    {"move_num": 1, "color": "Black", "played": "e5", "best": "d5", "class": "Unknown", "eval": null},
    {"move_num": 2, "color": "White", "played": "Nf3", "best": "Nc3", "class": "Unknown", "eval": null},
    {"move_num": 2, "color": "Black", "played": "Nc6", "best": "Nc6", "class": "Best", "eval": null}
  ],
  "move_analysis": ["Unknown", "Unknown", "Unknown", "Best"],
  "analysis_timeout_seconds": 10,
  "truncated": false,
  "final_eval": null
}

7. Get Puzzle Stats (GET /api/puzzle-stats/)

Returns puzzle streak information for the puzzle interface. A logged-in user gets their own numbers; an anonymous request gets zeros.

Response (Success - 200 OK):

{
  "streak": 0,
  "longest_streak": 0,
  "puzzles_solved": 0,
  "daily_completions": 0
}

8. Cleanup Cron (GET or POST /api/cron/cleanup-stale-games/)

Secure cron-triggered cleanup endpoint for abandoned games. vercel.json schedules it once a day.

Request Headers:

Authorization: Bearer <cron_secret>

Response (Success - 200 OK):

{
  "status": "success",
  "deleted_games": 2,
  "resigned_games": 1,
  "purged_records": 0,
  "purged_sessions": 0
}

9. Claim timeout (POST /api/timeout/)

Called by the board when its clock reaches zero. The server ends the game only if its own stored clock has run out as well.

Response (Success - 200 OK):

{
  "valid": true,
  "game_status": "timeout",
  "winner": "black",
  "white_time": 0,
  "black_time": 412,
  "version": 0
}

Response (clock still running - 400 Bad Request):

{
  "valid": false,
  "message": "Clock has not run out.",
  "white_time": 3,
  "black_time": 412
}

10. Solve puzzle (POST /api/puzzles/<id>/solve/)

Checks the moves played against the puzzle's stored solution and counts the solve for the logged-in user. counted is false when the user opened that puzzle's solution in the last seven days; the answer is still checked, but nothing is counted.

Request Body:

{
  "moves": ["g2g4"]
}

Response (Success - 200 OK):

{
  "success": true,
  "correct": true,
  "counted": true,
  "newly_solved": true,
  "puzzles_solved": 1,
  "streak": 1,
  "longest_streak": 1,
  "daily_completions": 1
}

Tests

The test suite runs fully in-memory β€” no compiled engine binary required.

pip install -r requirements-dev.txt
python manage.py test game

The Django tests are in game/tests.py and the game/test_*.py modules. They cover the API endpoints, move validation, both engines and the bridge to them, the difficulty levels, accounts and Google sign-in, and ratings, points and streaks. requirements-dev.txt adds python-chess. Some engine tests check both engines against it, and they are skipped when it is missing. The command also collects the Selenium tests in game/selenium_tests/, which need Chrome. docs/testing.md has the details.

The JavaScript tests run on Jest:

npm ci
npm test

That runs the 103 tests in board.test.js and forum.test.js.


Troubleshooting Guide

Below are solutions to common setup, installation, and environment issues contributors encounter when getting Checkora running locally.

🐍 1. Python Version Mismatch

Django 6.x is built on modern Python paradigms and strictly requires Python 3.12 or higher. If you run an older version, dependencies in requirements.txt will fail to resolve or throw syntax errors during server boot.

  • Check version:
    python --version
  • Resolution (Windows multiple installations): Use the Python Launcher to explicitly target 3.12+ when creating your virtual environment:
    py -3.12 -m venv venv
  • Resolution (macOS/Linux): Ensure python3 points to a 3.12+ installation (e.g., via Homebrew: brew install [email protected]).

πŸ“¦ 2. Virtual Environment Activation Issues

Depending on your terminal shell or system policies, activating the virtual environment might throw permission or script execution errors.

  • Windows PowerShell execution restriction error: If you see an error like Script execution is disabled on this system, bypass the policy for the active process:

    Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
    venv\Scripts\Activate.ps1
  • Activation commands for different shells:

    Shell Command
    Windows Cmd venv\Scripts\activate.bat
    Windows PowerShell venv\Scripts\Activate.ps1
    Git Bash / WSL / Linux / macOS source venv/bin/activate
    Fish Shell source venv/bin/activate.fish

πŸ› οΈ 3. g++ Compiler Installation & Configuration Problems

The C++ chess engine has to be compiled locally to get the faster engine. If g++ is missing or not configured correctly, the compile command fails.

Tip

If g++ setup is too tricky for your system, you can skip compiling it! Checkora will automatically detect the absence of the binary and fall back to the Python engine in game/engine/main.py. It does the same for a binary that is not executable or was built from older sources.

  • Check compiler availability:

    g++ --version
  • Resolution (Windows):

    1. Download the MinGW-w64 compiler suite (we recommend the simple, portable w64-devkit).
    2. Add the bin directory (containing g++.exe) to your system's Environment Variables -> PATH list.
    3. Restart your terminal so the new path takes effect.
  • Resolution (macOS): Install the Xcode Command Line Tools:

    xcode-select --install
  • Resolution (Ubuntu/Debian Linux):

    sudo apt update && sudo apt install build-essential

πŸ’Ύ 4. Database Migration Errors

If migrations fail to run, or database models get out of sync, you may encounter relational database exceptions.

  • Resolution: Reset your local SQLite database structure by running:

    # 1. Generate any missing database schema blueprints
    python manage.py makemigrations game
    
    # 2. Safely apply schema blueprints
    python manage.py migrate

    If conflicts persist, delete the local db.sqlite3 file and re-run the commands above to construct a clean database.

πŸ”‘ 5. Missing .env Configuration File

If you attempt to launch the Django server without setting up a local configuration file, Django will throw KeyError or configuration load failures for crucial settings.

  • Resolution: Ensure you clone the template configuration into a new active .env file in the root directory:

    # Windows PowerShell
    copy .env.example .env
    
    # macOS / Linux
    cp .env.example .env

    Open .env and verify you have a robust string under SECRET_KEY. Keep DEBUG=True in it for local work. core/settings.py leaves DEBUG off unless .env turns it on. With it off you get the custom 500 page instead of Django's traceback, and OTP and password reset emails go to the SMTP server instead of being printed in the terminal. Additionally, ensure TRUSTED_PROXY_IPS is configured (defaulting to 127.0.0.1,::1 for local development). TRUSTED_PROXIES remains supported as a legacy fallback.

    ⚠️ Security Warning for Production: When deploying behind reverse proxies (Vercel, Cloudflare, AWS ALB, etc.), you must set TRUSTED_PROXY_IPS to your platform's upstream proxy IPs. Incorrect configuration allows attackers to spoof their IP address and bypass rate limiting entirely.

πŸ”Œ 6. Port Conflicts (Port 8000 Already in Use)

If you already have another service running on your local port 8000, Django will fail to bind and throw Error: That port is already in use.

  • Resolution: Instruct Django to boot the local server on an alternative unoccupied port, for example, 8080 or 8001:

    python manage.py runserver 8080

πŸ”’ 7. Local SSL Error (ERR_SSL_PROTOCOL_ERROR)

If the browser shows ERR_SSL_PROTOCOL_ERROR or the terminal prints "You're accessing the development server over HTTPS, but it only supports HTTP", the browser is using HTTPS against the local HTTP dev server.

  • Resolution:
    1. Copy the example env file if you have not already: copy .env.example .env (Windows) or cp .env.example .env (macOS/Linux).
    2. Copy the exact URL from the terminal, for example http://127.0.0.1:8000/ β€” include http:// and do not let the browser change it to https://.
    3. Disable your browser's HTTPS-upgrade setting for local development (for example, Chrome/Brave: "Always use secure connections" / "Upgrade connections to HTTPS").
    4. Clear cached HSTS for 127.0.0.1 if the browser keeps forcing HTTPS (Chrome/Brave: chrome://net-internals/#hsts; steps vary by browser).

Contributor Support & Feedback

We want your contribution journey with Checkora to be smooth, welcoming, and productive! If you hit roadblocks or have ideas, please utilize the following channels:

πŸ’¬ 1. Join our Discord Community

Our central hub for live discussions, playtesting matches, roadmap announcements, and direct maintainer support.

  • Invite Link: Join the Checkora Discord Server
  • Active Channels:
    • #setup-help: For environment, dependencies, or local compilation challenges.
    • #engine-chat: For deep-dives into minimax heuristics, board representation, and alpha-beta pruning.
    • #suggestions: For sharing your design mocks, UI improvements, or gameplay feature proposals.

❓ 2. Ask Setup & Installation Questions

If you prefer forum-style threading over live Discord chat:

  • Open a question on our GitHub Discussions page under the Q&A / Help category.
  • Search prior threads; many common setups or dependencies are documented by fellow contributors.

πŸ“š 3. Report Documentation Confusion

If a section of this guide, structure.md, or API.md is unclear, out of date, or missing steps:

  • File a GitHub Issue and attach the documentation label. The repository has issue templates for bug reports and feature requests only.
  • Better yet: Submit a quick pull request correcting the text! We love docs-focused contributions.

πŸ’‘ 4. Share Feature Proposals & Suggestions

Want to introduce a new gameplay timer format, customize themes, or build a matching lobby?

  • Share your proposals in GitHub Discussions Ideas.
  • Align with core maintainers (@EDWARD-012 & @triemerge) before writing significant logic to ensure architectural compatibility.

Contributing

Contributions are welcome! Please read CONTRIBUTING.md for branch naming conventions, commit message format, and PR guidelines before submitting.


License

Released under the MIT License.

About

Chess platform with an AI opponent powered by minimax search with alpha-beta pruning, built on Django and a C++ engine. Discord: https://discord.gg/ymvGzP5NBu

Resources

Code of conduct

Contributing

Security policy

Stars

139 stars

Watchers

3 watching

Forks

Used by

Contributors

Languages