# daik0t/fool-the-blacjack architecture

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

- Interactive diagram: https://gitdiagram.com/daik0t/fool-the-blacjack
- Repository: https://github.com/daik0t/fool-the-blacjack

## Overview

This repository implements a browser-based blackjack game with account registration/login, protected play and game routes, and a server API backed by PostgreSQL. The visible workflow starts in the client router: users can reach instructions, authentication, play setup, a game, or the leaderboard. During play, the game uses a deck and submits a score when the run ends; server routes dispatch authentication and score requests to controllers, which query the database. The README is generic Create React App material, so product details are based on the source index and excerpts; unsampled links are omitted.

Main entry points: [`src/client/App.jsx`](https://github.com/daik0t/fool-the-blacjack/blob/master/src/client/App.jsx) (App router), [`src/server/routes/index.js`](https://github.com/daik0t/fool-the-blacjack/blob/master/src/server/routes/index.js) (API router), [`src/server/config/db.js`](https://github.com/daik0t/fool-the-blacjack/blob/master/src/server/config/db.js) (DB connection), [`src/client/Game.jsx`](https://github.com/daik0t/fool-the-blacjack/blob/master/src/client/Game.jsx) (Game session)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client experience"]
  node_app["App router<br/>[App.jsx]"]
  node_home["Home menu<br/>[Main.jsx]"]
  node_instructions["Instructions<br/>[Instructions.jsx]"]
  node_leaderboard["Leaderboard<br/>[Leaderboard.jsx]"]
end

subgraph group_gameplay["Blackjack gameplay"]
  node_play["Play setup<br/>[Play.jsx]"]
  node_game["Game session<br/>[Game.jsx]"]
  node_deck["Card deck<br/>[deck.jsx]"]
  node_cardloader["Card preloader<br/>[preLoadCards.jsx]"]
end

subgraph group_identity["Identity"]
  node_authform["Login and signup<br/>[AuthFlipCard.jsx]"]
  node_authstate["Auth state<br/>[AuthContext.jsx]"]
end

subgraph group_server["Server API and data"]
  node_api["API router<br/>[index.js]"]
  node_login["Login handler<br/>[loginController.js]"]
  node_register["Registration handler"]
  node_scores["Score handler<br/>[gameController.js]"]
  node_users["User handler<br/>[userController.js]"]
  node_authmiddleware["Token middleware<br/>[authMiddleware.js]"]
  node_dbconfig["DB connection<br/>[db.js]"]
  node_database[("PostgreSQL")]
end

node_user(("Player"))

node_user -->|"uses"| node_app
node_app -->|"routes to"| node_home
node_app -->|"routes to"| node_instructions
node_app -->|"routes to"| node_leaderboard
node_app -->|"protects route"| node_play
node_app -->|"protects route"| node_game
node_app -->|"routes to"| node_authform
node_app -->|"reads auth"| node_authstate
node_authform -->|"sets session"| node_authstate
node_authform -->|"posts login"| node_api
node_authform -->|"posts signup"| node_api
node_api -->|"dispatches login"| node_login
node_api -->|"dispatches signup"| node_register
node_api -->|"dispatches scores"| node_scores
node_api -->|"dispatches users"| node_users
node_api -->|"checks token"| node_authmiddleware
node_game -->|"draws cards"| node_deck
node_play -->|"uses"| node_cardloader
node_game -->|"reads token"| node_authstate
node_game -->|"posts score"| node_api
node_login -->|"queries"| node_dbconfig
node_register -->|"writes user"| node_dbconfig
node_scores -->|"queries scores"| node_dbconfig
node_users -->|"queries users"| node_dbconfig
node_dbconfig -->|"connects"| node_database

click node_app "https://github.com/daik0t/fool-the-blacjack/blob/master/src/client/App.jsx"
click node_home "https://github.com/daik0t/fool-the-blacjack/blob/master/src/client/Main.jsx"
click node_instructions "https://github.com/daik0t/fool-the-blacjack/blob/master/src/client/Instructions.jsx"
click node_leaderboard "https://github.com/daik0t/fool-the-blacjack/blob/master/src/client/Leaderboard.jsx"
click node_play "https://github.com/daik0t/fool-the-blacjack/blob/master/src/client/Play.jsx"
click node_game "https://github.com/daik0t/fool-the-blacjack/blob/master/src/client/Game.jsx"
click node_deck "https://github.com/daik0t/fool-the-blacjack/blob/master/src/client/deck.jsx"
click node_cardloader "https://github.com/daik0t/fool-the-blacjack/blob/master/src/client/utils/preLoadCards.jsx"
click node_authform "https://github.com/daik0t/fool-the-blacjack/blob/master/src/client/components/AuthFlipCard.jsx"
click node_authstate "https://github.com/daik0t/fool-the-blacjack/blob/master/src/client/context/AuthContext.jsx"
click node_api "https://github.com/daik0t/fool-the-blacjack/blob/master/src/server/routes/index.js"
click node_login "https://github.com/daik0t/fool-the-blacjack/blob/master/src/server/controllers/loginController.js"
click node_register "https://github.com/daik0t/fool-the-blacjack/blob/master/src/server/controllers/registerController.js"
click node_scores "https://github.com/daik0t/fool-the-blacjack/blob/master/src/server/controllers/gameController.js"
click node_users "https://github.com/daik0t/fool-the-blacjack/blob/master/src/server/controllers/userController.js"
click node_authmiddleware "https://github.com/daik0t/fool-the-blacjack/blob/master/src/server/middleware/authMiddleware.js"
click node_dbconfig "https://github.com/daik0t/fool-the-blacjack/blob/master/src/server/config/db.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_app,node_home,node_instructions,node_leaderboard toneBlue
class node_play,node_game,node_deck,node_cardloader toneAmber
class node_authform,node_authstate toneMint
class node_api,node_login,node_register,node_scores,node_users,node_authmiddleware,node_dbconfig,node_database toneRose
class node_user toneIndigo
```

## Components

### Client experience

- [App router](https://github.com/daik0t/fool-the-blacjack/blob/master/src/client/App.jsx): `src/client/App.jsx`
- [Home menu](https://github.com/daik0t/fool-the-blacjack/blob/master/src/client/Main.jsx): `src/client/Main.jsx`
- [Instructions](https://github.com/daik0t/fool-the-blacjack/blob/master/src/client/Instructions.jsx): `src/client/Instructions.jsx`
- [Leaderboard](https://github.com/daik0t/fool-the-blacjack/blob/master/src/client/Leaderboard.jsx): `src/client/Leaderboard.jsx`

### Blackjack gameplay

- [Play setup](https://github.com/daik0t/fool-the-blacjack/blob/master/src/client/Play.jsx): `src/client/Play.jsx`
- [Game session](https://github.com/daik0t/fool-the-blacjack/blob/master/src/client/Game.jsx): `src/client/Game.jsx`
- [Card deck](https://github.com/daik0t/fool-the-blacjack/blob/master/src/client/deck.jsx): `src/client/deck.jsx`
- [Card preloader](https://github.com/daik0t/fool-the-blacjack/blob/master/src/client/utils/preLoadCards.jsx): `src/client/utils/preLoadCards.jsx`

### Identity

- [Login and signup](https://github.com/daik0t/fool-the-blacjack/blob/master/src/client/components/AuthFlipCard.jsx): `src/client/components/AuthFlipCard.jsx`
- [Auth state](https://github.com/daik0t/fool-the-blacjack/blob/master/src/client/context/AuthContext.jsx): `src/client/context/AuthContext.jsx`

### Server API and data

- [API router](https://github.com/daik0t/fool-the-blacjack/blob/master/src/server/routes/index.js): `src/server/routes/index.js`
- [Login handler](https://github.com/daik0t/fool-the-blacjack/blob/master/src/server/controllers/loginController.js): `src/server/controllers/loginController.js`
- [Registration handler](https://github.com/daik0t/fool-the-blacjack/blob/master/src/server/controllers/registerController.js): `src/server/controllers/registerController.js`
- [Score handler](https://github.com/daik0t/fool-the-blacjack/blob/master/src/server/controllers/gameController.js): `src/server/controllers/gameController.js`
- [User handler](https://github.com/daik0t/fool-the-blacjack/blob/master/src/server/controllers/userController.js): `src/server/controllers/userController.js`
- [Token middleware](https://github.com/daik0t/fool-the-blacjack/blob/master/src/server/middleware/authMiddleware.js): `src/server/middleware/authMiddleware.js`
- [DB connection](https://github.com/daik0t/fool-the-blacjack/blob/master/src/server/config/db.js): `src/server/config/db.js`
- **PostgreSQL**

### Other components

- **Player**

## Connections

- Player → App router: uses
- App router → Home menu: routes to (evidence: `src/client/App.jsx`)
- App router → Instructions: routes to (evidence: `src/client/App.jsx`)
- App router → Leaderboard: routes to (evidence: `src/client/App.jsx`)
- App router → Play setup: protects route (evidence: `src/client/App.jsx`)
- App router → Game session: protects route (evidence: `src/client/App.jsx`)
- App router → Login and signup: routes to (evidence: `src/client/App.jsx`)
- App router → Auth state: reads auth (evidence: `src/client/App.jsx`)
- Login and signup → Auth state: sets session (evidence: `src/client/components/AuthFlipCard.jsx`)
- Login and signup → API router: posts login (evidence: `src/client/components/AuthFlipCard.jsx`)
- Login and signup → API router: posts signup (evidence: `src/client/components/AuthFlipCard.jsx`)
- API router → Login handler: dispatches login (evidence: `src/server/routes/index.js`)
- API router → Registration handler: dispatches signup (evidence: `src/server/routes/index.js`)
- API router → Score handler: dispatches scores (evidence: `src/server/routes/index.js`)
- API router → User handler: dispatches users (evidence: `src/server/routes/index.js`)
- API router → Token middleware: checks token (evidence: `src/server/routes/index.js`)
- Game session → Card deck: draws cards (evidence: `src/client/Game.jsx`)
- Play setup → Card preloader: uses (evidence: `src/client/Play.jsx`)
- Game session → Auth state: reads token (evidence: `src/client/Game.jsx`)
- Game session → API router: posts score (evidence: `src/client/Game.jsx`)
- Login handler → DB connection: queries (evidence: `src/server/controllers/loginController.js`)
- Registration handler → DB connection: writes user (evidence: `src/server/controllers/registerController.js`)
- Score handler → DB connection: queries scores (evidence: `src/server/controllers/gameController.js`)
- User handler → DB connection: queries users (evidence: `src/server/controllers/userController.js`)
- DB connection → PostgreSQL: connects (evidence: `src/server/config/db.js`)
