How charizard00001/r-land-hunt works
Project type and purpose
• This is a full-stack web application (“R-Land Hunt”) for managing and playing location-based scavenger hunts.
• The README confirms two roles: an admin section for creating/managing hunts, and a participant section for viewing clues, leaderboards, and taking the hunt.
• Tech stack: Node.js + Express on the server, EJS templates + CSS/JS on the client, and a JavaScript-based database connector in data/database.js.
File structure
• Entry point: index.js
• Configuration: config/session.js (session setup)
• Middleware: middlewares/ (authentication, CSRF token, error handling)
• Routing: routes/ (separate route files for Oauth, auth, etc.)
• Controllers: controllers/ (one controller per feature: auth, startHunt, huntInfo, etc.)
• Models: models/ (User, Team, Hunt)
• Data access: data/database.js (DB connection and queries)
• Utilities: util/ (authentication helpers, flash messages)
• Presentation:
• views/ (EJS templates, includes)
• public/ (static assets: CSS under /CSS, client-side JS under /scripts)
Key architectural observations
• MVC-inspired pattern:
• Models encapsulate data schemas and DB operations.
• Views (EJS) render server-side HTML, injecting dynamic data.
• Controllers handle HTTP requests, call models, choose views or JSON responses.
• Middleware pipeline implements cross-cutting concerns (auth checks, CSRF protection, error handling).
• Session management for login state.
• Likely uses a single Node/Express process behind a hosting platform (Render).
Components
a. Presentation layer (Clients)
• Web browser, mobile browser
• Static assets: CSS files, client-side JS (geolocation, clue submission, leaderboard UI)
• EJS-rendered pages (login, register, hunt pages)
b. Application layer (Express server)
• index.js – Express app initialization
• Middleware chain (CSRF, check-auth, error handler)
• Router modules (routes/*.js)
• Controller modules handling business logic
• Utility modules (authentication helpers, flash messaging)
c. Data layer
• Database service (e.g., MongoDB or SQL engine)
• data/database.js – DB connector
• Model modules (models/*.model.js)
d. External services (optional)
• Geolocation API (client browser geolocation)
• Hosting platform (Render.com)
• OAuth providers if used (see routes/Oauth.routes.js)
Relationships and interactions
• Browser → HTTP(S) request → Express server
• Express → middleware → route matching → controller invocation
• Controller → model calls → database queries → data returned
• Controller → choose view template + data → EJS renders HTML → HTTP response → browser
• Client-side JS may make AJAX calls back to server controllers (e.g., fetching next clue, submitting hints)
• Session store interaction for maintaining user state between requests
Architectural patterns & principles
• Separation of concerns (presentation vs. business logic vs. data access)
• Layered architecture
• RESTful routing for resources (auth, hunts, teams)
• Modularization by feature (controllers + models per domain concept)
• Use of middleware for cross-cutting concerns