How daik0t/fool-the-blacjack works
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: App.jsx App router · index.js API router · db.js DB connection · Game.jsx Game session
Components 19
Client experience
- App router
src/client/App.jsx - Home menu
src/client/Main.jsx - Instructions
src/client/Instructions.jsx - Leaderboard
src/client/Leaderboard.jsx
Blackjack gameplay
- Play setup
src/client/Play.jsx - Game session
src/client/Game.jsx - Card deck
src/client/deck.jsx - Card preloader
src/client/utils/preLoadCards.jsx
Identity
- Login and signup
src/client/components/AuthFlipCard.jsx - Auth state
src/client/context/AuthContext.jsx
Server API and data
- API router
src/server/routes/index.js - Login handler
src/server/controllers/loginController.js - Registration handler
src/server/controllers/registerController.js - Score handler
src/server/controllers/gameController.js - User handler
src/server/controllers/userController.js - Token middleware
src/server/middleware/authMiddleware.js - DB connection
src/server/config/db.js - PostgreSQL
Other components
- Player
Connections 25
- Player → App router: uses
- App router → Home menu: routes to
src/client/App.jsx - App router → Instructions: routes to
src/client/App.jsx - App router → Leaderboard: routes to
src/client/App.jsx - App router → Play setup: protects route
src/client/App.jsx - App router → Game session: protects route
src/client/App.jsx - App router → Login and signup: routes to
src/client/App.jsx - App router → Auth state: reads auth
src/client/App.jsx - Login and signup → Auth state: sets session
src/client/components/AuthFlipCard.jsx - Login and signup → API router: posts login
src/client/components/AuthFlipCard.jsx - Login and signup → API router: posts signup
src/client/components/AuthFlipCard.jsx - API router → Login handler: dispatches login
src/server/routes/index.js - API router → Registration handler: dispatches signup
src/server/routes/index.js - API router → Score handler: dispatches scores
src/server/routes/index.js - API router → User handler: dispatches users
src/server/routes/index.js - API router → Token middleware: checks token
src/server/routes/index.js - Game session → Card deck: draws cards
src/client/Game.jsx - Play setup → Card preloader: uses
src/client/Play.jsx - Game session → Auth state: reads token
src/client/Game.jsx - Game session → API router: posts score
src/client/Game.jsx - Login handler → DB connection: queries
src/server/controllers/loginController.js - Registration handler → DB connection: writes user
src/server/controllers/registerController.js - Score handler → DB connection: queries scores
src/server/controllers/gameController.js - User handler → DB connection: queries users
src/server/controllers/userController.js - DB connection → PostgreSQL: connects
src/server/config/db.js