# imrehankhan/undoubt architecture

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

- Interactive diagram: https://gitdiagram.com/imrehankhan/undoubt
- Repository: https://github.com/imrehankhan/undoubt

## Overview

UnDoubt is a real-time question-and-doubt platform organized around sign-in, creating or joining a room, and asking or managing questions there. The frontend also exposes home, profile, and access-denied views; backend routes support room, user, and statistics operations. Socket events provide live room updates, while MongoDB models hold room, doubt, user, and statistics data. Several frontend pages and helpers were not sampled, so their links to API and socket behavior are shown as unverified rather than asserted.

Main entry points: [`frontend/src/App.jsx`](https://github.com/imrehankhan/undoubt/blob/main/frontend/src/App.jsx) (App routing), [`backend/routes/routes.js`](https://github.com/imrehankhan/undoubt/blob/main/backend/routes/routes.js) (Room and user routes), [`backend/app.js`](https://github.com/imrehankhan/undoubt/blob/main/backend/app.js) (HTTP and socket server), [`backend/controllers/socketController.js`](https://github.com/imrehankhan/undoubt/blob/main/backend/controllers/socketController.js) (Socket event handler)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend experience"]
  node_app["App routing<br/>[App.jsx]"]
  node_auth["Auth context<br/>[AuthContext.jsx]"]
  node_firebase["Firebase auth<br/>[firebase.js]"]
  node_login["Sign-in page<br/>[LoginPage.jsx]"]
  node_home["Home page<br/>[HomePage.jsx]"]
  node_create["Create room<br/>[CreateRoomPage.jsx]"]
  node_join["Join room<br/>[JoinRoomPage.jsx]"]
  node_profile["User profile<br/>[ProfilePage.jsx]"]
  node_denied["Access denied"]
  node_recentrooms["Recent rooms<br/>[RecentRooms.jsx]"]
  node_userstats["User statistics<br/>[UserStats.jsx]"]
end

subgraph group_realtime["Live room interaction"]
  node_room["Room session<br/>[RoomPage.jsx]"]
  node_roombackup["Room page backup"]
  node_doubtviews["Doubt views<br/>[DoubtContainer.jsx]"]
  node_virtualdoubts["Virtualized doubts"]
  node_socketclient["Socket client<br/>[socket.js]"]
  node_socketcontroller["Socket event handler"]
end

subgraph group_api["HTTP API"]
  node_apihelper["API client<br/>[api.js]"]
  node_server["HTTP and socket server<br/>[app.js]"]
  node_routes["Room and user routes<br/>[routes.js]"]
  node_swagger["API specification<br/>[swagger.js]"]
end

subgraph group_data["MongoDB data"]
  node_roommodel[("Room records<br/>[Room.js]")]
  node_doubtmodel[("Doubt records<br/>[Doubt.js]")]
  node_usermodel[("User records<br/>[User.js]")]
  node_statsmodel[("Statistics records<br/>[Statistics.js]")]
end

node_visitor(("Platform user"))

node_visitor -->|"uses"| node_app
node_app -->|"provides auth"| node_auth
node_app -->|"routes"| node_login
node_app -->|"routes"| node_home
node_app -->|"routes"| node_create
node_app -->|"routes"| node_join
node_app -->|"routes"| node_room
node_app -->|"routes"| node_profile
node_app -->|"routes"| node_denied
node_app -->|"logs out through"| node_firebase
node_visitor -.->|"requests"| node_create
node_visitor -.->|"requests"| node_join
node_visitor -.->|"asks or manages"| node_room
node_roombackup -->|"calls"| node_apihelper
node_roombackup -->|"uses"| node_socketclient
node_recentrooms -->|"fetches through"| node_apihelper
node_apihelper -.->|"HTTP requests"| node_server
node_socketclient -.->|"socket connection"| node_server
node_server -->|"mounts routes"| node_routes
node_server -->|"dispatches connections"| node_socketcontroller
node_server -->|"serves docs"| node_swagger
node_routes -->|"reads and writes"| node_roommodel
node_routes -->|"reads and writes"| node_doubtmodel
node_routes -->|"reads and writes"| node_usermodel
node_routes -->|"references"| node_statsmodel
node_socketcontroller -->|"reads and updates"| node_doubtmodel
node_socketcontroller -->|"broadcasts events"| node_visitor

click node_app "https://github.com/imrehankhan/undoubt/blob/main/frontend/src/App.jsx"
click node_auth "https://github.com/imrehankhan/undoubt/blob/main/frontend/src/contexts/AuthContext.jsx"
click node_firebase "https://github.com/imrehankhan/undoubt/blob/main/frontend/src/config/firebase.js"
click node_login "https://github.com/imrehankhan/undoubt/blob/main/frontend/src/pages/LoginPage.jsx"
click node_home "https://github.com/imrehankhan/undoubt/blob/main/frontend/src/pages/HomePage.jsx"
click node_create "https://github.com/imrehankhan/undoubt/blob/main/frontend/src/pages/CreateRoomPage.jsx"
click node_join "https://github.com/imrehankhan/undoubt/blob/main/frontend/src/pages/JoinRoomPage.jsx"
click node_room "https://github.com/imrehankhan/undoubt/blob/main/frontend/src/pages/RoomPage.jsx"
click node_profile "https://github.com/imrehankhan/undoubt/blob/main/frontend/src/pages/ProfilePage.jsx"
click node_denied "https://github.com/imrehankhan/undoubt/blob/main/frontend/src/pages/AccessDeniedPage.jsx"
click node_roombackup "https://github.com/imrehankhan/undoubt/blob/main/frontend/src/pages/RoomPage.backup.jsx"
click node_doubtviews "https://github.com/imrehankhan/undoubt/blob/main/frontend/src/components/DoubtContainer.jsx"
click node_virtualdoubts "https://github.com/imrehankhan/undoubt/blob/main/frontend/src/components/VirtualizedDoubtList.jsx"
click node_recentrooms "https://github.com/imrehankhan/undoubt/blob/main/frontend/src/components/RecentRooms.jsx"
click node_userstats "https://github.com/imrehankhan/undoubt/blob/main/frontend/src/components/UserStats.jsx"
click node_apihelper "https://github.com/imrehankhan/undoubt/blob/main/frontend/src/utils/api.js"
click node_socketclient "https://github.com/imrehankhan/undoubt/blob/main/frontend/src/utils/socket.js"
click node_server "https://github.com/imrehankhan/undoubt/blob/main/backend/app.js"
click node_routes "https://github.com/imrehankhan/undoubt/blob/main/backend/routes/routes.js"
click node_socketcontroller "https://github.com/imrehankhan/undoubt/blob/main/backend/controllers/socketController.js"
click node_roommodel "https://github.com/imrehankhan/undoubt/blob/main/backend/models/Room.js"
click node_doubtmodel "https://github.com/imrehankhan/undoubt/blob/main/backend/models/Doubt.js"
click node_usermodel "https://github.com/imrehankhan/undoubt/blob/main/backend/models/User.js"
click node_statsmodel "https://github.com/imrehankhan/undoubt/blob/main/backend/models/Statistics.js"
click node_swagger "https://github.com/imrehankhan/undoubt/blob/main/backend/swagger.js"

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_auth,node_firebase,node_login,node_home,node_create,node_join,node_profile,node_denied,node_recentrooms,node_userstats,node_visitor toneBlue
class node_room,node_roombackup,node_doubtviews,node_virtualdoubts,node_socketclient,node_socketcontroller toneAmber
class node_apihelper,node_server,node_routes,node_swagger toneMint
class node_roommodel,node_doubtmodel,node_usermodel,node_statsmodel toneRose
```

## Components

### Frontend experience

- [App routing](https://github.com/imrehankhan/undoubt/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Auth context](https://github.com/imrehankhan/undoubt/blob/main/frontend/src/contexts/AuthContext.jsx): `frontend/src/contexts/AuthContext.jsx`
- [Firebase auth](https://github.com/imrehankhan/undoubt/blob/main/frontend/src/config/firebase.js): `frontend/src/config/firebase.js`
- [Sign-in page](https://github.com/imrehankhan/undoubt/blob/main/frontend/src/pages/LoginPage.jsx): `frontend/src/pages/LoginPage.jsx`
- [Home page](https://github.com/imrehankhan/undoubt/blob/main/frontend/src/pages/HomePage.jsx): `frontend/src/pages/HomePage.jsx`
- [Create room](https://github.com/imrehankhan/undoubt/blob/main/frontend/src/pages/CreateRoomPage.jsx): `frontend/src/pages/CreateRoomPage.jsx`
- [Join room](https://github.com/imrehankhan/undoubt/blob/main/frontend/src/pages/JoinRoomPage.jsx): `frontend/src/pages/JoinRoomPage.jsx`
- [User profile](https://github.com/imrehankhan/undoubt/blob/main/frontend/src/pages/ProfilePage.jsx): `frontend/src/pages/ProfilePage.jsx`
- [Access denied](https://github.com/imrehankhan/undoubt/blob/main/frontend/src/pages/AccessDeniedPage.jsx): `frontend/src/pages/AccessDeniedPage.jsx`
- [Recent rooms](https://github.com/imrehankhan/undoubt/blob/main/frontend/src/components/RecentRooms.jsx): `frontend/src/components/RecentRooms.jsx`
- [User statistics](https://github.com/imrehankhan/undoubt/blob/main/frontend/src/components/UserStats.jsx): `frontend/src/components/UserStats.jsx`

### Live room interaction

- [Room session](https://github.com/imrehankhan/undoubt/blob/main/frontend/src/pages/RoomPage.jsx): `frontend/src/pages/RoomPage.jsx`
- [Room page backup](https://github.com/imrehankhan/undoubt/blob/main/frontend/src/pages/RoomPage.backup.jsx): `frontend/src/pages/RoomPage.backup.jsx`
- [Doubt views](https://github.com/imrehankhan/undoubt/blob/main/frontend/src/components/DoubtContainer.jsx): `frontend/src/components/DoubtContainer.jsx`
- [Virtualized doubts](https://github.com/imrehankhan/undoubt/blob/main/frontend/src/components/VirtualizedDoubtList.jsx): `frontend/src/components/VirtualizedDoubtList.jsx`
- [Socket client](https://github.com/imrehankhan/undoubt/blob/main/frontend/src/utils/socket.js): `frontend/src/utils/socket.js`
- [Socket event handler](https://github.com/imrehankhan/undoubt/blob/main/backend/controllers/socketController.js): `backend/controllers/socketController.js`

### HTTP API

- [API client](https://github.com/imrehankhan/undoubt/blob/main/frontend/src/utils/api.js): `frontend/src/utils/api.js`
- [HTTP and socket server](https://github.com/imrehankhan/undoubt/blob/main/backend/app.js): `backend/app.js`
- [Room and user routes](https://github.com/imrehankhan/undoubt/blob/main/backend/routes/routes.js): `backend/routes/routes.js`
- [API specification](https://github.com/imrehankhan/undoubt/blob/main/backend/swagger.js): `backend/swagger.js`

### MongoDB data

- [Room records](https://github.com/imrehankhan/undoubt/blob/main/backend/models/Room.js): `backend/models/Room.js`
- [Doubt records](https://github.com/imrehankhan/undoubt/blob/main/backend/models/Doubt.js): `backend/models/Doubt.js`
- [User records](https://github.com/imrehankhan/undoubt/blob/main/backend/models/User.js): `backend/models/User.js`
- [Statistics records](https://github.com/imrehankhan/undoubt/blob/main/backend/models/Statistics.js): `backend/models/Statistics.js`

### Other components

- **Platform user**

## Connections

- Platform user → App routing: uses (evidence: `frontend/src/App.jsx`)
- App routing → Auth context: provides auth (evidence: `frontend/src/App.jsx`)
- App routing → Sign-in page: routes (evidence: `frontend/src/App.jsx`)
- App routing → Home page: routes (evidence: `frontend/src/App.jsx`)
- App routing → Create room: routes (evidence: `frontend/src/App.jsx`)
- App routing → Join room: routes (evidence: `frontend/src/App.jsx`)
- App routing → Room session: routes (evidence: `frontend/src/App.jsx`)
- App routing → User profile: routes (evidence: `frontend/src/App.jsx`)
- App routing → Access denied: routes (evidence: `frontend/src/App.jsx`)
- App routing → Firebase auth: logs out through (evidence: `frontend/src/App.jsx`)
- Platform user → Create room: requests
- Platform user → Join room: requests
- Platform user → Room session: asks or manages
- Room page backup → API client: calls (evidence: `frontend/src/pages/RoomPage.backup.jsx`)
- Room page backup → Socket client: uses (evidence: `frontend/src/pages/RoomPage.backup.jsx`)
- Recent rooms → API client: fetches through (evidence: `frontend/src/components/RecentRooms.jsx`)
- API client → HTTP and socket server: HTTP requests
- Socket client → HTTP and socket server: socket connection
- HTTP and socket server → Room and user routes: mounts routes (evidence: `backend/app.js`)
- HTTP and socket server → Socket event handler: dispatches connections (evidence: `backend/app.js`)
- HTTP and socket server → API specification: serves docs (evidence: `backend/app.js`)
- Room and user routes → Room records: reads and writes (evidence: `backend/routes/routes.js`)
- Room and user routes → Doubt records: reads and writes (evidence: `backend/routes/routes.js`)
- Room and user routes → User records: reads and writes (evidence: `backend/routes/routes.js`)
- Room and user routes → Statistics records: references (evidence: `backend/routes/routes.js`)
- Socket event handler → Doubt records: reads and updates (evidence: `backend/controllers/socketController.js`)
- Socket event handler → Platform user: broadcasts events (evidence: `backend/controllers/socketController.js`)
