VSCode Icon

File

Edit

View

Go

Run

Terminal

Help

Ghazi Saoudi - Visual Studio Code

All projects/chkobba.md

Engineering case study

Chkobba

A Tunisian classic. A shared, real-time table.

Online Chkobba for private 1v1 and 2v2 rooms, ranked matchmaking, and personality-driven AI opponents, built around server-authoritative game state.

Next.js 16React 19TypeScriptTailwind CSSZustandNode.jsSocket.IOSupabasePostgreSQL
01

The problem

Moving a card game online means more than rendering cards. Players need one consistent match state, enforceable rules, synchronized turns, and a way to reconnect without letting browsers decide which moves are legal.

Project context

Real-time multiplayer / Full-stack engineering

Implementation scope

  • A Next.js game interface with Zustand state and Socket.IO player intent.
  • A pure TypeScript engine for rules, scoring, AI, and tests, shared with the realtime server.
  • Guest play plus Supabase-backed accounts, match history, friends, ranked ratings, and progression.
02

Product walkthrough

chkobba.demo.mp4

Recorded product demo. Features shown reflect the version in this recording.

03

System architecture

  1. 01Player intent
  2. 02Server validation
  3. 03Game engine
  4. 04Approved state
  5. 05Match history
01

Player interface

Next.js / React / Zustand

Renders a sanitized game view and sends intent without deciding move legality.

02

Authoritative server

Node.js / Socket.IO

Owns rooms, turns, timers, validation, bots, reconnects, and match persistence.

03

Rules & contracts

TypeScript / pnpm workspaces

Pure game engine and shared event/DTO types, independent of the browser and database.

04

Player persistence

Supabase / PostgreSQL

Authentication, history, friends, ranked ratings, and progression; optional for guest play.

04

Engineering decisions

01

One authority for every move.

The realtime server owns the game state. Browsers submit intent and receive sanitized, server-approved views rather than acting as the rules authority.

02

Rules without framework dependencies.

The game engine contains no React, Socket.IO, database, or browser code. Rules, scoring, and AI can be tested independently of transport and UI.

03

Guest play stays independent of accounts.

Supabase is optional for guest play and required for account-based history, friends, ranked ratings, and progression. Core gameplay and account services have distinct boundaries.

04

Deploy the web and realtime server separately.

The documented deployment uses Vercel for the Next.js frontend and Render for the realtime server, with Supabase migrations deployed before server changes that depend on them.

05

Engineering takeaways

  • Realtime consistency starts with clear ownership of state.
  • A pure rules engine separates correctness from rendering and networking.
  • Shared contracts keep player intent and server-approved views aligned.

Next steps

The README identifies engine tests as the source of truth for captures, scoring, dealer rotation, and 1v1/2v2 rules. Further case-study updates can document measured reconnect behavior and player feedback once those results are available.