# atharv-06/real-time-chat-application- architecture

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

- Interactive diagram: https://gitdiagram.com/atharv-06/real-time-chat-application-
- Repository: https://github.com/atharv-06/real-time-chat-application-

## Overview

This is a full-stack real-time chat application. A user enters through the React app, authenticates through the auth store and REST API, then selects a conversation, loads or sends messages, and receives live updates over Socket.IO. The backend persists users and messages in MongoDB and can use Cloudinary for image uploads. The graph preserves the documented responsive UI, profile, settings, and REST capabilities. Several frontend and backend modules were not excerpted, so their detailed call relationships are not asserted.

Main entry points: [`frontend/src/App.jsx`](https://github.com/atharv-06/real-time-chat-application-/blob/main/frontend/src/App.jsx) (App routing), [`frontend/src/components/ChatContainer.jsx`](https://github.com/atharv-06/real-time-chat-application-/blob/main/frontend/src/components/ChatContainer.jsx) (Conversation UI), [`backend/src/controllers/message.controller.js`](https://github.com/atharv-06/real-time-chat-application-/blob/main/backend/src/controllers/message.controller.js) (Message controller), [`frontend/src/store/useAuthStore.js`](https://github.com/atharv-06/real-time-chat-application-/blob/main/frontend/src/store/useAuthStore.js) (Auth state)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_app["App routing<br/>[App.jsx]"]
  node_authpages["Auth pages<br/>[SignUpPage.jsx]"]
  node_authpattern["Auth visual pattern"]
  node_navbar["Navigation<br/>[Navbar.jsx]"]
  node_home["Chat page<br/>[HomePage.jsx]"]
  node_chatui["Conversation UI<br/>[ChatContainer.jsx]"]
  node_sidebar["Contact sidebar<br/>[Sidebar.jsx]"]
  node_messageinput["Message composer<br/>[MessageInput.jsx]"]
  node_chatheader["Conversation header<br/>[ChatHeader.jsx]"]
  node_emptychat["Empty conversation<br/>[NoChatSelected.jsx]"]
  node_settings["Theme settings<br/>[SettingsPage.jsx]"]
  node_themedata["Theme state<br/>[useThemeStore.js]"]
end

subgraph group_identity["Identity and profiles"]
  node_authstore["Auth state<br/>[useAuthStore.js]"]
  node_profile["Profile page<br/>[ProfilePage.jsx]"]
  node_authapi["Auth controller<br/>[auth.controller.js]"]
  node_authroutes["Auth routes<br/>[auth.route.js]"]
  node_authguard["JWT guard<br/>[auth.middleware.js]"]
  node_userrecord[("User model<br/>[user.model.js]")]
end

subgraph group_chat["Messaging"]
  node_chatstore["Chat state<br/>[useChatStore.js]"]
  node_messageapi["Message controller"]
  node_messageroutes["Message routes<br/>[message.route.js]"]
  node_messagerecord[("Message model<br/>[message.model.js]")]
end

subgraph group_server["API and persistence"]
  node_serverentry["Server entry<br/>[index.js]"]
  node_dbconnect["Database connection<br/>[db.js]"]
  node_mongodb[("MongoDB")]
  node_cloudinary["Image hosting<br/>[cloudinary.js]"]
  node_axios["HTTP client<br/>[axios.js]"]
end

subgraph group_realtime["Live presence"]
  node_socketserver["Socket server<br/>[socket.js]"]
end

node_user(("Chat user"))

node_user -->|"uses"| node_app
node_app -->|"routes to"| node_authpages
node_app -->|"routes to"| node_home
node_app -->|"renders"| node_navbar
node_app -->|"checks auth"| node_authstore
node_app -->|"reads theme"| node_themedata
node_authpages -->|"submits signup"| node_authstore
node_authpages -->|"renders"| node_authpattern
node_home -.->|"presents chat"| node_chatui
node_chatui -.->|"shows contacts"| node_sidebar
node_chatui -.->|"composes messages"| node_messageinput
node_chatui -.->|"shows conversation"| node_chatheader
node_chatui -.->|"shows empty state"| node_emptychat
node_chatui -.->|"uses state"| node_chatstore
node_chatstore -->|"calls API"| node_axios
node_authstore -->|"calls API"| node_axios
node_authstore -->|"connects live"| node_socketserver
node_profile -.->|"updates profile"| node_authstore
node_settings -.->|"changes theme"| node_themedata
node_axios -.->|"requests auth"| node_authroutes
node_axios -.->|"requests messages"| node_messageroutes
node_serverentry -->|"mounts routes"| node_authroutes
node_serverentry -->|"mounts routes"| node_messageroutes
node_serverentry -->|"connects database"| node_dbconnect
node_serverentry -->|"uses server"| node_socketserver
node_authroutes -->|"dispatches"| node_authapi
node_authroutes -->|"guards routes"| node_authguard
node_messageroutes -->|"dispatches"| node_messageapi
node_messageroutes -->|"guards routes"| node_authguard
node_authguard -->|"loads user"| node_userrecord
node_authapi -->|"reads and writes"| node_userrecord
node_authapi -->|"uploads profile image"| node_cloudinary
node_messageapi -->|"lists contacts"| node_userrecord
node_messageapi -->|"reads and writes"| node_messagerecord
node_messageapi -->|"uploads message image"| node_cloudinary
node_messageapi -->|"emits message"| node_socketserver
node_dbconnect -->|"connects"| node_mongodb
node_messageapi -->|"resolves recipient"| node_userrecord

click node_app "https://github.com/atharv-06/real-time-chat-application-/blob/main/frontend/src/App.jsx"
click node_authpages "https://github.com/atharv-06/real-time-chat-application-/blob/main/frontend/src/pages/SignUpPage.jsx"
click node_authpattern "https://github.com/atharv-06/real-time-chat-application-/blob/main/frontend/src/components/AuthImagePattern.jsx"
click node_navbar "https://github.com/atharv-06/real-time-chat-application-/blob/main/frontend/src/components/Navbar.jsx"
click node_home "https://github.com/atharv-06/real-time-chat-application-/blob/main/frontend/src/pages/HomePage.jsx"
click node_chatui "https://github.com/atharv-06/real-time-chat-application-/blob/main/frontend/src/components/ChatContainer.jsx"
click node_sidebar "https://github.com/atharv-06/real-time-chat-application-/blob/main/frontend/src/components/Sidebar.jsx"
click node_messageinput "https://github.com/atharv-06/real-time-chat-application-/blob/main/frontend/src/components/MessageInput.jsx"
click node_chatheader "https://github.com/atharv-06/real-time-chat-application-/blob/main/frontend/src/components/ChatHeader.jsx"
click node_emptychat "https://github.com/atharv-06/real-time-chat-application-/blob/main/frontend/src/components/NoChatSelected.jsx"
click node_authstore "https://github.com/atharv-06/real-time-chat-application-/blob/main/frontend/src/store/useAuthStore.js"
click node_profile "https://github.com/atharv-06/real-time-chat-application-/blob/main/frontend/src/pages/ProfilePage.jsx"
click node_authapi "https://github.com/atharv-06/real-time-chat-application-/blob/main/backend/src/controllers/auth.controller.js"
click node_authroutes "https://github.com/atharv-06/real-time-chat-application-/blob/main/backend/src/routes/auth.route.js"
click node_authguard "https://github.com/atharv-06/real-time-chat-application-/blob/main/backend/src/middleware/auth.middleware.js"
click node_userrecord "https://github.com/atharv-06/real-time-chat-application-/blob/main/backend/src/models/user.model.js"
click node_chatstore "https://github.com/atharv-06/real-time-chat-application-/blob/main/frontend/src/store/useChatStore.js"
click node_messageapi "https://github.com/atharv-06/real-time-chat-application-/blob/main/backend/src/controllers/message.controller.js"
click node_messageroutes "https://github.com/atharv-06/real-time-chat-application-/blob/main/backend/src/routes/message.route.js"
click node_messagerecord "https://github.com/atharv-06/real-time-chat-application-/blob/main/backend/src/models/message.model.js"
click node_settings "https://github.com/atharv-06/real-time-chat-application-/blob/main/frontend/src/pages/SettingsPage.jsx"
click node_themedata "https://github.com/atharv-06/real-time-chat-application-/blob/main/frontend/src/store/useThemeStore.js"
click node_serverentry "https://github.com/atharv-06/real-time-chat-application-/blob/main/backend/src/index.js"
click node_dbconnect "https://github.com/atharv-06/real-time-chat-application-/blob/main/backend/src/lib/db.js"
click node_cloudinary "https://github.com/atharv-06/real-time-chat-application-/blob/main/backend/src/lib/cloudinary.js"
click node_socketserver "https://github.com/atharv-06/real-time-chat-application-/blob/main/backend/src/lib/socket.js"
click node_axios "https://github.com/atharv-06/real-time-chat-application-/blob/main/frontend/src/lib/axios.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_authpattern,node_navbar,node_home,node_chatui,node_sidebar,node_messageinput,node_chatheader,node_emptychat,node_settings,node_themedata,node_user toneBlue
class node_authstore,node_profile,node_authapi,node_authroutes,node_authguard,node_userrecord toneAmber
class node_chatstore,node_messageapi,node_messageroutes,node_messagerecord toneMint
class node_serverentry,node_dbconnect,node_mongodb,node_cloudinary,node_axios toneRose
class node_socketserver toneIndigo
```

## Components

### Web client

- [App routing](https://github.com/atharv-06/real-time-chat-application-/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Auth pages](https://github.com/atharv-06/real-time-chat-application-/blob/main/frontend/src/pages/SignUpPage.jsx): `frontend/src/pages/SignUpPage.jsx`
- [Auth visual pattern](https://github.com/atharv-06/real-time-chat-application-/blob/main/frontend/src/components/AuthImagePattern.jsx): `frontend/src/components/AuthImagePattern.jsx`
- [Navigation](https://github.com/atharv-06/real-time-chat-application-/blob/main/frontend/src/components/Navbar.jsx): `frontend/src/components/Navbar.jsx`
- [Chat page](https://github.com/atharv-06/real-time-chat-application-/blob/main/frontend/src/pages/HomePage.jsx): `frontend/src/pages/HomePage.jsx`
- [Conversation UI](https://github.com/atharv-06/real-time-chat-application-/blob/main/frontend/src/components/ChatContainer.jsx): `frontend/src/components/ChatContainer.jsx`
- [Contact sidebar](https://github.com/atharv-06/real-time-chat-application-/blob/main/frontend/src/components/Sidebar.jsx): `frontend/src/components/Sidebar.jsx`
- [Message composer](https://github.com/atharv-06/real-time-chat-application-/blob/main/frontend/src/components/MessageInput.jsx): `frontend/src/components/MessageInput.jsx`
- [Conversation header](https://github.com/atharv-06/real-time-chat-application-/blob/main/frontend/src/components/ChatHeader.jsx): `frontend/src/components/ChatHeader.jsx`
- [Empty conversation](https://github.com/atharv-06/real-time-chat-application-/blob/main/frontend/src/components/NoChatSelected.jsx): `frontend/src/components/NoChatSelected.jsx`
- [Theme settings](https://github.com/atharv-06/real-time-chat-application-/blob/main/frontend/src/pages/SettingsPage.jsx): `frontend/src/pages/SettingsPage.jsx`
- [Theme state](https://github.com/atharv-06/real-time-chat-application-/blob/main/frontend/src/store/useThemeStore.js): `frontend/src/store/useThemeStore.js`

### Identity and profiles

- [Auth state](https://github.com/atharv-06/real-time-chat-application-/blob/main/frontend/src/store/useAuthStore.js): `frontend/src/store/useAuthStore.js`
- [Profile page](https://github.com/atharv-06/real-time-chat-application-/blob/main/frontend/src/pages/ProfilePage.jsx): `frontend/src/pages/ProfilePage.jsx`
- [Auth controller](https://github.com/atharv-06/real-time-chat-application-/blob/main/backend/src/controllers/auth.controller.js): `backend/src/controllers/auth.controller.js`
- [Auth routes](https://github.com/atharv-06/real-time-chat-application-/blob/main/backend/src/routes/auth.route.js): `backend/src/routes/auth.route.js`
- [JWT guard](https://github.com/atharv-06/real-time-chat-application-/blob/main/backend/src/middleware/auth.middleware.js): `backend/src/middleware/auth.middleware.js`
- [User model](https://github.com/atharv-06/real-time-chat-application-/blob/main/backend/src/models/user.model.js): `backend/src/models/user.model.js`

### Messaging

- [Chat state](https://github.com/atharv-06/real-time-chat-application-/blob/main/frontend/src/store/useChatStore.js): `frontend/src/store/useChatStore.js`
- [Message controller](https://github.com/atharv-06/real-time-chat-application-/blob/main/backend/src/controllers/message.controller.js): `backend/src/controllers/message.controller.js`
- [Message routes](https://github.com/atharv-06/real-time-chat-application-/blob/main/backend/src/routes/message.route.js): `backend/src/routes/message.route.js`
- [Message model](https://github.com/atharv-06/real-time-chat-application-/blob/main/backend/src/models/message.model.js): `backend/src/models/message.model.js`

### API and persistence

- [Server entry](https://github.com/atharv-06/real-time-chat-application-/blob/main/backend/src/index.js): `backend/src/index.js`
- [Database connection](https://github.com/atharv-06/real-time-chat-application-/blob/main/backend/src/lib/db.js): `backend/src/lib/db.js`
- **MongoDB**
- [Image hosting](https://github.com/atharv-06/real-time-chat-application-/blob/main/backend/src/lib/cloudinary.js): `backend/src/lib/cloudinary.js`
- [HTTP client](https://github.com/atharv-06/real-time-chat-application-/blob/main/frontend/src/lib/axios.js): `frontend/src/lib/axios.js`

### Live presence

- [Socket server](https://github.com/atharv-06/real-time-chat-application-/blob/main/backend/src/lib/socket.js): `backend/src/lib/socket.js`

### Other components

- **Chat user**

## Connections

- Chat user → App routing: uses
- App routing → Auth pages: routes to (evidence: `frontend/src/App.jsx`)
- App routing → Chat page: routes to (evidence: `frontend/src/App.jsx`)
- App routing → Navigation: renders (evidence: `frontend/src/App.jsx`)
- App routing → Auth state: checks auth (evidence: `frontend/src/App.jsx`)
- App routing → Theme state: reads theme (evidence: `frontend/src/App.jsx`)
- Auth pages → Auth state: submits signup (evidence: `frontend/src/pages/SignUpPage.jsx`)
- Auth pages → Auth visual pattern: renders (evidence: `frontend/src/pages/SignUpPage.jsx`)
- Chat page → Conversation UI: presents chat
- Conversation UI → Contact sidebar: shows contacts
- Conversation UI → Message composer: composes messages
- Conversation UI → Conversation header: shows conversation
- Conversation UI → Empty conversation: shows empty state
- Conversation UI → Chat state: uses state
- Chat state → HTTP client: calls API (evidence: `frontend/src/store/useChatStore.js`)
- Auth state → HTTP client: calls API (evidence: `frontend/src/store/useAuthStore.js`)
- Auth state → Socket server: connects live (evidence: `frontend/src/store/useAuthStore.js`)
- Profile page → Auth state: updates profile
- Theme settings → Theme state: changes theme
- HTTP client → Auth routes: requests auth
- HTTP client → Message routes: requests messages
- Server entry → Auth routes: mounts routes (evidence: `backend/src/index.js`)
- Server entry → Message routes: mounts routes (evidence: `backend/src/index.js`)
- Server entry → Database connection: connects database (evidence: `backend/src/index.js`)
- Server entry → Socket server: uses server (evidence: `backend/src/index.js`)
- Auth routes → Auth controller: dispatches (evidence: `backend/src/routes/auth.route.js`)
- Auth routes → JWT guard: guards routes (evidence: `backend/src/routes/auth.route.js`)
- Message routes → Message controller: dispatches (evidence: `backend/src/routes/message.route.js`)
- Message routes → JWT guard: guards routes (evidence: `backend/src/routes/message.route.js`)
- JWT guard → User model: loads user (evidence: `backend/src/middleware/auth.middleware.js`)
- Auth controller → User model: reads and writes (evidence: `backend/src/controllers/auth.controller.js`)
- Auth controller → Image hosting: uploads profile image (evidence: `backend/src/controllers/auth.controller.js`)
- Message controller → User model: lists contacts (evidence: `backend/src/controllers/message.controller.js`)
- Message controller → Message model: reads and writes (evidence: `backend/src/controllers/message.controller.js`)
- Message controller → Image hosting: uploads message image (evidence: `backend/src/controllers/message.controller.js`)
- Message controller → Socket server: emits message (evidence: `backend/src/controllers/message.controller.js`)
- Database connection → MongoDB: connects
- Message controller → User model: resolves recipient (evidence: `backend/src/controllers/message.controller.js`)
