# dev-rafayel/games-c-js architecture

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

- Interactive diagram: https://gitdiagram.com/dev-rafayel/games-c-js
- Repository: https://github.com/dev-rafayel/games-c-js

## Overview

The repository contains three standalone games: a browser chess game, a C terminal tic-tac-toe game, and a browser tic-tac-toe game. Chess separates board state and move coordination from piece-specific move rules and DOM rendering; each tic-tac-toe implementation handles its own input, game state, win/draw detection, and presentation. The supplied excerpts support the chess call relationships; the two tic-tac-toe games are each implemented in a single file.

Main entry points: [`Chess/Game_logic/main.js`](https://github.com/dev-rafayel/games-c-js/blob/main/Chess/Game_logic/main.js) (Board state), [`Chess/Pieces/Piece.js`](https://github.com/dev-rafayel/games-c-js/blob/main/Chess/Pieces/Piece.js) (Piece base), [`Chess/UI/board.js`](https://github.com/dev-rafayel/games-c-js/blob/main/Chess/UI/board.js) (Board interface), [`Chess/Pieces/Pawn.js`](https://github.com/dev-rafayel/games-c-js/blob/main/Chess/Pieces/Pawn.js) (Pawn moves)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_chess_rules["Chess rules"]
  node_chess_board["Board state<br/>[main.js]"]
  node_piece_base["Piece base<br/>[Piece.js]"]
  node_pawn["Pawn moves<br/>[Pawn.js]"]
  node_rook["Rook moves<br/>[Rook.js]"]
  node_knight["Knight moves<br/>[Knight.js]"]
  node_bishop["Bishop moves<br/>[Bishop.js]"]
  node_queen["Queen moves<br/>[Queen.js]"]
  node_king["King moves<br/>[King.js]"]
end

subgraph group_chess_ui["Chess interface"]
  node_chess_interface["Board interface<br/>[board.js]"]
end

subgraph group_c_ttt["C tic-tac-toe"]
  node_c_tictactoe["Terminal game<br/>[code.c]"]
end

subgraph group_js_ttt["Browser tic-tac-toe"]
  node_js_tictactoe["Browser game<br/>[game.js]"]
end

node_chess_player(("Chess player"))
node_terminal_player(("Terminal player"))
node_browser_player(("Browser player"))

node_chess_player -->|"clicks squares"| node_chess_interface
node_chess_interface -->|"queries moves"| node_chess_board
node_chess_interface -->|"applies moves"| node_chess_board
node_chess_board -->|"creates pieces"| node_pawn
node_chess_board -->|"creates pieces"| node_rook
node_chess_board -->|"creates pieces"| node_knight
node_chess_board -->|"creates pieces"| node_bishop
node_chess_board -->|"creates pieces"| node_queen
node_chess_board -->|"creates pieces"| node_king
node_pawn -->|"extends"| node_piece_base
node_rook -->|"extends"| node_piece_base
node_knight -->|"extends"| node_piece_base
node_bishop -->|"extends"| node_piece_base
node_queen -->|"extends"| node_piece_base
node_king -->|"extends"| node_piece_base
node_terminal_player -->|"enters moves"| node_c_tictactoe
node_browser_player -->|"clicks cells"| node_js_tictactoe

click node_chess_board "https://github.com/dev-rafayel/games-c-js/blob/main/Chess/Game_logic/main.js"
click node_piece_base "https://github.com/dev-rafayel/games-c-js/blob/main/Chess/Pieces/Piece.js"
click node_pawn "https://github.com/dev-rafayel/games-c-js/blob/main/Chess/Pieces/Pawn.js"
click node_rook "https://github.com/dev-rafayel/games-c-js/blob/main/Chess/Pieces/Rook.js"
click node_knight "https://github.com/dev-rafayel/games-c-js/blob/main/Chess/Pieces/Knight.js"
click node_bishop "https://github.com/dev-rafayel/games-c-js/blob/main/Chess/Pieces/Bishop.js"
click node_queen "https://github.com/dev-rafayel/games-c-js/blob/main/Chess/Pieces/Queen.js"
click node_king "https://github.com/dev-rafayel/games-c-js/blob/main/Chess/Pieces/King.js"
click node_chess_interface "https://github.com/dev-rafayel/games-c-js/blob/main/Chess/UI/board.js"
click node_c_tictactoe "https://github.com/dev-rafayel/games-c-js/blob/main/C_tictactoe/code.c"
click node_js_tictactoe "https://github.com/dev-rafayel/games-c-js/blob/main/JS_tictactoe/game.js"

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_chess_board,node_piece_base,node_pawn,node_rook,node_knight,node_bishop,node_queen,node_king,node_browser_player toneBlue
class node_chess_interface toneAmber
class node_c_tictactoe toneMint
class node_js_tictactoe toneRose
class node_chess_player,node_terminal_player toneIndigo
```

## Components

### Chess rules

- [Board state](https://github.com/dev-rafayel/games-c-js/blob/main/Chess/Game_logic/main.js): `Chess/Game_logic/main.js`
- [Piece base](https://github.com/dev-rafayel/games-c-js/blob/main/Chess/Pieces/Piece.js): `Chess/Pieces/Piece.js`
- [Pawn moves](https://github.com/dev-rafayel/games-c-js/blob/main/Chess/Pieces/Pawn.js): `Chess/Pieces/Pawn.js`
- [Rook moves](https://github.com/dev-rafayel/games-c-js/blob/main/Chess/Pieces/Rook.js): `Chess/Pieces/Rook.js`
- [Knight moves](https://github.com/dev-rafayel/games-c-js/blob/main/Chess/Pieces/Knight.js): `Chess/Pieces/Knight.js`
- [Bishop moves](https://github.com/dev-rafayel/games-c-js/blob/main/Chess/Pieces/Bishop.js): `Chess/Pieces/Bishop.js`
- [Queen moves](https://github.com/dev-rafayel/games-c-js/blob/main/Chess/Pieces/Queen.js): `Chess/Pieces/Queen.js`
- [King moves](https://github.com/dev-rafayel/games-c-js/blob/main/Chess/Pieces/King.js): `Chess/Pieces/King.js`

### Chess interface

- [Board interface](https://github.com/dev-rafayel/games-c-js/blob/main/Chess/UI/board.js): `Chess/UI/board.js`

### C tic-tac-toe

- [Terminal game](https://github.com/dev-rafayel/games-c-js/blob/main/C_tictactoe/code.c): `C_tictactoe/code.c`

### Browser tic-tac-toe

- [Browser game](https://github.com/dev-rafayel/games-c-js/blob/main/JS_tictactoe/game.js): `JS_tictactoe/game.js`

### Other components

- **Chess player**
- **Terminal player**
- **Browser player**

## Connections

- Chess player → Board interface: clicks squares (evidence: `Chess/UI/board.js`)
- Board interface → Board state: queries moves (evidence: `Chess/UI/board.js`)
- Board interface → Board state: applies moves (evidence: `Chess/UI/board.js`)
- Board state → Pawn moves: creates pieces (evidence: `Chess/Game_logic/main.js`)
- Board state → Rook moves: creates pieces (evidence: `Chess/Game_logic/main.js`)
- Board state → Knight moves: creates pieces (evidence: `Chess/Game_logic/main.js`)
- Board state → Bishop moves: creates pieces (evidence: `Chess/Game_logic/main.js`)
- Board state → Queen moves: creates pieces (evidence: `Chess/Game_logic/main.js`)
- Board state → King moves: creates pieces (evidence: `Chess/Game_logic/main.js`)
- Pawn moves → Piece base: extends (evidence: `Chess/Pieces/Pawn.js`)
- Rook moves → Piece base: extends (evidence: `Chess/Pieces/Rook.js`)
- Knight moves → Piece base: extends (evidence: `Chess/Pieces/Knight.js`)
- Bishop moves → Piece base: extends (evidence: `Chess/Pieces/Bishop.js`)
- Queen moves → Piece base: extends (evidence: `Chess/Pieces/Queen.js`)
- King moves → Piece base: extends (evidence: `Chess/Pieces/King.js`)
- Terminal player → Terminal game: enters moves (evidence: `C_tictactoe/code.c`)
- Browser player → Browser game: clicks cells (evidence: `JS_tictactoe/game.js`)
