How mwanzia-simon/reaction-time-game works
Project type & purpose (from README + tree)
This is a full-stack web application: a Reaction Time Game with:
• A browser-based frontend (HTML/CSS/vanilla JS) that runs the game, plays sounds, and shows pages (login/signup/game/leaderboard).
• A Node.js backend (Backend/app.js) that likely exposes HTTP endpoints for authentication and leaderboard/score persistence.
• A simple JSON file database (Backend/db.json) acting as the persistence layer (common patterns: direct file reads/writes, or a json-server-style storage).
Frontend (Frontend/)
• Pages (routing is page-based, not SPA routing):
• index.html (landing)
• login.html, signup.html (auth UI)
• game.html (main game UI)
• leaderboard.html (score display)
• Client logic:
• main.js (likely core game + navigation + API calls)
• leaderboard.js (fetch/render leaderboard)
• Static assets:
• assets/*.wav (sound effects)
• style.css
This suggests: static file hosting + client-side JS calling backend APIs.
Backend (Backend/)
• app.js indicates a single Node server entrypoint (often Express).
• db.json indicates persistence via local JSON (no separate DB service like Postgres).
Browser (Frontend)
• Loads *.html, style.css, *.js, assets/*.wav
• Runs reaction-time logic locally
Node.js Backend Server
• Serves API (and possibly serves static frontend too—unclear from tree; represent as either a separate static host or “Node serves static + API” with a note/assumption)
Persistence: db.json
• File-based datastore (scores/users/leaderboard)
(Optional but useful) Local/Deployed Environment
• If this runs locally: “Developer machine”
Important architectural patterns to highlight (based on repo)
• Classic 3-tier-ish split:
• Presentation: static HTML/CSS/JS
• Application/API: Node server (app.js)
• Data: JSON file (db.json)
• Page-based frontend rather than a framework SPA:
• Each HTML file is a “view”; JS files attach behavior and call APIs.
Open Backend/app.js and confirm
• Are static frontend files served by Node (express.static) or is frontend expected to be opened directly / hosted separately?
• The actual route names for login/signup/leaderboard/score.
• Any middleware (CORS, sessions, JWT).
Inspect db.json
• What are the top-level collections? (users, scores, etc.)
• If tokens exist: include “JWT in Authorization header”.