# priyanshuk17/chatify architecture

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

- Interactive diagram: https://gitdiagram.com/priyanshuk17/chatify
- Repository: https://github.com/priyanshuk17/chatify

## Overview

Chatify is a full-stack real-time messaging application. The main workflow is account creation or login, authenticated chat selection, message retrieval and sending, persistence, and delivery to a recipient over Socket.io; the client also tracks online presence. Profile-image uploads, welcome email, and request shielding are supporting capabilities. The graph combines inspected source relationships with documented README relationships; unsampled feature links are omitted where their callers are not evidenced.

Main entry points: [`backend/src/server.js`](https://github.com/priyanshuk17/chatify/blob/main/backend/src/server.js) (Express server), [`backend/src/controllers/message.controller.js`](https://github.com/priyanshuk17/chatify/blob/main/backend/src/controllers/message.controller.js) (Message workflows), [`frontend/src/store/useAuthStore.js`](https://github.com/priyanshuk17/chatify/blob/main/frontend/src/store/useAuthStore.js) (Auth state), [`backend/src/lib/socket.js`](https://github.com/priyanshuk17/chatify/blob/main/backend/src/lib/socket.js) (Socket and presence)

## 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_chatuikit["Chat components<br/>[ChatContainer.jsx]"]
  node_profileui["Profile controls<br/>[ProfileHeader.jsx]"]
  node_authstore["Auth state<br/>[useAuthStore.js]"]
  node_chatstore["Chat state<br/>[useChatStore.js]"]
  node_httpclient["HTTP client<br/>[axios.js]"]
end

subgraph group_api["Backend API"]
  node_api["Express server<br/>[server.js]"]
  node_authroutes["Auth routes<br/>[auth.route.js]"]
  node_messageroutes["Message routes<br/>[message.route.js]"]
  node_authcontroller["Auth workflows<br/>[auth.controller.js]"]
  node_messagecontroller["Message workflows"]
  node_authguard["HTTP auth guard<br/>[auth.middleware.js]"]
  node_shield["Request protection"]
end

subgraph group_realtime["Identity and messaging"]
  node_userstore[("User records<br/>[User.js]")]
  node_messagestore[("Message records<br/>[Message.js]")]
  node_socketserver["Socket and presence<br/>[socket.js]"]
  node_socketauth["Socket auth"]
  node_database["MongoDB connection<br/>[db.js]"]
end

subgraph group_integrations["External integrations"]
  node_media["Media uploads<br/>[cloudinary.js]"]
  node_email["Welcome email<br/>[emailHandlers.js]"]
  node_emailservice["Resend<br/>[resend.js]"]
  node_arcjet["Arcjet service<br/>[arcjet.js]"]
end

node_user(("User"))
node_mongodb[("MongoDB Atlas")]
node_cloudinary["Cloudinary"]
node_resend["Resend email"]
node_arcjetservice["Arcjet protection"]

node_user -->|"uses"| node_app
node_app -->|"checks session"| node_authstore
node_authpages -->|"submits credentials"| node_authstore
node_chatpage -->|"loads chat state"| node_chatstore
node_chatpage -->|"renders"| node_chatuikit
node_chatuikit -->|"reads and updates"| node_chatstore
node_profileui -->|"updates profile"| node_authstore
node_authstore -->|"calls API"| node_httpclient
node_chatstore -->|"calls API"| node_httpclient
node_authstore -->|"opens WebSocket"| node_socketserver
node_chatstore -->|"receives messages"| node_socketserver
node_httpclient -->|"sends REST requests"| node_api
node_api -->|"mounts routes"| node_authroutes
node_api -->|"mounts routes"| node_messageroutes
node_api -->|"connects database"| node_database
node_api -->|"uses server"| node_socketserver
node_authroutes -->|"dispatches"| node_authcontroller
node_authroutes -->|"protects routes"| node_authguard
node_authroutes -->|"shields requests"| node_shield
node_messageroutes -->|"dispatches"| node_messagecontroller
node_messageroutes -->|"protects routes"| node_authguard
node_messageroutes -->|"shields requests"| node_shield
node_authcontroller -->|"reads and writes"| node_userstore
node_authcontroller -->|"uploads profile image"| node_media
node_authcontroller -->|"sends welcome email"| node_email
node_messagecontroller -->|"looks up users"| node_userstore
node_messagecontroller -->|"reads and saves"| node_messagestore
node_messagecontroller -->|"uploads message image"| node_media
node_messagecontroller -->|"relays message"| node_socketserver
node_authguard -->|"loads user"| node_userstore
node_socketserver -->|"authenticates connection"| node_socketauth
node_socketauth -->|"verifies user"| node_userstore
node_database -->|"connects"| node_mongodb
node_media -->|"uploads media"| node_cloudinary
node_email -->|"uses client"| node_emailservice
node_emailservice -->|"delivers email"| node_resend
node_shield -->|"applies protection"| node_arcjet
node_arcjet -->|"checks requests"| node_arcjetservice

click node_app "https://github.com/priyanshuk17/chatify/blob/main/frontend/src/App.jsx"
click node_authpages "https://github.com/priyanshuk17/chatify/blob/main/frontend/src/pages/LoginPage.jsx"
click node_chatpage "https://github.com/priyanshuk17/chatify/blob/main/frontend/src/pages/ChatPage.jsx"
click node_chatuikit "https://github.com/priyanshuk17/chatify/blob/main/frontend/src/components/ChatContainer.jsx"
click node_profileui "https://github.com/priyanshuk17/chatify/blob/main/frontend/src/components/ProfileHeader.jsx"
click node_authstore "https://github.com/priyanshuk17/chatify/blob/main/frontend/src/store/useAuthStore.js"
click node_chatstore "https://github.com/priyanshuk17/chatify/blob/main/frontend/src/store/useChatStore.js"
click node_httpclient "https://github.com/priyanshuk17/chatify/blob/main/frontend/src/lib/axios.js"
click node_api "https://github.com/priyanshuk17/chatify/blob/main/backend/src/server.js"
click node_authroutes "https://github.com/priyanshuk17/chatify/blob/main/backend/src/routes/auth.route.js"
click node_messageroutes "https://github.com/priyanshuk17/chatify/blob/main/backend/src/routes/message.route.js"
click node_authcontroller "https://github.com/priyanshuk17/chatify/blob/main/backend/src/controllers/auth.controller.js"
click node_messagecontroller "https://github.com/priyanshuk17/chatify/blob/main/backend/src/controllers/message.controller.js"
click node_authguard "https://github.com/priyanshuk17/chatify/blob/main/backend/src/middleware/auth.middleware.js"
click node_shield "https://github.com/priyanshuk17/chatify/blob/main/backend/src/middleware/arcjet.middleware.js"
click node_userstore "https://github.com/priyanshuk17/chatify/blob/main/backend/src/models/User.js"
click node_messagestore "https://github.com/priyanshuk17/chatify/blob/main/backend/src/models/Message.js"
click node_socketserver "https://github.com/priyanshuk17/chatify/blob/main/backend/src/lib/socket.js"
click node_socketauth "https://github.com/priyanshuk17/chatify/blob/main/backend/src/middleware/socket.auth.middleware.js"
click node_database "https://github.com/priyanshuk17/chatify/blob/main/backend/src/lib/db.js"
click node_media "https://github.com/priyanshuk17/chatify/blob/main/backend/src/lib/cloudinary.js"
click node_email "https://github.com/priyanshuk17/chatify/blob/main/backend/src/emails/emailHandlers.js"
click node_emailservice "https://github.com/priyanshuk17/chatify/blob/main/backend/src/lib/resend.js"
click node_arcjet "https://github.com/priyanshuk17/chatify/blob/main/backend/src/lib/arcjet.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_chatuikit,node_profileui,node_authstore,node_chatstore,node_httpclient,node_user toneBlue
class node_api,node_authroutes,node_messageroutes,node_authcontroller,node_messagecontroller,node_authguard,node_shield,node_mongodb toneAmber
class node_userstore,node_messagestore,node_socketserver,node_socketauth,node_database toneMint
class node_media,node_email,node_emailservice,node_arcjet toneRose
class node_cloudinary,node_resend,node_arcjetservice toneIndigo
```

## Components

### Web client

- [App routing](https://github.com/priyanshuk17/chatify/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Login and signup](https://github.com/priyanshuk17/chatify/blob/main/frontend/src/pages/LoginPage.jsx): `frontend/src/pages/LoginPage.jsx`
- [Chat workspace](https://github.com/priyanshuk17/chatify/blob/main/frontend/src/pages/ChatPage.jsx): `frontend/src/pages/ChatPage.jsx`
- [Chat components](https://github.com/priyanshuk17/chatify/blob/main/frontend/src/components/ChatContainer.jsx): `frontend/src/components/ChatContainer.jsx`
- [Profile controls](https://github.com/priyanshuk17/chatify/blob/main/frontend/src/components/ProfileHeader.jsx): `frontend/src/components/ProfileHeader.jsx`
- [Auth state](https://github.com/priyanshuk17/chatify/blob/main/frontend/src/store/useAuthStore.js): `frontend/src/store/useAuthStore.js`
- [Chat state](https://github.com/priyanshuk17/chatify/blob/main/frontend/src/store/useChatStore.js): `frontend/src/store/useChatStore.js`
- [HTTP client](https://github.com/priyanshuk17/chatify/blob/main/frontend/src/lib/axios.js): `frontend/src/lib/axios.js`

### Backend API

- [Express server](https://github.com/priyanshuk17/chatify/blob/main/backend/src/server.js): `backend/src/server.js`
- [Auth routes](https://github.com/priyanshuk17/chatify/blob/main/backend/src/routes/auth.route.js): `backend/src/routes/auth.route.js`
- [Message routes](https://github.com/priyanshuk17/chatify/blob/main/backend/src/routes/message.route.js): `backend/src/routes/message.route.js`
- [Auth workflows](https://github.com/priyanshuk17/chatify/blob/main/backend/src/controllers/auth.controller.js): `backend/src/controllers/auth.controller.js`
- [Message workflows](https://github.com/priyanshuk17/chatify/blob/main/backend/src/controllers/message.controller.js): `backend/src/controllers/message.controller.js`
- [HTTP auth guard](https://github.com/priyanshuk17/chatify/blob/main/backend/src/middleware/auth.middleware.js): `backend/src/middleware/auth.middleware.js`
- [Request protection](https://github.com/priyanshuk17/chatify/blob/main/backend/src/middleware/arcjet.middleware.js): `backend/src/middleware/arcjet.middleware.js`

### Identity and messaging

- [User records](https://github.com/priyanshuk17/chatify/blob/main/backend/src/models/User.js): `backend/src/models/User.js`
- [Message records](https://github.com/priyanshuk17/chatify/blob/main/backend/src/models/Message.js): `backend/src/models/Message.js`
- [Socket and presence](https://github.com/priyanshuk17/chatify/blob/main/backend/src/lib/socket.js): `backend/src/lib/socket.js`
- [Socket auth](https://github.com/priyanshuk17/chatify/blob/main/backend/src/middleware/socket.auth.middleware.js): `backend/src/middleware/socket.auth.middleware.js`
- [MongoDB connection](https://github.com/priyanshuk17/chatify/blob/main/backend/src/lib/db.js): `backend/src/lib/db.js`

### External integrations

- [Media uploads](https://github.com/priyanshuk17/chatify/blob/main/backend/src/lib/cloudinary.js): `backend/src/lib/cloudinary.js`
- [Welcome email](https://github.com/priyanshuk17/chatify/blob/main/backend/src/emails/emailHandlers.js): `backend/src/emails/emailHandlers.js`
- [Resend](https://github.com/priyanshuk17/chatify/blob/main/backend/src/lib/resend.js): `backend/src/lib/resend.js`
- [Arcjet service](https://github.com/priyanshuk17/chatify/blob/main/backend/src/lib/arcjet.js): `backend/src/lib/arcjet.js`

### Other components

- **User**
- **MongoDB Atlas**
- **Cloudinary**
- **Resend email**
- **Arcjet protection**

## Connections

- User → App routing: uses (evidence: `README.md`)
- App routing → Auth state: checks session (evidence: `frontend/src/App.jsx`)
- Login and signup → Auth state: submits credentials (evidence: `frontend/src/pages/LoginPage.jsx`)
- Chat workspace → Chat state: loads chat state (evidence: `frontend/src/pages/ChatPage.jsx`)
- Chat workspace → Chat components: renders (evidence: `frontend/src/pages/ChatPage.jsx`)
- Chat components → Chat state: reads and updates (evidence: `frontend/src/components/ChatContainer.jsx`)
- Profile controls → Auth state: updates profile (evidence: `frontend/src/components/ProfileHeader.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`)
- Auth state → Socket and presence: opens WebSocket (evidence: `README.md`)
- Chat state → Socket and presence: receives messages (evidence: `frontend/src/store/useChatStore.js`)
- HTTP client → Express server: sends REST requests (evidence: `README.md`)
- Express server → Auth routes: mounts routes (evidence: `backend/src/server.js`)
- Express server → Message routes: mounts routes (evidence: `backend/src/server.js`)
- Express server → MongoDB connection: connects database (evidence: `backend/src/server.js`)
- Express server → Socket and presence: uses server (evidence: `backend/src/server.js`)
- Auth routes → Auth workflows: dispatches (evidence: `backend/src/routes/auth.route.js`)
- Auth routes → HTTP auth guard: protects routes (evidence: `backend/src/routes/auth.route.js`)
- Auth routes → Request protection: shields requests (evidence: `backend/src/routes/auth.route.js`)
- Message routes → Message workflows: dispatches (evidence: `backend/src/routes/message.route.js`)
- Message routes → HTTP auth guard: protects routes (evidence: `backend/src/routes/message.route.js`)
- Message routes → Request protection: shields requests (evidence: `backend/src/routes/message.route.js`)
- Auth workflows → User records: reads and writes (evidence: `backend/src/controllers/auth.controller.js`)
- Auth workflows → Media uploads: uploads profile image (evidence: `backend/src/controllers/auth.controller.js`)
- Auth workflows → Welcome email: sends welcome email (evidence: `backend/src/controllers/auth.controller.js`)
- Message workflows → User records: looks up users (evidence: `backend/src/controllers/message.controller.js`)
- Message workflows → Message records: reads and saves (evidence: `backend/src/controllers/message.controller.js`)
- Message workflows → Media uploads: uploads message image (evidence: `backend/src/controllers/message.controller.js`)
- Message workflows → Socket and presence: relays message (evidence: `backend/src/controllers/message.controller.js`)
- HTTP auth guard → User records: loads user (evidence: `backend/src/middleware/auth.middleware.js`)
- Socket and presence → Socket auth: authenticates connection (evidence: `backend/src/lib/socket.js`)
- Socket auth → User records: verifies user (evidence: `backend/src/middleware/socket.auth.middleware.js`)
- MongoDB connection → MongoDB Atlas: connects (evidence: `README.md`)
- Media uploads → Cloudinary: uploads media (evidence: `README.md`)
- Welcome email → Resend: uses client (evidence: `backend/src/emails/emailHandlers.js`)
- Resend → Resend email: delivers email (evidence: `README.md`)
- Request protection → Arcjet service: applies protection (evidence: `backend/src/middleware/arcjet.middleware.js`)
- Arcjet service → Arcjet protection: checks requests (evidence: `README.md`)
