# englucascaetano-stack/tablefone architecture

> Architecture diagram of the GitHub repository englucascaetano-stack/tablefone, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/englucascaetano-stack/tablefone
- Repository: https://github.com/englucascaetano-stack/tablefone

## Overview

Mesa de Jogos is a private, browser-based multiplayer board-game platform, usable on a local network or through Supabase. Players choose a game, join a room, and submit move intentions; the server-side game rules validate moves and publish public state while keeping private hands or objectives separate. The graph includes the documented game library, tablet mode, and access-code administration. Several client and cloud details come from the README rather than sampled implementation; those relationships are cited there, and unsampled per-game screens are grouped by their existing directory.

Main entry points: [`games/index.js`](https://github.com/englucascaetano-stack/tablefone/blob/main/games/index.js) (Game registry), [`public/app.js`](https://github.com/englucascaetano-stack/tablefone/blob/main/public/app.js) (Browser shell), [`supabase/functions/mesa/index.ts`](https://github.com/englucascaetano-stack/tablefone/blob/main/supabase/functions/mesa/index.ts) (Mesa Edge Function), [`supabase/functions/mesa/core.mjs`](https://github.com/englucascaetano-stack/tablefone/blob/main/supabase/functions/mesa/core.mjs) (Room and move logic)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["Player interfaces"]
  node_browser["Browser shell<br/>[app.js]"]
  node_gameui["Game screens"]
  node_tabletui["Tablet display<br/>[tablet.js]"]
  node_transport["Client transport<br/>[transport.js]"]
end

subgraph group_local["Local game service"]
  node_localserver["Local room server<br/>[server.js]"]
end

subgraph group_cloud["Cloud game service"]
  node_edge["Mesa Edge Function<br/>[index.ts]"]
  node_core["Room and move logic<br/>[core.mjs]"]
  node_auth["Access control<br/>[auth.mjs]"]
  node_cloudgames["Cloud game rules"]
  node_supabase[("Supabase room data")]
  node_realtime["Supabase Realtime"]
end

subgraph group_games["Game library"]
  node_registry["Game registry<br/>[index.js]"]
  node_azul["Azul rules<br/>[game.js]"]
  node_bang["BANG! rules<br/>[game.js]"]
  node_buraco["Buraco rules<br/>[game.js]"]
  node_catan["Catan rules<br/>[game.js]"]
  node_caxeta["Caxeta rules<br/>[game.js]"]
  node_codenames["Código Secreto rules<br/>[game.js]"]
  node_coup["Coup rules<br/>[game.js]"]
  node_damas["Dama rules<br/>[game.js]"]
  node_hues["Hues and Cues rules<br/>[game.js]"]
  node_ito["Ito rules<br/>[game.js]"]
  node_paciencia["Paciência rules<br/>[game.js]"]
  node_scrabble["Scrabble rules<br/>[game.js]"]
  node_dictionary["Portuguese dictionary<br/>[dict.js]"]
  node_truco["Truco rules<br/>[game.js]"]
  node_uno["Uno rules<br/>[game.js]"]
  node_war["War rules<br/>[game.js]"]
  node_war2["War II rules<br/>[game.js]"]
end

node_players(("Players"))

node_players -->|"use"| node_browser
node_browser -.->|"opens game"| node_gameui
node_browser -.->|"sends actions"| node_transport
node_gameui -.->|"submits moves"| node_transport
node_players -->|"join and play"| node_localserver
node_localserver -->|"loads games"| node_registry
node_registry -->|"loads rules"| node_azul
node_registry -->|"loads rules"| node_bang
node_registry -->|"loads rules"| node_buraco
node_registry -->|"loads rules"| node_catan
node_registry -->|"loads rules"| node_caxeta
node_registry -->|"loads rules"| node_codenames
node_registry -->|"loads rules"| node_coup
node_registry -->|"loads rules"| node_damas
node_registry -->|"loads rules"| node_hues
node_registry -->|"loads rules"| node_ito
node_registry -->|"loads rules"| node_paciencia
node_registry -->|"loads rules"| node_scrabble
node_scrabble -->|"checks words"| node_dictionary
node_registry -->|"loads rules"| node_truco
node_registry -->|"loads rules"| node_uno
node_registry -->|"loads rules"| node_war
node_registry -->|"loads rules"| node_war2
node_players -->|"join and play"| node_edge
node_browser -.->|"cloud requests"| node_edge
node_edge -->|"checks access"| node_auth
node_edge -->|"routes requests"| node_core
node_core -->|"uses game rules"| node_cloudgames
node_edge -->|"reads and writes"| node_supabase
node_core -->|"room operations"| node_supabase
node_supabase -->|"publishes rooms"| node_realtime
node_browser -.->|"tablet mode"| node_tabletui

click node_browser "https://github.com/englucascaetano-stack/tablefone/blob/main/public/app.js"
click node_gameui "https://github.com/englucascaetano-stack/tablefone/tree/main/public/games"
click node_tabletui "https://github.com/englucascaetano-stack/tablefone/blob/main/public/tablet.js"
click node_transport "https://github.com/englucascaetano-stack/tablefone/blob/main/public/transport.js"
click node_localserver "https://github.com/englucascaetano-stack/tablefone/blob/main/server.js"
click node_registry "https://github.com/englucascaetano-stack/tablefone/blob/main/games/index.js"
click node_azul "https://github.com/englucascaetano-stack/tablefone/blob/main/games/azul/game.js"
click node_bang "https://github.com/englucascaetano-stack/tablefone/blob/main/games/bang/game.js"
click node_buraco "https://github.com/englucascaetano-stack/tablefone/blob/main/games/buraco/game.js"
click node_catan "https://github.com/englucascaetano-stack/tablefone/blob/main/games/catan/game.js"
click node_caxeta "https://github.com/englucascaetano-stack/tablefone/blob/main/games/caxeta/game.js"
click node_codenames "https://github.com/englucascaetano-stack/tablefone/blob/main/games/codenames/game.js"
click node_coup "https://github.com/englucascaetano-stack/tablefone/blob/main/games/coup/game.js"
click node_damas "https://github.com/englucascaetano-stack/tablefone/blob/main/games/damas/game.js"
click node_hues "https://github.com/englucascaetano-stack/tablefone/blob/main/games/huesandcues/game.js"
click node_ito "https://github.com/englucascaetano-stack/tablefone/blob/main/games/ito/game.js"
click node_paciencia "https://github.com/englucascaetano-stack/tablefone/blob/main/games/paciencia/game.js"
click node_scrabble "https://github.com/englucascaetano-stack/tablefone/blob/main/games/scrabble/game.js"
click node_dictionary "https://github.com/englucascaetano-stack/tablefone/blob/main/games/scrabble/dict.js"
click node_truco "https://github.com/englucascaetano-stack/tablefone/blob/main/games/truco/game.js"
click node_uno "https://github.com/englucascaetano-stack/tablefone/blob/main/games/uno/game.js"
click node_war "https://github.com/englucascaetano-stack/tablefone/blob/main/games/war/game.js"
click node_war2 "https://github.com/englucascaetano-stack/tablefone/blob/main/games/war2/game.js"
click node_edge "https://github.com/englucascaetano-stack/tablefone/blob/main/supabase/functions/mesa/index.ts"
click node_core "https://github.com/englucascaetano-stack/tablefone/blob/main/supabase/functions/mesa/core.mjs"
click node_auth "https://github.com/englucascaetano-stack/tablefone/blob/main/supabase/functions/mesa/auth.mjs"
click node_cloudgames "https://github.com/englucascaetano-stack/tablefone/tree/main/supabase/functions/mesa/games"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_browser,node_gameui,node_tabletui,node_transport toneBlue
class node_localserver toneAmber
class node_edge,node_core,node_auth,node_cloudgames,node_supabase,node_realtime toneMint
class node_registry,node_azul,node_bang,node_buraco,node_catan,node_caxeta,node_codenames,node_coup,node_damas,node_hues,node_ito,node_paciencia,node_scrabble,node_dictionary,node_truco,node_uno,node_war,node_war2 toneRose
class node_players toneIndigo
```

## Components

### Player interfaces

- [Browser shell](https://github.com/englucascaetano-stack/tablefone/blob/main/public/app.js): `public/app.js`
- [Game screens](https://github.com/englucascaetano-stack/tablefone/tree/main/public/games): `public/games`
- [Tablet display](https://github.com/englucascaetano-stack/tablefone/blob/main/public/tablet.js): `public/tablet.js`
- [Client transport](https://github.com/englucascaetano-stack/tablefone/blob/main/public/transport.js): `public/transport.js`

### Local game service

- [Local room server](https://github.com/englucascaetano-stack/tablefone/blob/main/server.js): `server.js`

### Cloud game service

- [Mesa Edge Function](https://github.com/englucascaetano-stack/tablefone/blob/main/supabase/functions/mesa/index.ts): `supabase/functions/mesa/index.ts`
- [Room and move logic](https://github.com/englucascaetano-stack/tablefone/blob/main/supabase/functions/mesa/core.mjs): `supabase/functions/mesa/core.mjs`
- [Access control](https://github.com/englucascaetano-stack/tablefone/blob/main/supabase/functions/mesa/auth.mjs): `supabase/functions/mesa/auth.mjs`
- [Cloud game rules](https://github.com/englucascaetano-stack/tablefone/tree/main/supabase/functions/mesa/games): `supabase/functions/mesa/games`
- **Supabase room data**
- **Supabase Realtime**

### Game library

- [Game registry](https://github.com/englucascaetano-stack/tablefone/blob/main/games/index.js): `games/index.js`
- [Azul rules](https://github.com/englucascaetano-stack/tablefone/blob/main/games/azul/game.js): `games/azul/game.js`
- [BANG! rules](https://github.com/englucascaetano-stack/tablefone/blob/main/games/bang/game.js): `games/bang/game.js`
- [Buraco rules](https://github.com/englucascaetano-stack/tablefone/blob/main/games/buraco/game.js): `games/buraco/game.js`
- [Catan rules](https://github.com/englucascaetano-stack/tablefone/blob/main/games/catan/game.js): `games/catan/game.js`
- [Caxeta rules](https://github.com/englucascaetano-stack/tablefone/blob/main/games/caxeta/game.js): `games/caxeta/game.js`
- [Código Secreto rules](https://github.com/englucascaetano-stack/tablefone/blob/main/games/codenames/game.js): `games/codenames/game.js`
- [Coup rules](https://github.com/englucascaetano-stack/tablefone/blob/main/games/coup/game.js): `games/coup/game.js`
- [Dama rules](https://github.com/englucascaetano-stack/tablefone/blob/main/games/damas/game.js): `games/damas/game.js`
- [Hues and Cues rules](https://github.com/englucascaetano-stack/tablefone/blob/main/games/huesandcues/game.js): `games/huesandcues/game.js`
- [Ito rules](https://github.com/englucascaetano-stack/tablefone/blob/main/games/ito/game.js): `games/ito/game.js`
- [Paciência rules](https://github.com/englucascaetano-stack/tablefone/blob/main/games/paciencia/game.js): `games/paciencia/game.js`
- [Scrabble rules](https://github.com/englucascaetano-stack/tablefone/blob/main/games/scrabble/game.js): `games/scrabble/game.js`
- [Portuguese dictionary](https://github.com/englucascaetano-stack/tablefone/blob/main/games/scrabble/dict.js): `games/scrabble/dict.js`
- [Truco rules](https://github.com/englucascaetano-stack/tablefone/blob/main/games/truco/game.js): `games/truco/game.js`
- [Uno rules](https://github.com/englucascaetano-stack/tablefone/blob/main/games/uno/game.js): `games/uno/game.js`
- [War rules](https://github.com/englucascaetano-stack/tablefone/blob/main/games/war/game.js): `games/war/game.js`
- [War II rules](https://github.com/englucascaetano-stack/tablefone/blob/main/games/war2/game.js): `games/war2/game.js`

### Other components

- **Players**

## Connections

- Players → Browser shell: use
- Browser shell → Game screens: opens game
- Browser shell → Client transport: sends actions
- Game screens → Client transport: submits moves
- Players → Local room server: join and play
- Local room server → Game registry: loads games (evidence: `server.js`)
- Game registry → Azul rules: loads rules (evidence: `games/index.js`)
- Game registry → BANG! rules: loads rules (evidence: `games/index.js`)
- Game registry → Buraco rules: loads rules (evidence: `games/index.js`)
- Game registry → Catan rules: loads rules (evidence: `games/index.js`)
- Game registry → Caxeta rules: loads rules (evidence: `games/index.js`)
- Game registry → Código Secreto rules: loads rules (evidence: `games/index.js`)
- Game registry → Coup rules: loads rules (evidence: `games/index.js`)
- Game registry → Dama rules: loads rules (evidence: `games/index.js`)
- Game registry → Hues and Cues rules: loads rules (evidence: `games/index.js`)
- Game registry → Ito rules: loads rules (evidence: `games/index.js`)
- Game registry → Paciência rules: loads rules (evidence: `games/index.js`)
- Game registry → Scrabble rules: loads rules (evidence: `games/index.js`)
- Scrabble rules → Portuguese dictionary: checks words (evidence: `games/scrabble/game.js`)
- Game registry → Truco rules: loads rules (evidence: `games/index.js`)
- Game registry → Uno rules: loads rules (evidence: `games/index.js`)
- Game registry → War rules: loads rules (evidence: `games/index.js`)
- Game registry → War II rules: loads rules (evidence: `games/index.js`)
- Players → Mesa Edge Function: join and play
- Browser shell → Mesa Edge Function: cloud requests
- Mesa Edge Function → Access control: checks access (evidence: `supabase/functions/mesa/index.ts`)
- Mesa Edge Function → Room and move logic: routes requests (evidence: `supabase/functions/mesa/index.ts`)
- Room and move logic → Cloud game rules: uses game rules (evidence: `supabase/functions/mesa/core.mjs`)
- Mesa Edge Function → Supabase room data: reads and writes
- Room and move logic → Supabase room data: room operations
- Supabase room data → Supabase Realtime: publishes rooms
- Browser shell → Tablet display: tablet mode
