How pm3949/hectoclash works
Project type and purpose
• From the file tree and minimal README, we see this is a full-stack, real-time coding/competition platform named “HectoClash.”
• The frontend is a React single-page application (SPA) that provides user signup/login, problem solving (single/multiplayer & training), a live match spectator mode, leaderboards, and user profiles.
• The backend is a Node.js/Express server exposing RESTful endpoints for users, matches, and training, plus a WebSocket interface for real-time match communication and spectator updates. It persists data in a database (configured in backend/config/database.js) and uses MVC organization (models, controllers, routes).
File structure
• Top-level folders:
• backend/ – Express API, REST routes, authentication middleware, socket server, database config, utility modules (problem generator & solver).
• frontend/ – React SPA scaffolded by Create React App, organized into Pages, components, Redux slices, custom hooks, context for socket, and Tailwind config.
• Key patterns:
• Backend follows an MVC-ish pattern: models/ (schema definitions), controllers/ (business logic), routes/ (HTTP endpoints), plus socket.
• Frontend uses Redux for global state (user, matches, opponents), React Context for socket connection, and React Router pages.
• Deployment/config:
• .env in backend for secret keys/DB URL, package.json scripts for both front and back.
README for additional insights
• No explicit architecture section present. We’ll infer from code and directory names.
Elements
– Backend layers in another (e.g., green)
• Authentication flow: show JWT issued by backend, stored in frontend, sent on API calls, guarded by isAuthenticated middleware.
Detailed breakdown
• Frontend Side:
[Browser]
→ [React Router / Pages]
→ [Redux Store] ←→ [Components]
→ [Socket Context]
• Backend Side:
[Express API]
→ [Routes] → [Controllers] → [Models] → [Database]
↘︎ [Utils (generateProblem, solver)]
• Real-Time:
[Client Socket Context] ↔ [backend/socket/socket.js] ↔ [Controllers/Models]
• Data Persistence:
[Models] → [Config/Database] → [Database]