How shivarora-sykkuno/saw-blades works
Project Type & Purpose
• This is a full-stack browser-based runner game. The client is a React single-page application (Canvas API for rendering) and the server is a Node.js/Express REST API with user authentication, score tracking, and activity logging. Data is persisted in a database (e.g., MongoDB via Mongoose).
File Structure Analysis
• Top-level:
• client/ – React app
– public/ holds static assets (HTML, sounds).
– src/ holds application code: entry points (index.js, App.jsx), pages (Login, Register, GamePage, Leaderboard, ActivityLog, Profile), and styles.css.
• server/ – Express API
– server.js – main Express app setup.
– routes/ – REST endpoints (auth.js, score.js, activity.js).
– middleware/ – authMiddleware.js enforces JWT authentication.
– models/ – Mongoose schemas (User.js, Activity.js).
• Shared: .gitignore, README.md.
README Insights
• Describes game mechanics, features (power-ups, scoring, audio), and setup (npm run server to start Express).
a. Main Components
1. Frontend (Browser)
– React SPA: UI pages, Canvas game engine, asset loader (audio, sprites).
2. Backend API Server
– Express app with three logical layers:
• Routes (REST endpoints for auth, scores, activity)
• Business logic/controllers
• Models (User, Activity)
3. Database
– NoSQL database (MongoDB) storing Users & Activities.
4. External Services (optional)
– Hosting/CDN for static assets, authentication provider (if any).
b. Relationships & Data Flow
• Browser ⟷ REST API over HTTPS
• Login/Register → POST /auth
• Fetch/Submit Score → GET/POST /score
• Fetch Activity Log → GET /activity
• Fetch Profile → GET /user/profile
• API Server ⟷ Database
• Queries & Writes to Users and Activities collections
• Auth Middleware
• Validates JWT on protected routes (score, activity, profile)
c. Architectural Patterns & Principles
• Separation of concerns:
• Client vs. Server vs. Database
• Within server: Models–Routes–Middleware (MVC-lite)
• Stateless RESTful API
• JWT-based authentication and authorization
• Single Page Application with componentized pages
d. Key Technologies
• Frontend: React, Canvas API, HTML5, CSS
• Backend: Node.js, Express, Mongoose (MongoDB)
• Authentication: JSON Web Tokens
• Build & Dev: npm, package.json scripts
Detailed Capture of Architectural Elements
• Canvas Engine (game loop, rendering)
• UI Pages (Login, GamePage, Leaderboard, etc.)
• Asset Loader (audio, images)
• Auth Middleware (JWT validation)
• Route Handlers (/auth, /score, /activity)
• Data Models (User, Activity)
• Optional external services (e.g., static file hosting).