# harshverma-25/quizzyworld architecture

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

- Interactive diagram: https://gitdiagram.com/harshverma-25/quizzyworld
- Repository: https://github.com/harshverma-25/quizzyworld

## Overview

QUIZZY is a full-stack multiplayer quiz platform with solo practice, category-based quiz creation, real-time rooms and battles, match results, profiles, rankings, and administration. The principal flow is players selecting or creating a quiz, joining a room or starting solo practice, answering server-timed questions, then reviewing results and history. The graph preserves major documented capabilities, including authentication, payments, and AI quiz generation. Source excerpts and the index establish only selected internal calls; other links are limited to README-documented communication or omitted where wiring is unverified.

Main entry points: [`server/src/modules/auth/auth.service.ts`](https://github.com/harshverma-25/quizzyworld/blob/main/server/src/modules/auth/auth.service.ts) (Authentication), [`server/src/sockets/socket.ts`](https://github.com/harshverma-25/quizzyworld/blob/main/server/src/sockets/socket.ts) (Socket gateway), [`client/features/battle/hooks/useLiveBattle.ts`](https://github.com/harshverma-25/quizzyworld/blob/main/client/features/battle/hooks/useLiveBattle.ts) (Battle client), [`server/src/modules/room/room.service.ts`](https://github.com/harshverma-25/quizzyworld/blob/main/server/src/modules/room/room.service.ts) (Room workflows)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_web["Next.js app<br/>[page.tsx]"]
  node_category_ui["Category browsing"]
  node_creator_ui["Quiz creator"]
  node_lobby_ui["Room lobby<br/>[page.tsx]"]
  node_battle_ui["Battle client<br/>[useLiveBattle.ts]"]
  node_result_ui["Match results<br/>[page.tsx]"]
  node_profile_ui["Profile and rankings<br/>[useUserProfile.ts]"]
  node_history_ui["Match history<br/>[useMatchHistory.ts]"]
  node_admin_ui["Admin suite<br/>[page.tsx]"]
  node_api_client["API client<br/>[useApiClient.ts]"]
end

subgraph group_game["Quiz and battle"]
  node_room_api["Room workflows<br/>[room.service.ts]"]
  node_battle_api["Battle engine<br/>[battle.service.ts]"]
  node_question_api["Question bank"]
  node_quiz_api["Quiz generation<br/>[quiz.service.ts]"]
  node_socket_gateway["Socket gateway<br/>[socket.ts]"]
end

subgraph group_identity["Identity and accounts"]
  node_auth_ui["Client authentication<br/>[useCurrentUser.ts]"]
  node_auth_service["Authentication<br/>[auth.service.ts]"]
  node_user_service["User profiles<br/>[user.service.ts]"]
  node_user_store[("User repository<br/>[user.repository.ts]")]
end

subgraph group_insights["Results and discovery"]
  node_category_api["Category catalog"]
  node_history_api["Match history<br/>[history.service.ts]"]
  node_leaderboard_api["Leaderboard"]
end

subgraph group_platform["Platform services"]
  node_admin_service["Admin management<br/>[admin.service.ts]"]
  node_payment_service["Pro payments<br/>[payment.service.ts]"]
  node_server_config["Server configuration<br/>[env.ts]"]
  node_logger["Logging<br/>[logger.ts]"]
  node_mongo[("MongoDB<br/>[database.ts]")]
end

node_player(("Player / admin"))
node_razorpay["Razorpay"]
node_ai_provider["AI provider"]

node_player -->|"uses"| node_web
node_web -->|"browses"| node_category_ui
node_player -->|"creates quiz"| node_creator_ui
node_category_ui -.->|"starts room"| node_room_api
node_creator_ui -.->|"requests generation"| node_quiz_api
node_lobby_ui -->|"configures room"| node_room_api
node_room_api -->|"gets socket"| node_socket_gateway
node_player -->|"joins and answers"| node_socket_gateway
node_socket_gateway -.->|"dispatches rounds"| node_battle_api
node_battle_ui -->|"receives updates"| node_socket_gateway
node_battle_ui -->|"forfeits via REST"| node_battle_api
node_battle_api -.->|"uses questions"| node_question_api
node_battle_ui -->|"shows results"| node_result_ui
node_result_ui -.->|"reviews match"| node_history_api
node_player -->|"authenticates"| node_auth_ui
node_auth_ui -->|"requests user"| node_api_client
node_api_client -->|"calls REST API"| node_auth_service
node_auth_service -->|"reads and writes"| node_user_store
node_player -->|"views profile"| node_profile_ui
node_profile_ui -.->|"requests profile"| node_user_service
node_user_service -.->|"uses repository"| node_user_store
node_player -->|"reviews history"| node_history_ui
node_player -->|"manages content"| node_admin_ui
node_admin_ui -.->|"calls service"| node_admin_service
node_player -->|"views rankings"| node_leaderboard_api
node_player -.->|"buys Pro"| node_payment_service
node_payment_service -->|"verifies payments"| node_razorpay
node_quiz_api -.->|"generates quizzes"| node_ai_provider
node_auth_service -->|"reads settings"| node_server_config
node_auth_service -->|"logs events"| node_logger
node_auth_service -->|"persists accounts"| node_user_store

click node_web "https://github.com/harshverma-25/quizzyworld/blob/main/client/app/(public)/page.tsx"
click node_category_ui "https://github.com/harshverma-25/quizzyworld/blob/main/client/components/categories/CategoryDetailClient.tsx"
click node_creator_ui "https://github.com/harshverma-25/quizzyworld/blob/main/client/components/create/QuizCreatorClient.tsx"
click node_lobby_ui "https://github.com/harshverma-25/quizzyworld/blob/main/client/app/(protected)/lobby/%5BroomCode%5D/page.tsx"
click node_battle_ui "https://github.com/harshverma-25/quizzyworld/blob/main/client/features/battle/hooks/useLiveBattle.ts"
click node_result_ui "https://github.com/harshverma-25/quizzyworld/blob/main/client/app/(match)/results/%5BmatchId%5D/page.tsx"
click node_profile_ui "https://github.com/harshverma-25/quizzyworld/blob/main/client/features/profile/hooks/useUserProfile.ts"
click node_history_ui "https://github.com/harshverma-25/quizzyworld/blob/main/client/features/history/hooks/useMatchHistory.ts"
click node_admin_ui "https://github.com/harshverma-25/quizzyworld/blob/main/client/app/(admin)/admin/categories/page.tsx"
click node_api_client "https://github.com/harshverma-25/quizzyworld/blob/main/client/hooks/useApiClient.ts"
click node_auth_ui "https://github.com/harshverma-25/quizzyworld/blob/main/client/features/auth/hooks/useCurrentUser.ts"
click node_room_api "https://github.com/harshverma-25/quizzyworld/blob/main/server/src/modules/room/room.service.ts"
click node_battle_api "https://github.com/harshverma-25/quizzyworld/blob/main/server/src/modules/battle/battle.service.ts"
click node_question_api "https://github.com/harshverma-25/quizzyworld/blob/main/server/src/modules/question/question.service.ts"
click node_quiz_api "https://github.com/harshverma-25/quizzyworld/blob/main/server/src/modules/quiz/quiz.service.ts"
click node_socket_gateway "https://github.com/harshverma-25/quizzyworld/blob/main/server/src/sockets/socket.ts"
click node_auth_service "https://github.com/harshverma-25/quizzyworld/blob/main/server/src/modules/auth/auth.service.ts"
click node_user_service "https://github.com/harshverma-25/quizzyworld/blob/main/server/src/modules/user/user.service.ts"
click node_user_store "https://github.com/harshverma-25/quizzyworld/blob/main/server/src/modules/user/user.repository.ts"
click node_category_api "https://github.com/harshverma-25/quizzyworld/blob/main/server/src/modules/category/category.service.ts"
click node_history_api "https://github.com/harshverma-25/quizzyworld/blob/main/server/src/modules/history/history.service.ts"
click node_leaderboard_api "https://github.com/harshverma-25/quizzyworld/blob/main/server/src/modules/leaderboard/leaderboard.routes.ts"
click node_admin_service "https://github.com/harshverma-25/quizzyworld/blob/main/server/src/modules/admin/admin.service.ts"
click node_payment_service "https://github.com/harshverma-25/quizzyworld/blob/main/server/src/modules/payment/payment.service.ts"
click node_server_config "https://github.com/harshverma-25/quizzyworld/blob/main/server/src/config/env.ts"
click node_logger "https://github.com/harshverma-25/quizzyworld/blob/main/server/src/config/logger.ts"
click node_mongo "https://github.com/harshverma-25/quizzyworld/blob/main/server/src/config/database.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_web,node_category_ui,node_creator_ui,node_lobby_ui,node_battle_ui,node_result_ui,node_profile_ui,node_history_ui,node_admin_ui,node_api_client toneBlue
class node_room_api,node_battle_api,node_question_api,node_quiz_api,node_socket_gateway toneAmber
class node_auth_ui,node_auth_service,node_user_service,node_user_store toneMint
class node_category_api,node_history_api,node_leaderboard_api toneRose
class node_admin_service,node_payment_service,node_server_config,node_logger,node_mongo,node_player,node_razorpay,node_ai_provider toneIndigo
```

## Components

### Web client

- [Next.js app](https://github.com/harshverma-25/quizzyworld/blob/main/client/app/(public)/page.tsx): `client/app/(public)/page.tsx`
- [Category browsing](https://github.com/harshverma-25/quizzyworld/blob/main/client/components/categories/CategoryDetailClient.tsx): `client/components/categories/CategoryDetailClient.tsx`
- [Quiz creator](https://github.com/harshverma-25/quizzyworld/blob/main/client/components/create/QuizCreatorClient.tsx): `client/components/create/QuizCreatorClient.tsx`
- [Room lobby](https://github.com/harshverma-25/quizzyworld/blob/main/client/app/(protected)/lobby/%5BroomCode%5D/page.tsx): `client/app/(protected)/lobby/[roomCode]/page.tsx`
- [Battle client](https://github.com/harshverma-25/quizzyworld/blob/main/client/features/battle/hooks/useLiveBattle.ts): `client/features/battle/hooks/useLiveBattle.ts`
- [Match results](https://github.com/harshverma-25/quizzyworld/blob/main/client/app/(match)/results/%5BmatchId%5D/page.tsx): `client/app/(match)/results/[matchId]/page.tsx`
- [Profile and rankings](https://github.com/harshverma-25/quizzyworld/blob/main/client/features/profile/hooks/useUserProfile.ts): `client/features/profile/hooks/useUserProfile.ts`
- [Match history](https://github.com/harshverma-25/quizzyworld/blob/main/client/features/history/hooks/useMatchHistory.ts): `client/features/history/hooks/useMatchHistory.ts`
- [Admin suite](https://github.com/harshverma-25/quizzyworld/blob/main/client/app/(admin)/admin/categories/page.tsx): `client/app/(admin)/admin/categories/page.tsx`
- [API client](https://github.com/harshverma-25/quizzyworld/blob/main/client/hooks/useApiClient.ts): `client/hooks/useApiClient.ts`

### Quiz and battle

- [Room workflows](https://github.com/harshverma-25/quizzyworld/blob/main/server/src/modules/room/room.service.ts): `server/src/modules/room/room.service.ts`
- [Battle engine](https://github.com/harshverma-25/quizzyworld/blob/main/server/src/modules/battle/battle.service.ts): `server/src/modules/battle/battle.service.ts`
- [Question bank](https://github.com/harshverma-25/quizzyworld/blob/main/server/src/modules/question/question.service.ts): `server/src/modules/question/question.service.ts`
- [Quiz generation](https://github.com/harshverma-25/quizzyworld/blob/main/server/src/modules/quiz/quiz.service.ts): `server/src/modules/quiz/quiz.service.ts`
- [Socket gateway](https://github.com/harshverma-25/quizzyworld/blob/main/server/src/sockets/socket.ts): `server/src/sockets/socket.ts`

### Identity and accounts

- [Client authentication](https://github.com/harshverma-25/quizzyworld/blob/main/client/features/auth/hooks/useCurrentUser.ts): `client/features/auth/hooks/useCurrentUser.ts`
- [Authentication](https://github.com/harshverma-25/quizzyworld/blob/main/server/src/modules/auth/auth.service.ts): `server/src/modules/auth/auth.service.ts`
- [User profiles](https://github.com/harshverma-25/quizzyworld/blob/main/server/src/modules/user/user.service.ts): `server/src/modules/user/user.service.ts`
- [User repository](https://github.com/harshverma-25/quizzyworld/blob/main/server/src/modules/user/user.repository.ts): `server/src/modules/user/user.repository.ts`

### Results and discovery

- [Category catalog](https://github.com/harshverma-25/quizzyworld/blob/main/server/src/modules/category/category.service.ts): `server/src/modules/category/category.service.ts`
- [Match history](https://github.com/harshverma-25/quizzyworld/blob/main/server/src/modules/history/history.service.ts): `server/src/modules/history/history.service.ts`
- [Leaderboard](https://github.com/harshverma-25/quizzyworld/blob/main/server/src/modules/leaderboard/leaderboard.routes.ts): `server/src/modules/leaderboard/leaderboard.routes.ts`

### Platform services

- [Admin management](https://github.com/harshverma-25/quizzyworld/blob/main/server/src/modules/admin/admin.service.ts): `server/src/modules/admin/admin.service.ts`
- [Pro payments](https://github.com/harshverma-25/quizzyworld/blob/main/server/src/modules/payment/payment.service.ts): `server/src/modules/payment/payment.service.ts`
- [Server configuration](https://github.com/harshverma-25/quizzyworld/blob/main/server/src/config/env.ts): `server/src/config/env.ts`
- [Logging](https://github.com/harshverma-25/quizzyworld/blob/main/server/src/config/logger.ts): `server/src/config/logger.ts`
- [MongoDB](https://github.com/harshverma-25/quizzyworld/blob/main/server/src/config/database.ts): `server/src/config/database.ts`

### Other components

- **Player / admin**
- **Razorpay**
- **AI provider**

## Connections

- Player / admin → Next.js app: uses (evidence: `README.md`)
- Next.js app → Category browsing: browses (evidence: `README.md`)
- Player / admin → Quiz creator: creates quiz (evidence: `README.md`)
- Category browsing → Room workflows: starts room
- Quiz creator → Quiz generation: requests generation
- Room lobby → Room workflows: configures room (evidence: `README.md`)
- Room workflows → Socket gateway: gets socket (evidence: `server/src/modules/room/room.controller.ts`)
- Player / admin → Socket gateway: joins and answers (evidence: `README.md`)
- Socket gateway → Battle engine: dispatches rounds
- Battle client → Socket gateway: receives updates (evidence: `README.md`)
- Battle client → Battle engine: forfeits via REST (evidence: `client/features/battle/hooks/useLiveBattle.ts`)
- Battle engine → Question bank: uses questions
- Battle client → Match results: shows results (evidence: `README.md`)
- Match results → Match history: reviews match
- Player / admin → Client authentication: authenticates (evidence: `README.md`)
- Client authentication → API client: requests user (evidence: `client/features/auth/hooks/useCurrentUser.ts`)
- API client → Authentication: calls REST API (evidence: `README.md`)
- Authentication → User repository: reads and writes (evidence: `server/src/modules/auth/auth.service.ts`)
- Player / admin → Profile and rankings: views profile (evidence: `README.md`)
- Profile and rankings → User profiles: requests profile
- User profiles → User repository: uses repository
- Player / admin → Match history: reviews history (evidence: `README.md`)
- Player / admin → Admin suite: manages content (evidence: `README.md`)
- Admin suite → Admin management: calls service
- Player / admin → Leaderboard: views rankings (evidence: `README.md`)
- Player / admin → Pro payments: buys Pro
- Pro payments → Razorpay: verifies payments
- Quiz generation → AI provider: generates quizzes
- Authentication → Server configuration: reads settings (evidence: `server/src/modules/auth/auth.service.ts`)
- Authentication → Logging: logs events (evidence: `server/src/modules/auth/auth.service.ts`)
- Authentication → User repository: persists accounts (evidence: `server/src/modules/auth/auth.service.ts`)
