# iemafzalhassan/full-stack_chatapp architecture

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

- Interactive diagram: https://gitdiagram.com/iemafzalhassan/full-stack_chatapp
- Repository: https://github.com/iemafzalhassan/full-stack_chatapp

## Overview

This is a full-stack real-time chat application. A user signs up or logs in, selects another user, retrieves conversation history, sends text or an image, and receives new messages and online-user updates. The backend routes requests through authentication and controllers to user/message models; Socket.IO handles live delivery. The frontend also provides profile-picture updates and theme settings. The graph follows documented and indexed references; unsampled subsystems are included where the README or source index supports them, but uncertain links are omitted.

Main entry points: [`frontend/src/App.jsx`](https://github.com/iemafzalhassan/full-stack_chatapp/blob/main/frontend/src/App.jsx) (App routing), [`frontend/src/store/useAuthStore.js`](https://github.com/iemafzalhassan/full-stack_chatapp/blob/main/frontend/src/store/useAuthStore.js) (Auth state), [`frontend/src/store/useChatStore.js`](https://github.com/iemafzalhassan/full-stack_chatapp/blob/main/frontend/src/store/useChatStore.js) (Chat state), [`backend/src/controllers/message.controller.js`](https://github.com/iemafzalhassan/full-stack_chatapp/blob/main/backend/src/controllers/message.controller.js) (Message controller)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web application"]
  node_app["App routing<br/>[App.jsx]"]
  node_authpages["Login and signup<br/>[LoginPage.jsx]"]
  node_signup["Signup page<br/>[SignUpPage.jsx]"]
  node_home["Chat home<br/>[HomePage.jsx]"]
  node_sidebar["User sidebar<br/>[Sidebar.jsx]"]
  node_chatview["Conversation view<br/>[ChatContainer.jsx]"]
  node_chatheader["Chat header<br/>[ChatHeader.jsx]"]
  node_messageinput["Message composer<br/>[MessageInput.jsx]"]
  node_profilepage["Profile page<br/>[ProfilePage.jsx]"]
  node_settingspage["Theme settings<br/>[SettingsPage.jsx]"]
  node_authstate["Auth state<br/>[useAuthStore.js]"]
  node_chatstate["Chat state<br/>[useChatStore.js]"]
  node_themestate["Theme state<br/>[useThemeStore.js]"]
  node_http["HTTP client<br/>[axios.js]"]
end

subgraph group_backend["Backend API"]
  node_api["Express API<br/>[index.js]"]
  node_authroutes["Auth routes<br/>[auth.route.js]"]
  node_messageroutes["Message routes<br/>[message.route.js]"]
  node_authcontroller["Auth controller<br/>[auth.controller.js]"]
  node_messagecontroller["Message controller"]
  node_authmiddleware["JWT protection<br/>[auth.middleware.js]"]
end

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

subgraph group_data["Persistence and media"]
  node_userstore[("User model<br/>[user.model.js]")]
  node_messagestore[("Message model<br/>[message.model.js]")]
  node_dbconnect["Database connection<br/>[db.js]"]
  node_cloudinary["Image hosting<br/>[cloudinary.js]"]
end

node_user(("Chat user"))
node_mongodb[("MongoDB")]
node_cloudservice[("Cloudinary service")]

node_user -->|"uses"| node_app
node_app -->|"routes to"| node_authpages
node_app -->|"routes to"| node_signup
node_app -->|"routes to"| node_home
node_app -->|"routes to"| node_profilepage
node_app -->|"routes to"| node_settingspage
node_app -->|"checks auth"| node_authstate
node_app -->|"reads theme"| node_themestate
node_authpages -->|"submits credentials"| node_authstate
node_signup -->|"creates account"| node_authstate
node_profilepage -->|"updates profile"| node_authstate
node_settingspage -->|"sets theme"| node_themestate
node_home -->|"renders"| node_sidebar
node_home -->|"renders"| node_chatview
node_home -->|"reads selection"| node_chatstate
node_sidebar -->|"selects user"| node_chatstate
node_chatview -->|"renders"| node_chatheader
node_chatview -->|"renders"| node_messageinput
node_chatview -->|"loads messages"| node_chatstate
node_messageinput -->|"sends message"| node_chatstate
node_authstate -->|"calls API"| node_http
node_chatstate -->|"calls API"| node_http
node_chatstate -->|"uses socket"| node_authstate
node_authstate -->|"connects"| node_socket
node_user -->|"authenticates"| node_authstate
node_http -.->|"HTTP requests"| node_api
node_api -->|"mounts routes"| node_authroutes
node_api -->|"mounts routes"| node_messageroutes
node_api -->|"connects database"| node_dbconnect
node_authroutes -->|"dispatches"| node_authcontroller
node_authroutes -->|"protects routes"| node_authmiddleware
node_messageroutes -->|"protects routes"| node_authmiddleware
node_messageroutes -->|"dispatches"| node_messagecontroller
node_authcontroller -->|"reads and writes"| node_userstore
node_authmiddleware -->|"loads user"| node_userstore
node_messagecontroller -->|"lists users"| node_userstore
node_messagecontroller -->|"reads and writes"| node_messagestore
node_messagecontroller -->|"emits message"| node_socket
node_socket -.->|"sends presence events"| node_authstate
node_chatstate -->|"receives messages"| node_socket
node_authcontroller -->|"uploads profile image"| node_cloudinary
node_messagecontroller -->|"uploads message image"| node_cloudinary
node_cloudinary -.->|"stores images"| node_cloudservice
node_dbconnect -.->|"connects"| node_mongodb

click node_app "https://github.com/iemafzalhassan/full-stack_chatapp/blob/main/frontend/src/App.jsx"
click node_authpages "https://github.com/iemafzalhassan/full-stack_chatapp/blob/main/frontend/src/pages/LoginPage.jsx"
click node_signup "https://github.com/iemafzalhassan/full-stack_chatapp/blob/main/frontend/src/pages/SignUpPage.jsx"
click node_home "https://github.com/iemafzalhassan/full-stack_chatapp/blob/main/frontend/src/pages/HomePage.jsx"
click node_sidebar "https://github.com/iemafzalhassan/full-stack_chatapp/blob/main/frontend/src/components/Sidebar.jsx"
click node_chatview "https://github.com/iemafzalhassan/full-stack_chatapp/blob/main/frontend/src/components/ChatContainer.jsx"
click node_chatheader "https://github.com/iemafzalhassan/full-stack_chatapp/blob/main/frontend/src/components/ChatHeader.jsx"
click node_messageinput "https://github.com/iemafzalhassan/full-stack_chatapp/blob/main/frontend/src/components/MessageInput.jsx"
click node_profilepage "https://github.com/iemafzalhassan/full-stack_chatapp/blob/main/frontend/src/pages/ProfilePage.jsx"
click node_settingspage "https://github.com/iemafzalhassan/full-stack_chatapp/blob/main/frontend/src/pages/SettingsPage.jsx"
click node_authstate "https://github.com/iemafzalhassan/full-stack_chatapp/blob/main/frontend/src/store/useAuthStore.js"
click node_chatstate "https://github.com/iemafzalhassan/full-stack_chatapp/blob/main/frontend/src/store/useChatStore.js"
click node_themestate "https://github.com/iemafzalhassan/full-stack_chatapp/blob/main/frontend/src/store/useThemeStore.js"
click node_http "https://github.com/iemafzalhassan/full-stack_chatapp/blob/main/frontend/src/lib/axios.js"
click node_api "https://github.com/iemafzalhassan/full-stack_chatapp/blob/main/backend/src/index.js"
click node_authroutes "https://github.com/iemafzalhassan/full-stack_chatapp/blob/main/backend/src/routes/auth.route.js"
click node_messageroutes "https://github.com/iemafzalhassan/full-stack_chatapp/blob/main/backend/src/routes/message.route.js"
click node_authcontroller "https://github.com/iemafzalhassan/full-stack_chatapp/blob/main/backend/src/controllers/auth.controller.js"
click node_messagecontroller "https://github.com/iemafzalhassan/full-stack_chatapp/blob/main/backend/src/controllers/message.controller.js"
click node_authmiddleware "https://github.com/iemafzalhassan/full-stack_chatapp/blob/main/backend/src/middleware/auth.middleware.js"
click node_socket "https://github.com/iemafzalhassan/full-stack_chatapp/blob/main/backend/src/lib/socket.js"
click node_userstore "https://github.com/iemafzalhassan/full-stack_chatapp/blob/main/backend/src/models/user.model.js"
click node_messagestore "https://github.com/iemafzalhassan/full-stack_chatapp/blob/main/backend/src/models/message.model.js"
click node_dbconnect "https://github.com/iemafzalhassan/full-stack_chatapp/blob/main/backend/src/lib/db.js"
click node_cloudinary "https://github.com/iemafzalhassan/full-stack_chatapp/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_signup,node_home,node_sidebar,node_chatview,node_chatheader,node_messageinput,node_profilepage,node_settingspage,node_authstate,node_chatstate,node_themestate,node_http,node_user toneBlue
class node_api,node_authroutes,node_messageroutes,node_authcontroller,node_messagecontroller,node_authmiddleware,node_mongodb,node_cloudservice toneAmber
class node_socket toneMint
class node_userstore,node_messagestore,node_dbconnect,node_cloudinary toneRose
```

## Components

### Web application

- [App routing](https://github.com/iemafzalhassan/full-stack_chatapp/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Login and signup](https://github.com/iemafzalhassan/full-stack_chatapp/blob/main/frontend/src/pages/LoginPage.jsx): `frontend/src/pages/LoginPage.jsx`
- [Signup page](https://github.com/iemafzalhassan/full-stack_chatapp/blob/main/frontend/src/pages/SignUpPage.jsx): `frontend/src/pages/SignUpPage.jsx`
- [Chat home](https://github.com/iemafzalhassan/full-stack_chatapp/blob/main/frontend/src/pages/HomePage.jsx): `frontend/src/pages/HomePage.jsx`
- [User sidebar](https://github.com/iemafzalhassan/full-stack_chatapp/blob/main/frontend/src/components/Sidebar.jsx): `frontend/src/components/Sidebar.jsx`
- [Conversation view](https://github.com/iemafzalhassan/full-stack_chatapp/blob/main/frontend/src/components/ChatContainer.jsx): `frontend/src/components/ChatContainer.jsx`
- [Chat header](https://github.com/iemafzalhassan/full-stack_chatapp/blob/main/frontend/src/components/ChatHeader.jsx): `frontend/src/components/ChatHeader.jsx`
- [Message composer](https://github.com/iemafzalhassan/full-stack_chatapp/blob/main/frontend/src/components/MessageInput.jsx): `frontend/src/components/MessageInput.jsx`
- [Profile page](https://github.com/iemafzalhassan/full-stack_chatapp/blob/main/frontend/src/pages/ProfilePage.jsx): `frontend/src/pages/ProfilePage.jsx`
- [Theme settings](https://github.com/iemafzalhassan/full-stack_chatapp/blob/main/frontend/src/pages/SettingsPage.jsx): `frontend/src/pages/SettingsPage.jsx`
- [Auth state](https://github.com/iemafzalhassan/full-stack_chatapp/blob/main/frontend/src/store/useAuthStore.js): `frontend/src/store/useAuthStore.js`
- [Chat state](https://github.com/iemafzalhassan/full-stack_chatapp/blob/main/frontend/src/store/useChatStore.js): `frontend/src/store/useChatStore.js`
- [Theme state](https://github.com/iemafzalhassan/full-stack_chatapp/blob/main/frontend/src/store/useThemeStore.js): `frontend/src/store/useThemeStore.js`
- [HTTP client](https://github.com/iemafzalhassan/full-stack_chatapp/blob/main/frontend/src/lib/axios.js): `frontend/src/lib/axios.js`

### Backend API

- [Express API](https://github.com/iemafzalhassan/full-stack_chatapp/blob/main/backend/src/index.js): `backend/src/index.js`
- [Auth routes](https://github.com/iemafzalhassan/full-stack_chatapp/blob/main/backend/src/routes/auth.route.js): `backend/src/routes/auth.route.js`
- [Message routes](https://github.com/iemafzalhassan/full-stack_chatapp/blob/main/backend/src/routes/message.route.js): `backend/src/routes/message.route.js`
- [Auth controller](https://github.com/iemafzalhassan/full-stack_chatapp/blob/main/backend/src/controllers/auth.controller.js): `backend/src/controllers/auth.controller.js`
- [Message controller](https://github.com/iemafzalhassan/full-stack_chatapp/blob/main/backend/src/controllers/message.controller.js): `backend/src/controllers/message.controller.js`
- [JWT protection](https://github.com/iemafzalhassan/full-stack_chatapp/blob/main/backend/src/middleware/auth.middleware.js): `backend/src/middleware/auth.middleware.js`

### Live messaging

- [Socket server](https://github.com/iemafzalhassan/full-stack_chatapp/blob/main/backend/src/lib/socket.js): `backend/src/lib/socket.js`

### Persistence and media

- [User model](https://github.com/iemafzalhassan/full-stack_chatapp/blob/main/backend/src/models/user.model.js): `backend/src/models/user.model.js`
- [Message model](https://github.com/iemafzalhassan/full-stack_chatapp/blob/main/backend/src/models/message.model.js): `backend/src/models/message.model.js`
- [Database connection](https://github.com/iemafzalhassan/full-stack_chatapp/blob/main/backend/src/lib/db.js): `backend/src/lib/db.js`
- [Image hosting](https://github.com/iemafzalhassan/full-stack_chatapp/blob/main/backend/src/lib/cloudinary.js): `backend/src/lib/cloudinary.js`

### Other components

- **Chat user**
- **MongoDB**
- **Cloudinary service**

## Connections

- Chat user → App routing: uses
- App routing → Login and signup: routes to (evidence: `frontend/src/App.jsx`)
- App routing → Signup page: routes to (evidence: `frontend/src/App.jsx`)
- App routing → Chat home: routes to (evidence: `frontend/src/App.jsx`)
- App routing → Profile page: routes to (evidence: `frontend/src/App.jsx`)
- App routing → Theme settings: routes to (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`)
- Login and signup → Auth state: submits credentials (evidence: `frontend/src/pages/LoginPage.jsx`)
- Signup page → Auth state: creates account (evidence: `frontend/src/pages/SignUpPage.jsx`)
- Profile page → Auth state: updates profile (evidence: `frontend/src/pages/ProfilePage.jsx`)
- Theme settings → Theme state: sets theme (evidence: `frontend/src/pages/SettingsPage.jsx`)
- Chat home → User sidebar: renders (evidence: `frontend/src/pages/HomePage.jsx`)
- Chat home → Conversation view: renders (evidence: `frontend/src/pages/HomePage.jsx`)
- Chat home → Chat state: reads selection (evidence: `frontend/src/pages/HomePage.jsx`)
- User sidebar → Chat state: selects user (evidence: `frontend/src/components/Sidebar.jsx`)
- Conversation view → Chat header: renders (evidence: `frontend/src/components/ChatContainer.jsx`)
- Conversation view → Message composer: renders (evidence: `frontend/src/components/ChatContainer.jsx`)
- Conversation view → Chat state: loads messages (evidence: `frontend/src/components/ChatContainer.jsx`)
- Message composer → Chat state: sends message (evidence: `frontend/src/components/MessageInput.jsx`)
- Auth state → HTTP client: calls API (evidence: `frontend/src/store/useAuthStore.js`)
- Chat state → HTTP client: calls API (evidence: `frontend/src/store/useChatStore.js`)
- Chat state → Auth state: uses socket (evidence: `frontend/src/store/useChatStore.js`)
- Auth state → Socket server: connects (evidence: `frontend/src/store/useAuthStore.js`)
- Chat user → Auth state: authenticates
- HTTP client → Express API: HTTP requests
- Express API → Auth routes: mounts routes (evidence: `backend/src/index.js`)
- Express API → Message routes: mounts routes (evidence: `backend/src/index.js`)
- Express API → Database connection: connects database (evidence: `backend/src/index.js`)
- Auth routes → Auth controller: dispatches (evidence: `backend/src/routes/auth.route.js`)
- Auth routes → JWT protection: protects routes (evidence: `backend/src/routes/auth.route.js`)
- Message routes → JWT protection: protects routes (evidence: `backend/src/routes/message.route.js`)
- Message routes → Message controller: dispatches (evidence: `backend/src/routes/message.route.js`)
- Auth controller → User model: reads and writes (evidence: `backend/src/controllers/auth.controller.js`)
- JWT protection → User model: loads user (evidence: `backend/src/middleware/auth.middleware.js`)
- Message controller → User model: lists users (evidence: `backend/src/controllers/message.controller.js`)
- Message controller → Message model: reads and writes (evidence: `backend/src/controllers/message.controller.js`)
- Message controller → Socket server: emits message (evidence: `backend/src/controllers/message.controller.js`)
- Socket server → Auth state: sends presence events
- Chat state → Socket server: receives messages (evidence: `frontend/src/store/useChatStore.js`)
- Auth controller → Image hosting: uploads profile image (evidence: `backend/src/controllers/auth.controller.js`)
- Message controller → Image hosting: uploads message image (evidence: `backend/src/controllers/message.controller.js`)
- Image hosting → Cloudinary service: stores images
- Database connection → MongoDB: connects
