# veeravardhan35/hashnet architecture

> Architecture diagram of the GitHub repository veeravardhan35/hashnet, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/veeravardhan35/hashnet
- Repository: https://github.com/veeravardhan35/hashnet

## Overview

Hashnet is a real-time multiplayer coding and learning platform. Learners enter through the React app, authenticate or create/join a room, then play quiz, coding battle, team, or cooperative boss-raid modes; separate competitive-programming and AI-assisted content workflows are also documented. Express serves REST features while Colyseus hosts authoritative game rooms; MongoDB-backed models support accounts and learning content. The excerpts establish routing, room commands, selected controller calls, and RAG forwarding; several feature-level links rely on README documentation because their implementations were not sampled.

Main entry points: [`client/src/App.tsx`](https://github.com/veeravardhan35/hashnet/blob/main/client/src/App.tsx) (React app), [`server/src/app.config.ts`](https://github.com/veeravardhan35/hashnet/blob/main/server/src/app.config.ts) (Express and Colyseus host), [`server/src/controllers/competitive.controller.ts`](https://github.com/veeravardhan35/hashnet/blob/main/server/src/controllers/competitive.controller.ts) (Competitive runs), [`server/src/models`](https://github.com/veeravardhan35/hashnet/tree/main/server/src/models) (Domain models)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_app["React app<br/>[App.tsx]"]
  node_authui["Auth pages<br/>[LoginPage.tsx]"]
  node_roomui["Room and lobby UI<br/>[LobbyPage.tsx]"]
  node_modeui["Game mode pages<br/>[BattlePage.tsx]"]
  node_competitiveui["Competitive pages"]
  node_roomhook["Room hook<br/>[useRoom.ts]"]
  node_battlehook["Battle hook<br/>[useBattle.ts]"]
  node_gameclient["Colyseus client<br/>[client.ts]"]
  node_roomstore["Room state<br/>[room.store.ts]"]
end

subgraph group_realtime["Realtime gameplay"]
  node_server["Express and Colyseus host<br/>[app.config.ts]"]
  node_lobbyroom["Lobby room<br/>[MyRoom.ts]"]
  node_gamerooms["Game mode rooms"]
end

subgraph group_api["API and content"]
  node_routes["REST routes"]
  node_authctrl["Authentication<br/>[auth.controller.ts]"]
  node_compctrl["Competitive runs"]
  node_content["Quiz and RAG content<br/>[rag.routes.ts]"]
  node_adminctrl["Content administration"]
end

subgraph group_data["Data and integrations"]
  node_models["Domain models"]
  node_mongodb[("MongoDB")]
  node_ragservice["RAG service"]
  node_codeforces["Codeforces API"]
  node_piston["Piston execution<br/>[piston.ts]"]
end

node_learner(("Learner"))

node_learner -->|"uses"| node_app
node_app -->|"routes to"| node_authui
node_app -->|"routes to"| node_roomui
node_app -->|"routes to"| node_modeui
node_app -->|"routes to"| node_competitiveui
node_roomhook -->|"creates rooms"| node_gameclient
node_roomhook -->|"updates"| node_roomstore
node_battlehook -->|"joins room"| node_gameclient
node_roomui -.->|"controls"| node_roomhook
node_modeui -.->|"uses"| node_battlehook
node_gameclient -->|"connects by WebSocket"| node_server
node_server -->|"mounts"| node_routes
node_server -->|"registers"| node_lobbyroom
node_server -->|"registers"| node_gamerooms
node_routes -.->|"dispatches"| node_authctrl
node_routes -.->|"dispatches"| node_compctrl
node_authctrl -->|"reads and writes users"| node_models
node_authctrl -.->|"persists users"| node_mongodb
node_content -->|"forwards uploads"| node_ragservice
node_content -->|"stores generated content"| node_models
node_adminctrl -->|"manages content"| node_models
node_compctrl -->|"tracks runs"| node_models
node_compctrl -->|"fetches problems"| node_codeforces
node_compctrl -->|"executes code"| node_piston
node_gamerooms -.->|"loads learning content"| node_mongodb

click node_app "https://github.com/veeravardhan35/hashnet/blob/main/client/src/App.tsx"
click node_authui "https://github.com/veeravardhan35/hashnet/blob/main/client/src/pages/LoginPage.tsx"
click node_roomui "https://github.com/veeravardhan35/hashnet/blob/main/client/src/pages/LobbyPage.tsx"
click node_modeui "https://github.com/veeravardhan35/hashnet/blob/main/client/src/pages/BattlePage.tsx"
click node_competitiveui "https://github.com/veeravardhan35/hashnet/blob/main/client/src/pages/CompetitiveSetupPage.tsx"
click node_roomhook "https://github.com/veeravardhan35/hashnet/blob/main/client/src/hooks/useRoom.ts"
click node_battlehook "https://github.com/veeravardhan35/hashnet/blob/main/client/src/hooks/useBattle.ts"
click node_gameclient "https://github.com/veeravardhan35/hashnet/blob/main/client/src/colyseus/client.ts"
click node_roomstore "https://github.com/veeravardhan35/hashnet/blob/main/client/src/store/room.store.ts"
click node_server "https://github.com/veeravardhan35/hashnet/blob/main/server/src/app.config.ts"
click node_lobbyroom "https://github.com/veeravardhan35/hashnet/blob/main/server/src/rooms/MyRoom.ts"
click node_gamerooms "https://github.com/veeravardhan35/hashnet/tree/main/server/src/rooms"
click node_routes "https://github.com/veeravardhan35/hashnet/tree/main/server/src/routes"
click node_authctrl "https://github.com/veeravardhan35/hashnet/blob/main/server/src/controllers/auth.controller.ts"
click node_compctrl "https://github.com/veeravardhan35/hashnet/blob/main/server/src/controllers/competitive.controller.ts"
click node_content "https://github.com/veeravardhan35/hashnet/blob/main/server/src/routes/rag.routes.ts"
click node_adminctrl "https://github.com/veeravardhan35/hashnet/blob/main/server/src/controllers/admin.controller.ts"
click node_models "https://github.com/veeravardhan35/hashnet/tree/main/server/src/models"
click node_piston "https://github.com/veeravardhan35/hashnet/blob/main/server/src/services/piston.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_authui,node_roomui,node_modeui,node_competitiveui,node_roomhook,node_battlehook,node_gameclient,node_roomstore toneBlue
class node_server,node_lobbyroom,node_gamerooms toneAmber
class node_routes,node_authctrl,node_compctrl,node_content,node_adminctrl toneMint
class node_models,node_mongodb,node_ragservice,node_codeforces,node_piston toneRose
class node_learner toneIndigo
```

## Components

### Web client

- [React app](https://github.com/veeravardhan35/hashnet/blob/main/client/src/App.tsx): `client/src/App.tsx`
- [Auth pages](https://github.com/veeravardhan35/hashnet/blob/main/client/src/pages/LoginPage.tsx): `client/src/pages/LoginPage.tsx`
- [Room and lobby UI](https://github.com/veeravardhan35/hashnet/blob/main/client/src/pages/LobbyPage.tsx): `client/src/pages/LobbyPage.tsx`
- [Game mode pages](https://github.com/veeravardhan35/hashnet/blob/main/client/src/pages/BattlePage.tsx): `client/src/pages/BattlePage.tsx`
- [Competitive pages](https://github.com/veeravardhan35/hashnet/blob/main/client/src/pages/CompetitiveSetupPage.tsx): `client/src/pages/CompetitiveSetupPage.tsx`
- [Room hook](https://github.com/veeravardhan35/hashnet/blob/main/client/src/hooks/useRoom.ts): `client/src/hooks/useRoom.ts`
- [Battle hook](https://github.com/veeravardhan35/hashnet/blob/main/client/src/hooks/useBattle.ts): `client/src/hooks/useBattle.ts`
- [Colyseus client](https://github.com/veeravardhan35/hashnet/blob/main/client/src/colyseus/client.ts): `client/src/colyseus/client.ts`
- [Room state](https://github.com/veeravardhan35/hashnet/blob/main/client/src/store/room.store.ts): `client/src/store/room.store.ts`

### Realtime gameplay

- [Express and Colyseus host](https://github.com/veeravardhan35/hashnet/blob/main/server/src/app.config.ts): `server/src/app.config.ts`
- [Lobby room](https://github.com/veeravardhan35/hashnet/blob/main/server/src/rooms/MyRoom.ts): `server/src/rooms/MyRoom.ts`
- [Game mode rooms](https://github.com/veeravardhan35/hashnet/tree/main/server/src/rooms): `server/src/rooms`

### API and content

- [REST routes](https://github.com/veeravardhan35/hashnet/tree/main/server/src/routes): `server/src/routes`
- [Authentication](https://github.com/veeravardhan35/hashnet/blob/main/server/src/controllers/auth.controller.ts): `server/src/controllers/auth.controller.ts`
- [Competitive runs](https://github.com/veeravardhan35/hashnet/blob/main/server/src/controllers/competitive.controller.ts): `server/src/controllers/competitive.controller.ts`
- [Quiz and RAG content](https://github.com/veeravardhan35/hashnet/blob/main/server/src/routes/rag.routes.ts): `server/src/routes/rag.routes.ts`
- [Content administration](https://github.com/veeravardhan35/hashnet/blob/main/server/src/controllers/admin.controller.ts): `server/src/controllers/admin.controller.ts`

### Data and integrations

- [Domain models](https://github.com/veeravardhan35/hashnet/tree/main/server/src/models): `server/src/models`
- **MongoDB**
- **RAG service**
- **Codeforces API**
- [Piston execution](https://github.com/veeravardhan35/hashnet/blob/main/server/src/services/piston.ts): `server/src/services/piston.ts`

### Other components

- **Learner**

## Connections

- Learner → React app: uses (evidence: `README.md`)
- React app → Auth pages: routes to (evidence: `client/src/App.tsx`)
- React app → Room and lobby UI: routes to (evidence: `client/src/App.tsx`)
- React app → Game mode pages: routes to (evidence: `client/src/App.tsx`)
- React app → Competitive pages: routes to (evidence: `client/src/App.tsx`)
- Room hook → Colyseus client: creates rooms (evidence: `client/src/hooks/useRoom.ts`)
- Room hook → Room state: updates (evidence: `client/src/hooks/useRoom.ts`)
- Battle hook → Colyseus client: joins room (evidence: `client/src/hooks/useBattle.ts`)
- Room and lobby UI → Room hook: controls
- Game mode pages → Battle hook: uses
- Colyseus client → Express and Colyseus host: connects by WebSocket (evidence: `README.md`)
- Express and Colyseus host → REST routes: mounts (evidence: `server/src/app.config.ts`)
- Express and Colyseus host → Lobby room: registers (evidence: `server/src/app.config.ts`)
- Express and Colyseus host → Game mode rooms: registers (evidence: `server/src/app.config.ts`)
- REST routes → Authentication: dispatches
- REST routes → Competitive runs: dispatches
- Authentication → Domain models: reads and writes users (evidence: `server/src/controllers/auth.controller.ts`)
- Authentication → MongoDB: persists users
- Quiz and RAG content → RAG service: forwards uploads (evidence: `server/src/routes/rag.routes.ts`)
- Quiz and RAG content → Domain models: stores generated content (evidence: `server/src/routes/rag.routes.ts`)
- Content administration → Domain models: manages content (evidence: `server/src/controllers/admin.controller.ts`)
- Competitive runs → Domain models: tracks runs (evidence: `server/src/controllers/competitive.controller.ts`)
- Competitive runs → Codeforces API: fetches problems (evidence: `server/src/controllers/competitive.controller.ts`)
- Competitive runs → Piston execution: executes code (evidence: `server/src/controllers/competitive.controller.ts`)
- Game mode rooms → MongoDB: loads learning content
