# dhruthi-kedilaya/real-time-chat-app architecture

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

- Interactive diagram: https://gitdiagram.com/dhruthi-kedilaya/real-time-chat-app
- Repository: https://github.com/dhruthi-kedilaya/real-time-chat-app

## Overview

This is a group-chat application: users sign up or log in, then create or join groups and exchange text/image messages. The frontend routes pages and holds auth, group, and personalization state; the backend exposes authenticated REST routes, persists users/groups/messages, and broadcasts group messages over Socket.IO. The tree and excerpts support those core paths, but message-controller behavior and several frontend pages/components are not sampled, so their internal links are omitted where unverified.

Main entry points: [`frontend/src/App.jsx`](https://github.com/dhruthi-kedilaya/real-time-chat-app/blob/main/frontend/src/App.jsx) (Route shell), [`backend/src/controller/group.js`](https://github.com/dhruthi-kedilaya/real-time-chat-app/blob/main/backend/src/controller/group.js) (Group operations), [`frontend/src/lib/axios.js`](https://github.com/dhruthi-kedilaya/real-time-chat-app/blob/main/frontend/src/lib/axios.js) (HTTP client), [`frontend/src/store/useAuthStore.jsx`](https://github.com/dhruthi-kedilaya/real-time-chat-app/blob/main/frontend/src/store/useAuthStore.jsx) (Auth state)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_app["Route shell<br/>[App.jsx]"]
  node_authpages["Auth pages"]
  node_profilepage["Profile page<br/>[ProfilePage.jsx]"]
  node_createpage["Create group page"]
  node_home["Chat home<br/>[HomePage.jsx]"]
  node_chatui["Chat interface"]
  node_personalstate["Personalization<br/>[usePersStore.jsx]"]
  node_axios["HTTP client<br/>[axios.js]"]
end

subgraph group_identity["Identity"]
  node_authstate["Auth state<br/>[useAuthStore.jsx]"]
  node_authroutes["Auth routes<br/>[authentication.js]"]
  node_authcontroller["Auth operations<br/>[authentication.js]"]
  node_guard["Route protection<br/>[protectRoute.js]"]
end

subgraph group_groupschat["Groups and chat"]
  node_groupstate["Group state<br/>[useGroupStore.jsx]"]
  node_grouproutes["Group routes<br/>[group.js]"]
  node_groupcontroller["Group operations<br/>[group.js]"]
  node_messagecontroller["Direct messages<br/>[message.js]"]
end

subgraph group_server["API and realtime"]
  node_socket["Realtime server<br/>[socket.js]"]
  node_serverentry["HTTP server<br/>[index.js]"]
end

subgraph group_data["Persistence and media"]
  node_userdb[("User records<br/>[User.js]")]
  node_groupdb[("Group records<br/>[Group.js]")]
  node_messagedb[("Message records<br/>[Message.js]")]
  node_cloudinary["Image hosting<br/>[cloudinary.js]"]
end

node_user(("Chat user"))
node_database[("MongoDB")]

node_user -->|"uses"| node_app
node_app -->|"checks session"| node_authstate
node_app -->|"routes to"| node_authpages
node_app -->|"routes to"| node_profilepage
node_app -->|"routes to"| node_createpage
node_app -->|"routes to"| node_home
node_home -.->|"renders"| node_chatui
node_authpages -.->|"authenticates"| node_authstate
node_profilepage -->|"updates profile"| node_authstate
node_createpage -.->|"creates group"| node_groupstate
node_chatui -->|"uses"| node_groupstate
node_chatui -->|"uses"| node_personalstate
node_authstate -->|"sends requests"| node_axios
node_groupstate -->|"sends requests"| node_axios
node_authstate -->|"connects"| node_socket
node_groupstate -->|"joins rooms"| node_socket
node_axios -.->|"calls API"| node_authroutes
node_axios -.->|"calls API"| node_grouproutes
node_axios -.->|"calls API"| node_messagecontroller
node_serverentry -->|"mounts"| node_authroutes
node_serverentry -->|"mounts"| node_grouproutes
node_serverentry -->|"serves"| node_socket
node_authroutes -->|"dispatches"| node_authcontroller
node_authroutes -->|"protects"| node_guard
node_grouproutes -->|"dispatches"| node_groupcontroller
node_guard -->|"loads user"| node_userdb
node_authcontroller -->|"reads/writes"| node_userdb
node_authcontroller -->|"uploads profile image"| node_cloudinary
node_groupcontroller -->|"reads/writes"| node_userdb
node_groupcontroller -->|"reads/writes"| node_groupdb
node_groupcontroller -->|"reads/writes"| node_messagedb
node_groupcontroller -->|"uploads images"| node_cloudinary
node_groupcontroller -->|"broadcasts message"| node_socket
node_userdb -.->|"persists"| node_database
node_groupdb -.->|"persists"| node_database
node_messagedb -.->|"persists"| node_database

click node_app "https://github.com/dhruthi-kedilaya/real-time-chat-app/blob/main/frontend/src/App.jsx"
click node_authpages "https://github.com/dhruthi-kedilaya/real-time-chat-app/tree/main/frontend/src/pages"
click node_profilepage "https://github.com/dhruthi-kedilaya/real-time-chat-app/blob/main/frontend/src/pages/ProfilePage.jsx"
click node_createpage "https://github.com/dhruthi-kedilaya/real-time-chat-app/blob/main/frontend/src/pages/CreateGroupPage.jsx"
click node_home "https://github.com/dhruthi-kedilaya/real-time-chat-app/blob/main/frontend/src/pages/HomePage.jsx"
click node_chatui "https://github.com/dhruthi-kedilaya/real-time-chat-app/tree/main/frontend/src/components"
click node_authstate "https://github.com/dhruthi-kedilaya/real-time-chat-app/blob/main/frontend/src/store/useAuthStore.jsx"
click node_groupstate "https://github.com/dhruthi-kedilaya/real-time-chat-app/blob/main/frontend/src/store/useGroupStore.jsx"
click node_personalstate "https://github.com/dhruthi-kedilaya/real-time-chat-app/blob/main/frontend/src/store/usePersStore.jsx"
click node_axios "https://github.com/dhruthi-kedilaya/real-time-chat-app/blob/main/frontend/src/lib/axios.js"
click node_authroutes "https://github.com/dhruthi-kedilaya/real-time-chat-app/blob/main/backend/src/routes/authentication.js"
click node_authcontroller "https://github.com/dhruthi-kedilaya/real-time-chat-app/blob/main/backend/src/controller/authentication.js"
click node_guard "https://github.com/dhruthi-kedilaya/real-time-chat-app/blob/main/backend/src/middleware/protectRoute.js"
click node_grouproutes "https://github.com/dhruthi-kedilaya/real-time-chat-app/blob/main/backend/src/routes/group.js"
click node_groupcontroller "https://github.com/dhruthi-kedilaya/real-time-chat-app/blob/main/backend/src/controller/group.js"
click node_messagecontroller "https://github.com/dhruthi-kedilaya/real-time-chat-app/blob/main/backend/src/controller/message.js"
click node_socket "https://github.com/dhruthi-kedilaya/real-time-chat-app/blob/main/backend/src/lib/socket.js"
click node_serverentry "https://github.com/dhruthi-kedilaya/real-time-chat-app/blob/main/backend/src/index.js"
click node_userdb "https://github.com/dhruthi-kedilaya/real-time-chat-app/blob/main/backend/src/models/User.js"
click node_groupdb "https://github.com/dhruthi-kedilaya/real-time-chat-app/blob/main/backend/src/models/Group.js"
click node_messagedb "https://github.com/dhruthi-kedilaya/real-time-chat-app/blob/main/backend/src/models/Message.js"
click node_cloudinary "https://github.com/dhruthi-kedilaya/real-time-chat-app/blob/main/backend/src/lib/cloudinary.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_authpages,node_profilepage,node_createpage,node_home,node_chatui,node_personalstate,node_axios,node_user toneBlue
class node_authstate,node_authroutes,node_authcontroller,node_guard,node_database toneAmber
class node_groupstate,node_grouproutes,node_groupcontroller,node_messagecontroller toneMint
class node_socket,node_serverentry toneRose
class node_userdb,node_groupdb,node_messagedb,node_cloudinary toneIndigo
```

## Components

### Web client

- [Route shell](https://github.com/dhruthi-kedilaya/real-time-chat-app/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Auth pages](https://github.com/dhruthi-kedilaya/real-time-chat-app/tree/main/frontend/src/pages): `frontend/src/pages`
- [Profile page](https://github.com/dhruthi-kedilaya/real-time-chat-app/blob/main/frontend/src/pages/ProfilePage.jsx): `frontend/src/pages/ProfilePage.jsx`
- [Create group page](https://github.com/dhruthi-kedilaya/real-time-chat-app/blob/main/frontend/src/pages/CreateGroupPage.jsx): `frontend/src/pages/CreateGroupPage.jsx`
- [Chat home](https://github.com/dhruthi-kedilaya/real-time-chat-app/blob/main/frontend/src/pages/HomePage.jsx): `frontend/src/pages/HomePage.jsx`
- [Chat interface](https://github.com/dhruthi-kedilaya/real-time-chat-app/tree/main/frontend/src/components): `frontend/src/components`
- [Personalization](https://github.com/dhruthi-kedilaya/real-time-chat-app/blob/main/frontend/src/store/usePersStore.jsx): `frontend/src/store/usePersStore.jsx`
- [HTTP client](https://github.com/dhruthi-kedilaya/real-time-chat-app/blob/main/frontend/src/lib/axios.js): `frontend/src/lib/axios.js`

### Identity

- [Auth state](https://github.com/dhruthi-kedilaya/real-time-chat-app/blob/main/frontend/src/store/useAuthStore.jsx): `frontend/src/store/useAuthStore.jsx`
- [Auth routes](https://github.com/dhruthi-kedilaya/real-time-chat-app/blob/main/backend/src/routes/authentication.js): `backend/src/routes/authentication.js`
- [Auth operations](https://github.com/dhruthi-kedilaya/real-time-chat-app/blob/main/backend/src/controller/authentication.js): `backend/src/controller/authentication.js`
- [Route protection](https://github.com/dhruthi-kedilaya/real-time-chat-app/blob/main/backend/src/middleware/protectRoute.js): `backend/src/middleware/protectRoute.js`

### Groups and chat

- [Group state](https://github.com/dhruthi-kedilaya/real-time-chat-app/blob/main/frontend/src/store/useGroupStore.jsx): `frontend/src/store/useGroupStore.jsx`
- [Group routes](https://github.com/dhruthi-kedilaya/real-time-chat-app/blob/main/backend/src/routes/group.js): `backend/src/routes/group.js`
- [Group operations](https://github.com/dhruthi-kedilaya/real-time-chat-app/blob/main/backend/src/controller/group.js): `backend/src/controller/group.js`
- [Direct messages](https://github.com/dhruthi-kedilaya/real-time-chat-app/blob/main/backend/src/controller/message.js): `backend/src/controller/message.js`

### API and realtime

- [Realtime server](https://github.com/dhruthi-kedilaya/real-time-chat-app/blob/main/backend/src/lib/socket.js): `backend/src/lib/socket.js`
- [HTTP server](https://github.com/dhruthi-kedilaya/real-time-chat-app/blob/main/backend/src/index.js): `backend/src/index.js`

### Persistence and media

- [User records](https://github.com/dhruthi-kedilaya/real-time-chat-app/blob/main/backend/src/models/User.js): `backend/src/models/User.js`
- [Group records](https://github.com/dhruthi-kedilaya/real-time-chat-app/blob/main/backend/src/models/Group.js): `backend/src/models/Group.js`
- [Message records](https://github.com/dhruthi-kedilaya/real-time-chat-app/blob/main/backend/src/models/Message.js): `backend/src/models/Message.js`
- [Image hosting](https://github.com/dhruthi-kedilaya/real-time-chat-app/blob/main/backend/src/lib/cloudinary.js): `backend/src/lib/cloudinary.js`

### Other components

- **Chat user**
- **MongoDB**

## Connections

- Chat user → Route shell: uses
- Route shell → Auth state: checks session (evidence: `frontend/src/App.jsx`)
- Route shell → Auth pages: routes to (evidence: `frontend/src/App.jsx`)
- Route shell → Profile page: routes to (evidence: `frontend/src/App.jsx`)
- Route shell → Create group page: routes to (evidence: `frontend/src/App.jsx`)
- Route shell → Chat home: routes to (evidence: `frontend/src/App.jsx`)
- Chat home → Chat interface: renders
- Auth pages → Auth state: authenticates (evidence: `frontend/src/pages/ProfilePage.jsx`)
- Profile page → Auth state: updates profile (evidence: `frontend/src/pages/ProfilePage.jsx`)
- Create group page → Group state: creates group
- Chat interface → Group state: uses (evidence: `frontend/src/components/Messages.jsx`)
- Chat interface → Personalization: uses (evidence: `frontend/src/components/Messages.jsx`)
- Auth state → HTTP client: sends requests (evidence: `frontend/src/store/useAuthStore.jsx`)
- Group state → HTTP client: sends requests (evidence: `frontend/src/store/useGroupStore.jsx`)
- Auth state → Realtime server: connects (evidence: `frontend/src/store/useAuthStore.jsx`)
- Group state → Realtime server: joins rooms (evidence: `frontend/src/store/useGroupStore.jsx`)
- HTTP client → Auth routes: calls API
- HTTP client → Group routes: calls API
- HTTP client → Direct messages: calls API
- HTTP server → Auth routes: mounts (evidence: `backend/src/index.js`)
- HTTP server → Group routes: mounts (evidence: `backend/src/index.js`)
- HTTP server → Realtime server: serves (evidence: `backend/src/index.js`)
- Auth routes → Auth operations: dispatches (evidence: `backend/src/routes/authentication.js`)
- Auth routes → Route protection: protects (evidence: `backend/src/routes/authentication.js`)
- Group routes → Group operations: dispatches (evidence: `backend/src/routes/group.js`)
- Route protection → User records: loads user (evidence: `backend/src/middleware/protectRoute.js`)
- Auth operations → User records: reads/writes (evidence: `backend/src/controller/authentication.js`)
- Auth operations → Image hosting: uploads profile image (evidence: `backend/src/controller/authentication.js`)
- Group operations → User records: reads/writes (evidence: `backend/src/controller/group.js`)
- Group operations → Group records: reads/writes (evidence: `backend/src/controller/group.js`)
- Group operations → Message records: reads/writes (evidence: `backend/src/controller/group.js`)
- Group operations → Image hosting: uploads images (evidence: `backend/src/controller/group.js`)
- Group operations → Realtime server: broadcasts message (evidence: `backend/src/controller/group.js`)
- User records → MongoDB: persists
- Group records → MongoDB: persists
- Message records → MongoDB: persists
