# priyanshutrivedi/gameclassix_backend architecture

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

- Interactive diagram: https://gitdiagram.com/priyanshutrivedi/gameclassix_backend
- Repository: https://github.com/priyanshutrivedi/gameclassix_backend

## Overview

This is a Node/Express backend for a browser-based games product, with single-player game assistance, multiplayer rooms, accounts, profiles, leaderboards, and per-game statistics. A typical flow is a client request routed by the server to a game controller, which may call a game helper or update a statistics model; room play also uses Socket.IO events and shared in-memory room state. The excerpts show several controller relationships directly; other controller-to-helper/model links are supported by the SOURCE INDEX. Unshown controller behavior and storage wiring are not inferred.

Main entry points: [`index.js`](https://github.com/priyanshutrivedi/gameclassix_backend/blob/master/index.js) (HTTP and Socket.IO server), [`controllers/authController.js`](https://github.com/priyanshutrivedi/gameclassix_backend/blob/master/controllers/authController.js) (Authentication), [`controllers/BingoController.js`](https://github.com/priyanshutrivedi/gameclassix_backend/blob/master/controllers/BingoController.js) (Bingo API), [`controllers/DotAndBoxesController.js`](https://github.com/priyanshutrivedi/gameclassix_backend/blob/master/controllers/DotAndBoxesController.js) (Dots and Boxes API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["API and realtime"]
  node_server["HTTP and Socket.IO server<br/>[index.js]"]
  node_rooms["Room endpoints<br/>[RoomController.js]"]
end

subgraph group_games["Game logic"]
  node_bingo["Bingo API<br/>[BingoController.js]"]
  node_dots["Dots and Boxes API"]
  node_minesweeper["Minesweeper API"]
  node_sudoku["Sudoku API"]
  node_ttt["Tic-Tac-Toe API"]
  node_bingo_ai["Bingo board and move logic"]
  node_bingo_board["Bingo board generator"]
  node_dots_ai["Dots move logic"]
  node_mine_board["Minefield generator"]
  node_sudoku_gen["Sudoku generator"]
  node_ttt_difficulty["Difficulty-based moves"]
  node_ttt_optimal["Optimal move logic"]
end

subgraph group_accounts["Accounts and rankings"]
  node_auth["Authentication<br/>[authController.js]"]
  node_profile["Profile management"]
  node_leaderboard["Leaderboards"]
  node_users[("User records<br/>[user.js]")]
end

subgraph group_stats["Game statistics"]
  node_bingo_stats[("Bingo statistics<br/>[BingoStats.js]")]
  node_dots_stats[("Dots statistics<br/>[DotBoxesStats.js]")]
  node_mine_stats[("Minesweeper statistics")]
  node_sudoku_stats[("Sudoku statistics<br/>[SudokuStats.js]")]
  node_ttt_stats[("Tic-Tac-Toe statistics<br/>[TicTacToeStats.js]")]
end

subgraph group_runtime["Runtime state"]
  node_room_state["Room state<br/>[shared.js]"]
  node_db["Database connection<br/>[db.js]"]
  node_token["Token verification<br/>[verifyToken.js]"]
end

node_client(("Game client"))

node_client -->|"sends requests"| node_server
node_server -->|"routes auth"| node_auth
node_server -->|"routes profiles"| node_profile
node_server -->|"routes rankings"| node_leaderboard
node_server -->|"routes bingo"| node_bingo
node_server -->|"routes dots"| node_dots
node_server -->|"routes minesweeper"| node_minesweeper
node_server -->|"routes sudoku"| node_sudoku
node_server -->|"routes tic-tac-toe"| node_ttt
node_server -->|"routes rooms"| node_rooms
node_server -->|"reads and updates"| node_room_state
node_rooms -->|"checks room state"| node_room_state
node_auth -->|"creates and queries"| node_users
node_auth -->|"creates and reads"| node_bingo_stats
node_auth -->|"creates and reads"| node_dots_stats
node_auth -->|"creates and reads"| node_mine_stats
node_auth -->|"creates and reads"| node_sudoku_stats
node_auth -->|"creates and reads"| node_ttt_stats
node_profile -->|"reads and updates"| node_users
node_leaderboard -->|"aggregates rankings"| node_users
node_bingo -->|"requests move"| node_bingo_ai
node_bingo -->|"generates board"| node_bingo_board
node_bingo -->|"updates statistics"| node_bingo_stats
node_dots -->|"requests move"| node_dots_ai
node_dots -->|"updates statistics"| node_dots_stats
node_minesweeper -->|"generates board"| node_mine_board
node_minesweeper -->|"updates statistics"| node_mine_stats
node_sudoku -->|"generates puzzle"| node_sudoku_gen
node_sudoku -->|"updates statistics"| node_sudoku_stats
node_ttt -->|"requests move"| node_ttt_difficulty
node_ttt -->|"updates statistics"| node_ttt_stats
node_ttt_difficulty -->|"delegates move"| node_ttt_optimal
node_server -->|"connects database"| node_db
node_dots -->|"uses verification"| node_token

click node_server "https://github.com/priyanshutrivedi/gameclassix_backend/blob/master/index.js"
click node_rooms "https://github.com/priyanshutrivedi/gameclassix_backend/blob/master/controllers/RoomController.js"
click node_auth "https://github.com/priyanshutrivedi/gameclassix_backend/blob/master/controllers/authController.js"
click node_profile "https://github.com/priyanshutrivedi/gameclassix_backend/blob/master/controllers/profileController.js"
click node_leaderboard "https://github.com/priyanshutrivedi/gameclassix_backend/blob/master/controllers/LeaderBoardController.js"
click node_bingo "https://github.com/priyanshutrivedi/gameclassix_backend/blob/master/controllers/BingoController.js"
click node_dots "https://github.com/priyanshutrivedi/gameclassix_backend/blob/master/controllers/DotAndBoxesController.js"
click node_minesweeper "https://github.com/priyanshutrivedi/gameclassix_backend/blob/master/controllers/MinesweeperController.js"
click node_sudoku "https://github.com/priyanshutrivedi/gameclassix_backend/blob/master/controllers/SudokuController.js"
click node_ttt "https://github.com/priyanshutrivedi/gameclassix_backend/blob/master/controllers/TicTacToeController.js"
click node_bingo_ai "https://github.com/priyanshutrivedi/gameclassix_backend/blob/master/HelperFunctions/Bingo/Bingo_FindOptimalNumber.js"
click node_bingo_board "https://github.com/priyanshutrivedi/gameclassix_backend/blob/master/HelperFunctions/Bingo/Bingo_createRandomBoard.js"
click node_dots_ai "https://github.com/priyanshutrivedi/gameclassix_backend/blob/master/HelperFunctions/DotAndBoxes/DotAndBoxes_FindOptimalMove.js"
click node_mine_board "https://github.com/priyanshutrivedi/gameclassix_backend/blob/master/HelperFunctions/Minesweeper/Minesweeper_FindRandomBoardBoard.js"
click node_sudoku_gen "https://github.com/priyanshutrivedi/gameclassix_backend/blob/master/HelperFunctions/Sudoku/Sudoku_RandomSolvableSudokuWithSolution.js"
click node_ttt_difficulty "https://github.com/priyanshutrivedi/gameclassix_backend/blob/master/HelperFunctions/TicTacToe/TicTacToe_FindMoveAccToDifficulty.js"
click node_ttt_optimal "https://github.com/priyanshutrivedi/gameclassix_backend/blob/master/HelperFunctions/TicTacToe/TicTacToe_FindOptimalMove.js"
click node_users "https://github.com/priyanshutrivedi/gameclassix_backend/blob/master/models/user.js"
click node_bingo_stats "https://github.com/priyanshutrivedi/gameclassix_backend/blob/master/models/BingoStats.js"
click node_dots_stats "https://github.com/priyanshutrivedi/gameclassix_backend/blob/master/models/DotBoxesStats.js"
click node_mine_stats "https://github.com/priyanshutrivedi/gameclassix_backend/blob/master/models/MinesweeperStats.js"
click node_sudoku_stats "https://github.com/priyanshutrivedi/gameclassix_backend/blob/master/models/SudokuStats.js"
click node_ttt_stats "https://github.com/priyanshutrivedi/gameclassix_backend/blob/master/models/TicTacToeStats.js"
click node_room_state "https://github.com/priyanshutrivedi/gameclassix_backend/blob/master/shared.js"
click node_db "https://github.com/priyanshutrivedi/gameclassix_backend/blob/master/db/db.js"
click node_token "https://github.com/priyanshutrivedi/gameclassix_backend/blob/master/middlewares/verifyToken.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_server,node_rooms,node_client toneBlue
class node_bingo,node_dots,node_minesweeper,node_sudoku,node_ttt,node_bingo_ai,node_bingo_board,node_dots_ai,node_mine_board,node_sudoku_gen,node_ttt_difficulty,node_ttt_optimal toneAmber
class node_auth,node_profile,node_leaderboard,node_users toneMint
class node_bingo_stats,node_dots_stats,node_mine_stats,node_sudoku_stats,node_ttt_stats toneRose
class node_room_state,node_db,node_token toneIndigo
```

## Components

### API and realtime

- [HTTP and Socket.IO server](https://github.com/priyanshutrivedi/gameclassix_backend/blob/master/index.js): `index.js`
- [Room endpoints](https://github.com/priyanshutrivedi/gameclassix_backend/blob/master/controllers/RoomController.js): `controllers/RoomController.js`

### Game logic

- [Bingo API](https://github.com/priyanshutrivedi/gameclassix_backend/blob/master/controllers/BingoController.js): `controllers/BingoController.js`
- [Dots and Boxes API](https://github.com/priyanshutrivedi/gameclassix_backend/blob/master/controllers/DotAndBoxesController.js): `controllers/DotAndBoxesController.js`
- [Minesweeper API](https://github.com/priyanshutrivedi/gameclassix_backend/blob/master/controllers/MinesweeperController.js): `controllers/MinesweeperController.js`
- [Sudoku API](https://github.com/priyanshutrivedi/gameclassix_backend/blob/master/controllers/SudokuController.js): `controllers/SudokuController.js`
- [Tic-Tac-Toe API](https://github.com/priyanshutrivedi/gameclassix_backend/blob/master/controllers/TicTacToeController.js): `controllers/TicTacToeController.js`
- [Bingo board and move logic](https://github.com/priyanshutrivedi/gameclassix_backend/blob/master/HelperFunctions/Bingo/Bingo_FindOptimalNumber.js): `HelperFunctions/Bingo/Bingo_FindOptimalNumber.js`
- [Bingo board generator](https://github.com/priyanshutrivedi/gameclassix_backend/blob/master/HelperFunctions/Bingo/Bingo_createRandomBoard.js): `HelperFunctions/Bingo/Bingo_createRandomBoard.js`
- [Dots move logic](https://github.com/priyanshutrivedi/gameclassix_backend/blob/master/HelperFunctions/DotAndBoxes/DotAndBoxes_FindOptimalMove.js): `HelperFunctions/DotAndBoxes/DotAndBoxes_FindOptimalMove.js`
- [Minefield generator](https://github.com/priyanshutrivedi/gameclassix_backend/blob/master/HelperFunctions/Minesweeper/Minesweeper_FindRandomBoardBoard.js): `HelperFunctions/Minesweeper/Minesweeper_FindRandomBoardBoard.js`
- [Sudoku generator](https://github.com/priyanshutrivedi/gameclassix_backend/blob/master/HelperFunctions/Sudoku/Sudoku_RandomSolvableSudokuWithSolution.js): `HelperFunctions/Sudoku/Sudoku_RandomSolvableSudokuWithSolution.js`
- [Difficulty-based moves](https://github.com/priyanshutrivedi/gameclassix_backend/blob/master/HelperFunctions/TicTacToe/TicTacToe_FindMoveAccToDifficulty.js): `HelperFunctions/TicTacToe/TicTacToe_FindMoveAccToDifficulty.js`
- [Optimal move logic](https://github.com/priyanshutrivedi/gameclassix_backend/blob/master/HelperFunctions/TicTacToe/TicTacToe_FindOptimalMove.js): `HelperFunctions/TicTacToe/TicTacToe_FindOptimalMove.js`

### Accounts and rankings

- [Authentication](https://github.com/priyanshutrivedi/gameclassix_backend/blob/master/controllers/authController.js): `controllers/authController.js`
- [Profile management](https://github.com/priyanshutrivedi/gameclassix_backend/blob/master/controllers/profileController.js): `controllers/profileController.js`
- [Leaderboards](https://github.com/priyanshutrivedi/gameclassix_backend/blob/master/controllers/LeaderBoardController.js): `controllers/LeaderBoardController.js`
- [User records](https://github.com/priyanshutrivedi/gameclassix_backend/blob/master/models/user.js): `models/user.js`

### Game statistics

- [Bingo statistics](https://github.com/priyanshutrivedi/gameclassix_backend/blob/master/models/BingoStats.js): `models/BingoStats.js`
- [Dots statistics](https://github.com/priyanshutrivedi/gameclassix_backend/blob/master/models/DotBoxesStats.js): `models/DotBoxesStats.js`
- [Minesweeper statistics](https://github.com/priyanshutrivedi/gameclassix_backend/blob/master/models/MinesweeperStats.js): `models/MinesweeperStats.js`
- [Sudoku statistics](https://github.com/priyanshutrivedi/gameclassix_backend/blob/master/models/SudokuStats.js): `models/SudokuStats.js`
- [Tic-Tac-Toe statistics](https://github.com/priyanshutrivedi/gameclassix_backend/blob/master/models/TicTacToeStats.js): `models/TicTacToeStats.js`

### Runtime state

- [Room state](https://github.com/priyanshutrivedi/gameclassix_backend/blob/master/shared.js): `shared.js`
- [Database connection](https://github.com/priyanshutrivedi/gameclassix_backend/blob/master/db/db.js): `db/db.js`
- [Token verification](https://github.com/priyanshutrivedi/gameclassix_backend/blob/master/middlewares/verifyToken.js): `middlewares/verifyToken.js`

### Other components

- **Game client**

## Connections

- Game client → HTTP and Socket.IO server: sends requests
- HTTP and Socket.IO server → Authentication: routes auth (evidence: `index.js`)
- HTTP and Socket.IO server → Profile management: routes profiles (evidence: `index.js`)
- HTTP and Socket.IO server → Leaderboards: routes rankings (evidence: `index.js`)
- HTTP and Socket.IO server → Bingo API: routes bingo (evidence: `index.js`)
- HTTP and Socket.IO server → Dots and Boxes API: routes dots (evidence: `index.js`)
- HTTP and Socket.IO server → Minesweeper API: routes minesweeper (evidence: `index.js`)
- HTTP and Socket.IO server → Sudoku API: routes sudoku (evidence: `index.js`)
- HTTP and Socket.IO server → Tic-Tac-Toe API: routes tic-tac-toe (evidence: `index.js`)
- HTTP and Socket.IO server → Room endpoints: routes rooms (evidence: `index.js`)
- HTTP and Socket.IO server → Room state: reads and updates (evidence: `index.js`)
- Room endpoints → Room state: checks room state (evidence: `controllers/RoomController.js`)
- Authentication → User records: creates and queries (evidence: `controllers/authController.js`)
- Authentication → Bingo statistics: creates and reads (evidence: `controllers/authController.js`)
- Authentication → Dots statistics: creates and reads (evidence: `controllers/authController.js`)
- Authentication → Minesweeper statistics: creates and reads (evidence: `controllers/authController.js`)
- Authentication → Sudoku statistics: creates and reads (evidence: `controllers/authController.js`)
- Authentication → Tic-Tac-Toe statistics: creates and reads (evidence: `controllers/authController.js`)
- Profile management → User records: reads and updates (evidence: `controllers/profileController.js`)
- Leaderboards → User records: aggregates rankings (evidence: `controllers/LeaderBoardController.js`)
- Bingo API → Bingo board and move logic: requests move (evidence: `controllers/BingoController.js`)
- Bingo API → Bingo board generator: generates board (evidence: `controllers/BingoController.js`)
- Bingo API → Bingo statistics: updates statistics (evidence: `controllers/BingoController.js`)
- Dots and Boxes API → Dots move logic: requests move (evidence: `controllers/DotAndBoxesController.js`)
- Dots and Boxes API → Dots statistics: updates statistics (evidence: `controllers/DotAndBoxesController.js`)
- Minesweeper API → Minefield generator: generates board (evidence: `controllers/MinesweeperController.js`)
- Minesweeper API → Minesweeper statistics: updates statistics (evidence: `controllers/MinesweeperController.js`)
- Sudoku API → Sudoku generator: generates puzzle (evidence: `controllers/SudokuController.js`)
- Sudoku API → Sudoku statistics: updates statistics (evidence: `controllers/SudokuController.js`)
- Tic-Tac-Toe API → Difficulty-based moves: requests move (evidence: `controllers/TicTacToeController.js`)
- Tic-Tac-Toe API → Tic-Tac-Toe statistics: updates statistics (evidence: `controllers/TicTacToeController.js`)
- Difficulty-based moves → Optimal move logic: delegates move (evidence: `HelperFunctions/TicTacToe/TicTacToe_FindMoveAccToDifficulty.js`)
- HTTP and Socket.IO server → Database connection: connects database (evidence: `index.js`)
- Dots and Boxes API → Token verification: uses verification (evidence: `controllers/DotAndBoxesController.js`)
