How karla0311/geoquest works
1. Overall shape
GeoQuest is a two-tier app: a React/Vite client in client/ and an Express API in server/. The browser talks only to the client, and the client talks to the server over HTTP. The server is the main boundary for game logic, persistence, and protected operations.
2. Client presentation layer
The client is a single-page application with route-based screens in src/pages/ such as Landing, Login/Register, Dashboard, Game, Results, Leaderboard, and Forum. router.jsx wires navigation, while Navbar and LeaderboardTable are shared UI pieces.
3. Client state and orchestration
AuthContext and GameContext hold cross-page state such as logged-in user/session data and the current quiz/game state. This keeps page components thin: they render UI, call context actions, and delegate server interaction to API services.
4. Client API boundary
The client uses a small service layer in src/api/ (authService, gameService, leaderboardService, plus a shared api.js). This is the only place the UI should know about backend endpoints, which makes the architecture easy to diagram as: pages/components → context/services → server API.
5. Game flow
The quiz flow starts on the client, but the server supplies game content and likely validates/scorers results. The client has local scoring helpers in src/utils/scoring.js and formatting helpers like formatTime.js, while the server also has its own scoring utility in server/utils/scoring.js, suggesting server-side authority for final score computation or validation.
6. Backend API layer
The Express app is split by domain routes in server/routes/: auth, game, leaderboard, forum, and stats. Each route maps to a controller in server/controllers/, keeping request handling separate from business logic.
7. Backend business logic and services
Controllers delegate to services in server/services/ (gameService, leaderboardService, analyticsService). This indicates a service-oriented backend structure where controllers parse/validate requests and services perform the actual domain work, data lookup, and persistence coordination.
8. Data sources and persistence
Quiz content appears to come from local JSON files in server/data/ (countries.json, capitals.json, flags.json). Persistent shared data such as auth, leaderboards, forum content, and analytics likely lives in Supabase, configured through server/config/supabaseClient.js and the Supabase environment variables called out in the README.
9. Security and request protection
The server has authMiddleware, rateLimiter, and errorHandler, which defines clear operational boundaries: some routes are protected, public endpoints are throttled, and errors are normalized centrally. server/utils/validation.js suggests input checks happen before data reaches the service layer.
10. Analytics and leaderboard pipeline
Game outcomes likely feed into statsRoutes/analyticsController and leaderboard routes. That creates a post-game flow from client results submission to server-side aggregation, then back out through leaderboard reads to the client leaderboard pages.
11. Runtime and deployment topology
The client runs on Vite at localhost:5173, and the server runs independently on localhost:8000. They are separate Node 18+ processes, which is important for the diagram: the frontend is not server-rendered, and the API can be developed, secured, and scaled separately.
12. What to emphasize in an architecture diagram
Draw three main boxes: the React SPA, the Express API, and Supabase. Inside the API box, show route/controller/service layering plus shared middleware. Inside the SPA box, show pages, contexts, and API services. Connect the game, auth, leaderboard, forum, and stats flows between the SPA and API, and show local JSON game content as a backend-only static data source.
Main entry points: services Services · pages Screens · controllers Controllers · GameContext.jsx Game State
Components 16
Client SPA
React/Vite single-page app
- GeoQuest UI · Browser application shell and user entrypoint
client/src/App.jsx - Router · Maps URLs to page screens
client/src/router.jsx - Screens · Landing, auth, dashboard, game, results, leaderboard, forum
client/src/pages - Auth State · Session and logged-in user state
client/src/context/AuthContext.jsx - Game State · Current quiz and result state
client/src/context/GameContext.jsx - API Layer · HTTP client and domain service wrappers
client/src/api - Shared UI · Navbar and reusable table UI
client/src/components - Client Utils · Formatting and local scoring helpers
client/src/utils
Server API
Express backend and domain logic
- Express API · Backend entrypoint and request boundary
server/app.js - Middleware · Auth, throttling, and centralized errors
server/middleware - Routes · Auth, game, leaderboard, forum, and stats endpoints
server/routes - Controllers · Translate requests into domain calls
server/controllers - Services · Game, leaderboard, and analytics logic
server/services - Server Utils · Server-side scoring and input validation
server/utils
Connections 19
- GeoQuest UI → Router: navigation · Top-level screen routing
- Router → Screens: renders · Route-based page selection
- Screens → Auth State: reads/writes · Login and session state
- Screens → Game State: reads/writes · Quiz flow state
- Screens → Shared UI: uses · Shared navigation and table components
- Screens → API Layer: calls · Backend requests are initiated from screens and context actions
- Client Utils → Game State: supports · Local scoring and time formatting
- API Layer → Express API: http · Frontend talks to backend over HTTP
- Express API → Middleware: passes through · Requests are filtered and normalized centrally
- Middleware → Routes: guards · Protected routes, rate limits, and error handling
- Routes → Controllers: dispatches · Domain-specific endpoint handling
- Controllers → Services: delegates · Controllers keep logic thin
- Services → Quiz Data: reads · Game content source for quizzes
- Services → Supabase: persists · Shared data storage and retrieval
- Controllers → Server Utils: validates · Input checks and score handling
- Services → Server Utils: scores · Server-side score authority
- Game State → Services: submits results · End-of-game data sent for validation and aggregation
- Services → Controllers: returns data · Leaderboard, forum, auth, and analytics outputs
- Controllers → API Layer: responds to · API responses consumed by the client