# itsgbishal/real-time-chat-application architecture

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

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

## Overview

Chatify is a web chat application with account access, one-to-one messaging, group chats, profile and group images, and live presence/message updates. The user workflow is to sign in, select a contact or group, then exchange text or images; backend controllers persist and retrieve chat data and use sockets for live delivery. The README documents running separate frontend and backend processes but gives no further feature architecture. Some UI and route implementations were not excerpted, so uncertain HTTP links are shown as unverified.

Main entry points: [`backend/src/controllers/message.controller.js`](https://github.com/itsgbishal/real-time-chat-application/blob/main/backend/src/controllers/message.controller.js) (Message operations), [`backend/src/controllers/group.controller.js`](https://github.com/itsgbishal/real-time-chat-application/blob/main/backend/src/controllers/group.controller.js) (Group operations), [`frontend/src/App.jsx`](https://github.com/itsgbishal/real-time-chat-application/blob/main/frontend/src/App.jsx) (App routing), [`frontend/src/store/useChatStore.js`](https://github.com/itsgbishal/real-time-chat-application/blob/main/frontend/src/store/useChatStore.js) (Chat state and actions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_app["App routing<br/>[App.jsx]"]
  node_authpages["Login and signup<br/>[LoginPage.jsx]"]
  node_chatpage["Chat workspace<br/>[ChatPage.jsx]"]
  node_chatui["Chat views and input"]
  node_groupui["Group views and modal"]
end

subgraph group_identity["Accounts"]
  node_authstore["Auth state<br/>[useAuthStore.js]"]
  node_authroutes["Auth routes<br/>[auth.route.js]"]
  node_authcontroller["Auth operations<br/>[auth.controller.js]"]
  node_userdb[("User records<br/>[User.js]")]
  node_email["Welcome email<br/>[emailHandlers.js]"]
end

subgraph group_messaging["Messaging"]
  node_chatstore["Chat state and actions<br/>[useChatStore.js]"]
  node_messageui["Message views and input<br/>[MessageInput.jsx]"]
  node_messageroutes["Message routes<br/>[message.route.js]"]
  node_messagecontroller["Message operations"]
  node_messagedb[("Message records<br/>[Message.js]")]
  node_encryption["Message encryption<br/>[encryption.js]"]
end

subgraph group_groups["Group chats"]
  node_grouproutes["Group routes<br/>[group.route.js]"]
  node_groupcontroller["Group operations"]
  node_groupdb[("Group records<br/>[Group.js]")]
end

subgraph group_platform["Runtime services"]
  node_socket["Socket runtime<br/>[socket.js]"]
  node_authmw["Socket authentication"]
  node_cloudinary["Image hosting<br/>[cloudinary.js]"]
  node_resend["Email provider<br/>[resend.js]"]
  node_server["HTTP server<br/>[server.js]"]
end

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

node_person -->|"uses"| node_app
node_app -->|"checks session"| node_authstore
node_app -->|"routes to"| node_authpages
node_app -->|"routes to"| node_chatpage
node_authpages -->|"calls auth actions"| node_authstore
node_chatpage -->|"renders"| node_chatui
node_chatpage -->|"renders"| node_groupui
node_chatui -.->|"uses actions"| node_chatstore
node_groupui -->|"uses actions"| node_chatstore
node_authstore -.->|"HTTP requests"| node_authroutes
node_chatstore -.->|"HTTP requests"| node_messageroutes
node_chatstore -.->|"HTTP requests"| node_grouproutes
node_authroutes -->|"routes to"| node_authcontroller
node_authcontroller -->|"reads and writes"| node_userdb
node_authcontroller -->|"sends welcome"| node_email
node_email -->|"sends through"| node_resend
node_messageroutes -->|"routes to"| node_messagecontroller
node_messagecontroller -->|"reads and writes"| node_messagedb
node_messagecontroller -->|"looks up users"| node_userdb
node_messagecontroller -->|"encrypts and decrypts"| node_encryption
node_messagecontroller -->|"uploads images"| node_cloudinary
node_messagecontroller -->|"dispatches events"| node_socket
node_grouproutes -->|"routes to"| node_groupcontroller
node_groupcontroller -->|"reads and writes"| node_groupdb
node_groupcontroller -->|"looks up members"| node_userdb
node_groupcontroller -->|"uploads images"| node_cloudinary
node_groupcontroller -->|"dispatches events"| node_socket
node_socket -->|"authenticates connections"| node_authmw
node_server -->|"mounts routes"| node_authroutes
node_server -->|"mounts routes"| node_messageroutes
node_server -->|"mounts routes"| node_grouproutes
node_userdb -.->|"persists records"| node_database
node_messagedb -.->|"persists records"| node_database
node_groupdb -.->|"persists records"| node_database

click node_app "https://github.com/itsgbishal/real-time-chat-application/blob/main/frontend/src/App.jsx"
click node_authpages "https://github.com/itsgbishal/real-time-chat-application/blob/main/frontend/src/pages/LoginPage.jsx"
click node_chatpage "https://github.com/itsgbishal/real-time-chat-application/blob/main/frontend/src/pages/ChatPage.jsx"
click node_chatui "https://github.com/itsgbishal/real-time-chat-application/tree/main/frontend/src/components"
click node_groupui "https://github.com/itsgbishal/real-time-chat-application/tree/main/frontend/src/components"
click node_authstore "https://github.com/itsgbishal/real-time-chat-application/blob/main/frontend/src/store/useAuthStore.js"
click node_authroutes "https://github.com/itsgbishal/real-time-chat-application/blob/main/backend/src/routes/auth.route.js"
click node_authcontroller "https://github.com/itsgbishal/real-time-chat-application/blob/main/backend/src/controllers/auth.controller.js"
click node_userdb "https://github.com/itsgbishal/real-time-chat-application/blob/main/backend/src/models/User.js"
click node_email "https://github.com/itsgbishal/real-time-chat-application/blob/main/backend/src/emails/emailHandlers.js"
click node_chatstore "https://github.com/itsgbishal/real-time-chat-application/blob/main/frontend/src/store/useChatStore.js"
click node_messageui "https://github.com/itsgbishal/real-time-chat-application/blob/main/frontend/src/components/MessageInput.jsx"
click node_messageroutes "https://github.com/itsgbishal/real-time-chat-application/blob/main/backend/src/routes/message.route.js"
click node_messagecontroller "https://github.com/itsgbishal/real-time-chat-application/blob/main/backend/src/controllers/message.controller.js"
click node_messagedb "https://github.com/itsgbishal/real-time-chat-application/blob/main/backend/src/models/Message.js"
click node_encryption "https://github.com/itsgbishal/real-time-chat-application/blob/main/backend/src/lib/encryption.js"
click node_grouproutes "https://github.com/itsgbishal/real-time-chat-application/blob/main/backend/src/routes/group.route.js"
click node_groupcontroller "https://github.com/itsgbishal/real-time-chat-application/blob/main/backend/src/controllers/group.controller.js"
click node_groupdb "https://github.com/itsgbishal/real-time-chat-application/blob/main/backend/src/models/Group.js"
click node_socket "https://github.com/itsgbishal/real-time-chat-application/blob/main/backend/src/lib/socket.js"
click node_authmw "https://github.com/itsgbishal/real-time-chat-application/blob/main/backend/src/middleware/socket.auth.middleware.js"
click node_cloudinary "https://github.com/itsgbishal/real-time-chat-application/blob/main/backend/src/lib/cloudinary.js"
click node_resend "https://github.com/itsgbishal/real-time-chat-application/blob/main/backend/src/lib/resend.js"
click node_server "https://github.com/itsgbishal/real-time-chat-application/blob/main/backend/src/server.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_chatpage,node_chatui,node_groupui,node_person toneBlue
class node_authstore,node_authroutes,node_authcontroller,node_userdb,node_email,node_database toneAmber
class node_chatstore,node_messageui,node_messageroutes,node_messagecontroller,node_messagedb,node_encryption toneMint
class node_grouproutes,node_groupcontroller,node_groupdb toneRose
class node_socket,node_authmw,node_cloudinary,node_resend,node_server toneIndigo
```

## Components

### Web client

- [App routing](https://github.com/itsgbishal/real-time-chat-application/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Login and signup](https://github.com/itsgbishal/real-time-chat-application/blob/main/frontend/src/pages/LoginPage.jsx): `frontend/src/pages/LoginPage.jsx`
- [Chat workspace](https://github.com/itsgbishal/real-time-chat-application/blob/main/frontend/src/pages/ChatPage.jsx): `frontend/src/pages/ChatPage.jsx`
- [Chat views and input](https://github.com/itsgbishal/real-time-chat-application/tree/main/frontend/src/components): `frontend/src/components`
- [Group views and modal](https://github.com/itsgbishal/real-time-chat-application/tree/main/frontend/src/components): `frontend/src/components`

### Accounts

- [Auth state](https://github.com/itsgbishal/real-time-chat-application/blob/main/frontend/src/store/useAuthStore.js): `frontend/src/store/useAuthStore.js`
- [Auth routes](https://github.com/itsgbishal/real-time-chat-application/blob/main/backend/src/routes/auth.route.js): `backend/src/routes/auth.route.js`
- [Auth operations](https://github.com/itsgbishal/real-time-chat-application/blob/main/backend/src/controllers/auth.controller.js): `backend/src/controllers/auth.controller.js`
- [User records](https://github.com/itsgbishal/real-time-chat-application/blob/main/backend/src/models/User.js): `backend/src/models/User.js`
- [Welcome email](https://github.com/itsgbishal/real-time-chat-application/blob/main/backend/src/emails/emailHandlers.js): `backend/src/emails/emailHandlers.js`

### Messaging

- [Chat state and actions](https://github.com/itsgbishal/real-time-chat-application/blob/main/frontend/src/store/useChatStore.js): `frontend/src/store/useChatStore.js`
- [Message views and input](https://github.com/itsgbishal/real-time-chat-application/blob/main/frontend/src/components/MessageInput.jsx): `frontend/src/components/MessageInput.jsx`
- [Message routes](https://github.com/itsgbishal/real-time-chat-application/blob/main/backend/src/routes/message.route.js): `backend/src/routes/message.route.js`
- [Message operations](https://github.com/itsgbishal/real-time-chat-application/blob/main/backend/src/controllers/message.controller.js): `backend/src/controllers/message.controller.js`
- [Message records](https://github.com/itsgbishal/real-time-chat-application/blob/main/backend/src/models/Message.js): `backend/src/models/Message.js`
- [Message encryption](https://github.com/itsgbishal/real-time-chat-application/blob/main/backend/src/lib/encryption.js): `backend/src/lib/encryption.js`

### Group chats

- [Group routes](https://github.com/itsgbishal/real-time-chat-application/blob/main/backend/src/routes/group.route.js): `backend/src/routes/group.route.js`
- [Group operations](https://github.com/itsgbishal/real-time-chat-application/blob/main/backend/src/controllers/group.controller.js): `backend/src/controllers/group.controller.js`
- [Group records](https://github.com/itsgbishal/real-time-chat-application/blob/main/backend/src/models/Group.js): `backend/src/models/Group.js`

### Runtime services

- [Socket runtime](https://github.com/itsgbishal/real-time-chat-application/blob/main/backend/src/lib/socket.js): `backend/src/lib/socket.js`
- [Socket authentication](https://github.com/itsgbishal/real-time-chat-application/blob/main/backend/src/middleware/socket.auth.middleware.js): `backend/src/middleware/socket.auth.middleware.js`
- [Image hosting](https://github.com/itsgbishal/real-time-chat-application/blob/main/backend/src/lib/cloudinary.js): `backend/src/lib/cloudinary.js`
- [Email provider](https://github.com/itsgbishal/real-time-chat-application/blob/main/backend/src/lib/resend.js): `backend/src/lib/resend.js`
- [HTTP server](https://github.com/itsgbishal/real-time-chat-application/blob/main/backend/src/server.js): `backend/src/server.js`

### Other components

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

## Connections

- Chat user → App routing: uses (evidence: `frontend/src/App.jsx`)
- App routing → Auth state: checks session (evidence: `frontend/src/App.jsx`)
- App routing → Login and signup: routes to (evidence: `frontend/src/App.jsx`)
- App routing → Chat workspace: routes to (evidence: `frontend/src/App.jsx`)
- Login and signup → Auth state: calls auth actions (evidence: `frontend/src/pages/LoginPage.jsx`)
- Chat workspace → Chat views and input: renders (evidence: `frontend/src/pages/ChatPage.jsx`)
- Chat workspace → Group views and modal: renders (evidence: `frontend/src/pages/ChatPage.jsx`)
- Chat views and input → Chat state and actions: uses actions (evidence: `frontend/src/components/CreateGroupModal.jsx`)
- Group views and modal → Chat state and actions: uses actions (evidence: `frontend/src/components/GroupChatContainer.jsx`)
- Auth state → Auth routes: HTTP requests
- Chat state and actions → Message routes: HTTP requests
- Chat state and actions → Group routes: HTTP requests
- Auth routes → Auth operations: routes to (evidence: `backend/src/routes/auth.route.js`)
- Auth operations → User records: reads and writes (evidence: `backend/src/controllers/auth.controller.js`)
- Auth operations → Welcome email: sends welcome (evidence: `backend/src/controllers/auth.controller.js`)
- Welcome email → Email provider: sends through (evidence: `backend/src/emails/emailHandlers.js`)
- Message routes → Message operations: routes to (evidence: `backend/src/routes/message.route.js`)
- Message operations → Message records: reads and writes (evidence: `backend/src/controllers/message.controller.js`)
- Message operations → User records: looks up users (evidence: `backend/src/controllers/message.controller.js`)
- Message operations → Message encryption: encrypts and decrypts (evidence: `backend/src/controllers/message.controller.js`)
- Message operations → Image hosting: uploads images (evidence: `backend/src/controllers/message.controller.js`)
- Message operations → Socket runtime: dispatches events (evidence: `backend/src/controllers/message.controller.js`)
- Group routes → Group operations: routes to (evidence: `backend/src/routes/group.route.js`)
- Group operations → Group records: reads and writes (evidence: `backend/src/controllers/group.controller.js`)
- Group operations → User records: looks up members (evidence: `backend/src/controllers/group.controller.js`)
- Group operations → Image hosting: uploads images (evidence: `backend/src/controllers/group.controller.js`)
- Group operations → Socket runtime: dispatches events (evidence: `backend/src/controllers/group.controller.js`)
- Socket runtime → Socket authentication: authenticates connections (evidence: `backend/src/lib/socket.js`)
- HTTP server → Auth routes: mounts routes (evidence: `backend/src/server.js`)
- HTTP server → Message routes: mounts routes (evidence: `backend/src/server.js`)
- HTTP server → Group routes: mounts routes (evidence: `backend/src/server.js`)
- User records → MongoDB: persists records
- Message records → MongoDB: persists records
- Group records → MongoDB: persists records
