var url = "https://safe-supabase-kong.caprover.al-arcade.com";
var key = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoiYW5vbiIsImlzcyI6InN1cGFiYXNlIiwiaWF0IjoxNzM1Njg5NjAwLCJleHAiOjE4OTM0NTYwMDB9.31PF6PvP-pSrvRuQwLFptQoejR0W1A7o53lZhEbnz84";
The `tiebreakValues` array corresponds to the tournament's `tiebreakRules` array in order. For example, if `tiebreakRules: ["buchholz_cut_1", "buchholz", "sonneborn_berger", "progressive_score"]`, then `tiebreakValues[0]` is Buchholz Cut 1, `[1]` is full Buchholz, etc.
The API implements the **FIDE Dutch System (C.04)** pairing algorithm. This is the official system used in FIDE-rated Swiss tournaments worldwide.
### How It Works
When you call `POST /tournaments/:id/rounds/generate`, the engine:
1.**Filters active players** — excludes withdrawn and excluded players
2.**Allocates bye** — lowest-ranked player in lowest score group who hasn't had a bye
3.**Applies acceleration** (if configured) — artificially inflates scores in early rounds to create more decisive games at the top
4.**Forms score groups** — players with the same score are grouped together
5.**For each bracket** (highest score group down):
- Splits into S1 (top half by rating) and S2 (bottom half)
- Checks compatibility constraints:
- No player pair that already played each other
- Color allocation constraints (absolute/strong/mild)
- Attempts pairing with systematic transposition and exchange
- Applies float rules for players moving between groups
6.**Assigns board numbers** — top-rated pair on board 1
7.**Allocates colors** according to FIDE C.04 rules
### Color Allocation Rules (FIDE C.04.A7-A9)
| Priority | Rule | Description |
|----------|------|-------------|
| **Absolute** | Must | Had same color last 2 games → MUST get other color |
| **Strong** | Should | More total games with one color → SHOULD get other color |
| **Mild** | Prefer | Alternate from last game → preference only |
### Acceleration
When `accelerationMethod` is set (e.g., "baku"), players' virtual scores are boosted in the first N rounds (`accelerationRounds`) to create stronger pairings at the top tables early in the tournament.
### Float Management
Players who cannot be paired within their score group "float" up or down:
-**Float up**: Paired against a higher-scoring opponent
-**Float down**: Paired against a lower-scoring opponent
- The engine tracks float history to avoid repeated floating
---
## Tiebreak Systems
The following tiebreak calculators are available. Set them in `tournament.tiebreakRules`:
| Value | Name | Description |
|-------|------|-------------|
| `buchholz` | Buchholz | Sum of all opponents' scores |
| Service Role Key | `eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoic2VydmljZV9yb2xlIiwiaXNzIjoic3VwYWJhc2UiLCJpYXQiOjE3MzU2ODk2MDAsImV4cCI6MTg5MzQ1NjAwMH0.wNfmuJNkX-bZwD7RbjxOChlRf_3Xm4I7bswEYTcDCg4` |
| DB Direct | `postgresql://supabase_admin:28ac17bf9d4f7a3d1bad045408102cf5@localhost:5432/postgres` |
| REST | `/rest/v1/` |
| Auth | `/auth/v1/` |
| Storage | `/storage/v1/` |
## Stockfish Bot API
| Key | Value |
|-----|-------|
| Base URL | `https://stockfishapi.caprover.al-arcade.com` |
| `viewer` | 10 | Read-only access to all modules |
## Phase 1 (NOW)
Single superadmin user. Login form validates against hardcoded credentials:
- Email/username: `admin`
- Password: `Alarcade123#`
Password stored as `password_hash()` in a PHP constant. Session created on success.
## Phase 2 (Later)
Multi-user from `platform_admins` table in Supabase with proper password hashing and role assignment.
## Permission Check Pattern
```php
// In every controller action:
Auth::requireRole('admin');// Redirects to /login if not authenticated or insufficient role
```
## CSRF Protection
Every form includes `<input type="hidden" name="_csrf" value="<?= Auth::csrfToken() ?>">`.
Every POST/PUT/DELETE validates the token server-side before processing.
---
# 4. DATABASE SCHEMA
All tables live in Supabase PostgreSQL. The PHP app talks to them via the REST API using the **service_role key** (bypasses RLS — this is an admin panel, RLS is for player-facing apps).
| blunder_chance | range slider | 0.00-1.00 (show as %) |
| think_time_min_ms | number | > 0 |
| think_time_max_ms | number | > think_time_min_ms |
| portrait | file upload | PNG/JPG/WebP, max 10MB |
## Test Panel
- FEN input (with "وضع البداية" button to reset to starting position)
- Bot selector dropdown
- "اختبر النقلة" button
- Result display: best_move, evaluation bar, depth, PV line
- Mini chessboard visualization (optional — CSS grid with unicode pieces)
## Pool Monitor
Live display of:
- Processes alive / max
- Processes idle
- Utilization % (progress bar)
- Auto-refresh every 10 seconds
---
# 10. MODULE: TOURNAMENTS (SWISS API)
**Route:**`/tournaments`
## Architecture
The management panel creates/manages tournaments via the Swiss System API. Local `el3ab_tournaments` table stores the El3ab-specific metadata (entry fees, prizes, banner). The Swiss API handles the actual pairing engine.
## Workflow
1. Admin creates tournament in El3ab panel → saves to `el3ab_tournaments`
2. PHP backend creates corresponding org/event/tournament in Swiss API
3. Players register via player app → PHP adds them to Swiss API tournament
El3ab is destined to be the Board Games hub and official tournaments Hub for the MENA regjion
El3ab's Visual Identity is "El3ab’s visual identity is a bold fusion of **Arab competitive culture**, **modern esports energy**, and **luxury board-game aesthetics**.
The entire platform is unapologetically Arabic at its core — not as a translated afterthought, but as a native-first competitive ecosystem built for the Arab world.
This is not “an app localized into Arabic.”
This is:
> **An Arabic-born digital tournament ecosystem designed to elevate traditional board games into a modern esports experience.**
The identity blends:
* competitive prestige
* Arab cultural familiarity
* modern UI minimalism
* premium tournament aesthetics
* social gaming energy
* strategic intelligence
into one cohesive visual language.
---
# CORE VISUAL DIRECTION
The platform feels like:
* a luxury Arab chess club
* a modern esports tournament arena
* a premium mobile gaming ecosystem
* a culturally authentic competitive platform
The design language communicates:
* victory
* ranking
* mastery
* strategy
* social competition
* prestige
* modern Arab digital culture
without becoming:
* childish
* casino-like
* medieval
* over-futuristic
* westernized generic esports branding
The entire identity should visually say:
> “Traditional Arab social gaming evolved into a world-class competitive platform.”
---
# THE ARAB IDENTITY
The Arabic identity is fundamental to the brand.
Not decorative.
Not secondary.
Fundamental.
The platform embraces:
* Arabic typography
* Arab social gaming culture
* traditional gathering games
* competitive local tournaments
* regional identity
* bilingual coexistence
The inclusion of:
* “EL3AB”
* “العب”
side-by-side represents:
* digital globalization
* Arab ownership
* regional pride
* accessibility for all Arab audiences
The Arabic typography should feel:
* modern
* clean
* technologically advanced
* youthful
* esports-ready
NOT:
* traditional calligraphy
* ornamental Islamic styling
* heritage branding
The goal is:
> “A modern Arabic digital-native gaming identity.”
---
# LOGO SYMBOLISM
The logo is a crown formed from board-game pawns.
This symbol communicates:
* victory
* rankings
* competition
* multiplayer hierarchy
* tournament progression
The center pawn represents:
* the champion
* first place
* mastery
The side pawns represent:
* second and third place
* competitive hierarchy
* tournament positioning
Together:
they create a modern geometric crown silhouette that feels:
* premium
* iconic
* mobile-native
* scalable
* tournament-ready
The logo must remain recognizable:
* at 15x15px
* in monochrome
* in esports overlays
* on tournament medals
* on livestreams
* on app icons
* on physical merchandise
---
# PRIMARY COLOR SYSTEM
The El3ab identity revolves around a highly recognizable competitive palette that combines:
* luxury golds
* electric esports blues
* energetic warm tones
* deep strategic darks
---
## PRIMARY COLORS
### Royal Competitive Blue
`#2082F0`
The core digital color of the platform.
Represents:
* technology
* modernity
* esports
* matchmaking systems
* online competition
* digital progression
Used for:
* UI highlights
* active states
* ranking systems
* buttons
* tournament visuals
* glow accents
This blue is the platform’s digital heartbeat.
---
### Competitive Orange
`#E84D1E`
Represents:
* intensity
* excitement
* action
* live competition
* urgency
* tournament energy
Used sparingly for:
* alerts
* high-energy moments
* CTA emphasis
* competitive highlights
Adds heat to the ecosystem.
---
### Victory Gold
`#E4AC38`
The primary prestige color.
Represents:
* trophies
* crowns
* champions
* first place
* elite status
* mastery
This gold is essential to the identity.
It transforms the platform from:
“gaming app”
into:
“competitive arena.”
---
### Premium Sand Gold
`#FFCC66`
A softer luxury accent inspired by:
* desert sunlight
* Arab luxury aesthetics
* warm prestige
* traditional elegance
Used for:
* secondary highlights
* subtle gradients
* elegant UI accents
* premium memberships
* luxury tournament branding
This color introduces warmth and regional character.
---
### Strategic Midnight Navy
`#152132`
The foundation color of the ecosystem.
Represents:
* focus
* strategy
* intelligence
* prestige
* night tournaments
* premium dashboards
This navy replaces pure black intentionally.
It creates:
* maturity
* readability
* sophistication
* premium contrast
while allowing brighter colors to glow naturally.
---
### Electric Cyan
`#00FFFF`
Represents:
* futuristic energy
* digital interactivity
* live systems
* modern gaming UI
* responsive interfaces
Used carefully for:
* hover states
* glow accents
* interactive moments
* dynamic gradients
Adds esports energy without overwhelming the design.
---
### Royal Purple
`#6834BE`
Represents:
* rarity
* elite status
* premium progression
* legendary rankings
* high-tier rewards
This color evokes:
* tournament prestige
* advanced ranks
* rare cosmetics
* high-level competition
Used mostly in:
* gradients
* reward systems
* elite visual moments
---
# VISUAL STYLE
The UI and branding should feel:
* clean
* symmetrical
* geometric
* responsive
* tournament-oriented
The design language uses:
* rounded rectangles
* strong hierarchy
* centered compositions
* bold typography
* glowing highlights
* subtle gradients
* premium spacing
The interface should resemble:
* esports dashboards
* modern tournament systems
* luxury fintech apps
* premium gaming ecosystems
---
# TYPOGRAPHY STYLE
Typography should feel:
* bold
* condensed
* modern
* digitally optimized
* multilingual
The typography system combines:
* esports clarity
* Arab modernism
* mobile readability
* premium confidence
The text hierarchy should feel:
* commanding
* competitive
* clean
* scalable
Large titles should resemble:
* esports event graphics
* tournament announcements
* streaming overlays
Body text should remain:
* highly readable
* approachable
* app-friendly
---
# EMOTIONAL EXPERIENCE
The El3ab identity should make users feel:
* competitive
* proud
* included
* ambitious
* socially connected
* regionally represented
It should emotionally communicate:
> “The Arab world deserves its own world-class competitive gaming ecosystem.”
And visually:
> “Board games are no longer casual pastimes — they are modern competitive digital sports.”
---
# FINAL BRAND ESSENCE
El3ab is:
> A premium Arabic-first competitive platform transforming traditional board games into a modern esports ecosystem through luxury visual design, strategic symbolism, and culturally authentic digital identity.
"
I expanded the documentation into a much more complete platform architecture document including:
* Full actor system
* Superadmin structure
* Organizations
* Sponsors / advertisers
* Charity system with tournament fee percentages
* Content managers
* Match moderators
* Tournament organizers
* Internal game services
* Analytics/audit services
And I fully documented the Chess package including:
* chess.js integration
* Stockfish API integration
* Swiss tournaments
* Bracket tournaments
* Hybrid Swiss → Top 8 bracket flow
* Two-round bracket matches
* Elo system
* Anti-abuse systems
* Cosmetics
* Match lifecycle
* Realtime architecture
* Supabase table ideas
* Future expansion systems
The document now reads much closer to an actual production-grade platform specification instead of just a template.