# abuzar4ick/chatify architecture

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

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

## Overview

This is a full-stack chat application: users sign up or log in, then browse contacts and prior conversations, exchange text or image messages, and see online presence and incoming messages in real time. The React pages and Zustand stores drive an Express API backed by MongoDB; authenticated Socket.io connections handle presence and message delivery. Signup also triggers a welcome email, while profile and message images use Cloudinary. Some UI components and integrations are documented or indexed but not excerpted, so uncertain links are omitted.

Main entry points: [`backend/src/controllers/auth.controller.js`](https://github.com/abuzar4ick/chatify/blob/main/backend/src/controllers/auth.controller.js) (Auth operations), [`backend/src/controllers/message.controller.js`](https://github.com/abuzar4ick/chatify/blob/main/backend/src/controllers/message.controller.js) (Messaging operations), [`backend/src/routes/auth.route.js`](https://github.com/abuzar4ick/chatify/blob/main/backend/src/routes/auth.route.js) (Auth routes), [`backend/src/routes/message.route.js`](https://github.com/abuzar4ick/chatify/blob/main/backend/src/routes/message.route.js) (Message routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Chat interface"]
  node_app["App routing<br/>[App.jsx]"]
  node_authpages["Login and signup<br/>[LoginPage.jsx]"]
  node_chatpage["Chat page<br/>[ChatPage.jsx]"]
  node_chatui["Conversation UI<br/>[ChatContainer.jsx]"]
  node_profileui["Profile controls<br/>[ProfileHeader.jsx]"]
  node_messageinput["Message composer<br/>[MessageInput.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["API and domain"]
  node_authroutes["Auth routes<br/>[auth.route.js]"]
  node_message_routes["Message routes<br/>[message.route.js]"]
  node_authcontroller["Auth operations<br/>[auth.controller.js]"]
  node_messagecontroller["Messaging operations"]
  node_authmiddleware["JWT protection<br/>[auth.middleware.js]"]
  node_ratelimit["API rate limiting"]
  node_server["HTTP server setup<br/>[server.js]"]
  node_authutils["JWT token helper<br/>[utils.js]"]
end

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

subgraph group_integrations["Persistence and services"]
  node_user_model["User records<br/>[User.js]"]
  node_message_model["Message records<br/>[Message.js]"]
  node_database[("MongoDB")]
  node_cloudinary["Image hosting<br/>[cloudinary.js]"]
  node_emailhandler["Welcome email<br/>[emailHandlers.js]"]
  node_emailtemplate["Email template<br/>[emailTemplates.js]"]
end

node_user(("Chat user"))
node_cloudinary_service["Cloudinary"]
node_resend["Resend email service"]

node_user -->|"opens"| node_app
node_app -->|"routes to"| node_authpages
node_app -->|"routes to"| node_chatpage
node_authpages -->|"submits auth"| node_authstore
node_chatpage -->|"loads chat"| node_chatstore
node_chatpage -->|"renders"| node_chatui
node_chatpage -->|"renders"| node_profileui
node_chatui -->|"renders"| node_messageinput
node_messageinput -->|"sends message"| node_chatstore
node_authstore -->|"requests"| node_httpclient
node_chatstore -->|"requests"| node_httpclient
node_authstore -->|"connects"| node_socketserver
node_httpclient -->|"calls auth API"| node_authroutes
node_httpclient -->|"calls message API"| node_message_routes
node_server -->|"mounts"| node_authroutes
node_server -->|"mounts"| node_message_routes
node_authroutes -->|"dispatches"| node_authcontroller
node_message_routes -->|"dispatches"| node_messagecontroller
node_authroutes -->|"applies"| node_ratelimit
node_message_routes -->|"applies"| node_ratelimit
node_authroutes -->|"protects routes"| node_authmiddleware
node_message_routes -->|"protects routes"| node_authmiddleware
node_authcontroller -->|"reads and writes"| node_user_model
node_authcontroller -->|"generates token"| node_authutils
node_authcontroller -->|"sends welcome"| node_emailhandler
node_authcontroller -->|"uploads profile image"| node_cloudinary
node_messagecontroller -->|"looks up users"| node_user_model
node_messagecontroller -->|"reads and writes"| node_message_model
node_messagecontroller -->|"uploads image"| node_cloudinary
node_messagecontroller -->|"dispatches message"| node_socketserver
node_authmiddleware -->|"loads user"| node_user_model
node_socketauth -->|"loads user"| node_user_model
node_socketserver -->|"authenticates sockets"| node_socketauth
node_server -->|"uses server"| node_socketserver
node_emailhandler -->|"renders"| node_emailtemplate
node_emailhandler -->|"sends email"| node_resend
node_cloudinary -.->|"uploads to"| node_cloudinary_service
node_user_model -.->|"persists in"| node_database
node_message_model -.->|"persists in"| node_database

click node_app "https://github.com/abuzar4ick/chatify/blob/main/frontend/src/App.jsx"
click node_authpages "https://github.com/abuzar4ick/chatify/blob/main/frontend/src/pages/LoginPage.jsx"
click node_chatpage "https://github.com/abuzar4ick/chatify/blob/main/frontend/src/pages/ChatPage.jsx"
click node_chatui "https://github.com/abuzar4ick/chatify/blob/main/frontend/src/components/ChatContainer.jsx"
click node_profileui "https://github.com/abuzar4ick/chatify/blob/main/frontend/src/components/ProfileHeader.jsx"
click node_messageinput "https://github.com/abuzar4ick/chatify/blob/main/frontend/src/components/MessageInput.jsx"
click node_authstore "https://github.com/abuzar4ick/chatify/blob/main/frontend/src/store/useAuthStore.js"
click node_chatstore "https://github.com/abuzar4ick/chatify/blob/main/frontend/src/store/useChatStore.js"
click node_httpclient "https://github.com/abuzar4ick/chatify/blob/main/frontend/src/lib/axios.js"
click node_authroutes "https://github.com/abuzar4ick/chatify/blob/main/backend/src/routes/auth.route.js"
click node_message_routes "https://github.com/abuzar4ick/chatify/blob/main/backend/src/routes/message.route.js"
click node_authcontroller "https://github.com/abuzar4ick/chatify/blob/main/backend/src/controllers/auth.controller.js"
click node_messagecontroller "https://github.com/abuzar4ick/chatify/blob/main/backend/src/controllers/message.controller.js"
click node_authmiddleware "https://github.com/abuzar4ick/chatify/blob/main/backend/src/middleware/auth.middleware.js"
click node_ratelimit "https://github.com/abuzar4ick/chatify/blob/main/backend/src/middleware/arcjet.middleware.js"
click node_user_model "https://github.com/abuzar4ick/chatify/blob/main/backend/src/models/User.js"
click node_message_model "https://github.com/abuzar4ick/chatify/blob/main/backend/src/models/Message.js"
click node_socketserver "https://github.com/abuzar4ick/chatify/blob/main/backend/src/lib/socket.js"
click node_socketauth "https://github.com/abuzar4ick/chatify/blob/main/backend/src/middleware/socket.auth.middleware.js"
click node_cloudinary "https://github.com/abuzar4ick/chatify/blob/main/backend/src/lib/cloudinary.js"
click node_emailhandler "https://github.com/abuzar4ick/chatify/blob/main/backend/src/emails/emailHandlers.js"
click node_emailtemplate "https://github.com/abuzar4ick/chatify/blob/main/backend/src/emails/emailTemplates.js"
click node_server "https://github.com/abuzar4ick/chatify/blob/main/backend/src/server.js"
click node_authutils "https://github.com/abuzar4ick/chatify/blob/main/backend/src/lib/utils.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_profileui,node_messageinput,node_authstore,node_chatstore,node_httpclient,node_user toneBlue
class node_authroutes,node_message_routes,node_authcontroller,node_messagecontroller,node_authmiddleware,node_ratelimit,node_server,node_authutils toneAmber
class node_socketserver,node_socketauth toneMint
class node_user_model,node_message_model,node_database,node_cloudinary,node_emailhandler,node_emailtemplate toneRose
class node_cloudinary_service,node_resend toneIndigo
```

## Components

### Chat interface

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

### API and domain

- [Auth routes](https://github.com/abuzar4ick/chatify/blob/main/backend/src/routes/auth.route.js): `backend/src/routes/auth.route.js`
- [Message routes](https://github.com/abuzar4ick/chatify/blob/main/backend/src/routes/message.route.js): `backend/src/routes/message.route.js`
- [Auth operations](https://github.com/abuzar4ick/chatify/blob/main/backend/src/controllers/auth.controller.js): `backend/src/controllers/auth.controller.js`
- [Messaging operations](https://github.com/abuzar4ick/chatify/blob/main/backend/src/controllers/message.controller.js): `backend/src/controllers/message.controller.js`
- [JWT protection](https://github.com/abuzar4ick/chatify/blob/main/backend/src/middleware/auth.middleware.js): `backend/src/middleware/auth.middleware.js`
- [API rate limiting](https://github.com/abuzar4ick/chatify/blob/main/backend/src/middleware/arcjet.middleware.js): `backend/src/middleware/arcjet.middleware.js`
- [HTTP server setup](https://github.com/abuzar4ick/chatify/blob/main/backend/src/server.js): `backend/src/server.js`
- [JWT token helper](https://github.com/abuzar4ick/chatify/blob/main/backend/src/lib/utils.js): `backend/src/lib/utils.js`

### Realtime presence

- [Socket server](https://github.com/abuzar4ick/chatify/blob/main/backend/src/lib/socket.js): `backend/src/lib/socket.js`
- [Socket authentication](https://github.com/abuzar4ick/chatify/blob/main/backend/src/middleware/socket.auth.middleware.js): `backend/src/middleware/socket.auth.middleware.js`

### Persistence and services

- [User records](https://github.com/abuzar4ick/chatify/blob/main/backend/src/models/User.js): `backend/src/models/User.js`
- [Message records](https://github.com/abuzar4ick/chatify/blob/main/backend/src/models/Message.js): `backend/src/models/Message.js`
- **MongoDB**
- [Image hosting](https://github.com/abuzar4ick/chatify/blob/main/backend/src/lib/cloudinary.js): `backend/src/lib/cloudinary.js`
- [Welcome email](https://github.com/abuzar4ick/chatify/blob/main/backend/src/emails/emailHandlers.js): `backend/src/emails/emailHandlers.js`
- [Email template](https://github.com/abuzar4ick/chatify/blob/main/backend/src/emails/emailTemplates.js): `backend/src/emails/emailTemplates.js`

### Other components

- **Chat user**
- **Cloudinary**
- **Resend email service**

## Connections

- Chat user → App routing: opens (evidence: `frontend/src/App.jsx`)
- App routing → Login and signup: routes to (evidence: `frontend/src/App.jsx`)
- App routing → Chat page: routes to (evidence: `frontend/src/App.jsx`)
- Login and signup → Auth state: submits auth (evidence: `frontend/src/pages/LoginPage.jsx`)
- Chat page → Chat state: loads chat (evidence: `frontend/src/pages/ChatPage.jsx`)
- Chat page → Conversation UI: renders (evidence: `frontend/src/pages/ChatPage.jsx`)
- Chat page → Profile controls: renders (evidence: `frontend/src/pages/ChatPage.jsx`)
- Conversation UI → Message composer: renders (evidence: `frontend/src/components/ChatContainer.jsx`)
- Message composer → Chat state: sends message (evidence: `frontend/src/components/MessageInput.jsx`)
- Auth state → HTTP client: requests (evidence: `frontend/src/store/useAuthStore.js`)
- Chat state → HTTP client: requests (evidence: `frontend/src/store/useChatStore.js`)
- Auth state → Socket server: connects (evidence: `frontend/src/store/useAuthStore.js`)
- HTTP client → Auth routes: calls auth API
- HTTP client → Message routes: calls message API
- HTTP server setup → Auth routes: mounts (evidence: `backend/src/server.js`)
- HTTP server setup → Message routes: mounts (evidence: `backend/src/server.js`)
- Auth routes → Auth operations: dispatches (evidence: `backend/src/routes/auth.route.js`)
- Message routes → Messaging operations: dispatches (evidence: `backend/src/routes/message.route.js`)
- Auth routes → API rate limiting: applies (evidence: `backend/src/routes/auth.route.js`)
- Message routes → API rate limiting: applies (evidence: `backend/src/routes/message.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`)
- Auth operations → User records: reads and writes (evidence: `backend/src/controllers/auth.controller.js`)
- Auth operations → JWT token helper: generates token (evidence: `backend/src/controllers/auth.controller.js`)
- Auth operations → Welcome email: sends welcome (evidence: `backend/src/controllers/auth.controller.js`)
- Auth operations → Image hosting: uploads profile image (evidence: `backend/src/controllers/auth.controller.js`)
- Messaging operations → User records: looks up users (evidence: `backend/src/controllers/message.controller.js`)
- Messaging operations → Message records: reads and writes (evidence: `backend/src/controllers/message.controller.js`)
- Messaging operations → Image hosting: uploads image (evidence: `backend/src/controllers/message.controller.js`)
- Messaging operations → Socket server: dispatches message (evidence: `backend/src/controllers/message.controller.js`)
- JWT protection → User records: loads user (evidence: `backend/src/middleware/auth.middleware.js`)
- Socket authentication → User records: loads user (evidence: `backend/src/middleware/socket.auth.middleware.js`)
- Socket server → Socket authentication: authenticates sockets (evidence: `backend/src/lib/socket.js`)
- HTTP server setup → Socket server: uses server (evidence: `backend/src/server.js`)
- Welcome email → Email template: renders (evidence: `backend/src/emails/emailHandlers.js`)
- Welcome email → Resend email service: sends email (evidence: `backend/src/emails/emailHandlers.js`)
- Image hosting → Cloudinary: uploads to
- User records → MongoDB: persists in
- Message records → MongoDB: persists in
