# yashg504/connectify architecture

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

- Interactive diagram: https://gitdiagram.com/yashg504/connectify
- Repository: https://github.com/yashg504/connectify

## Overview

Connectify is a full-stack real-time messaging and calling app. Users authenticate and onboard, find friends or channels, exchange messages and media, and can use AI summaries/translations or start peer-to-peer calls. The frontend routes users to these experiences and accesses backend APIs; the backend applies route protection, persists application data, and emits live events. The README documents major capabilities, but several frontend and backend implementations were not sampled, so links to those areas are included only where documentation or indexed references support them.

Main entry points: [`frontend/src/App.jsx`](https://github.com/yashg504/connectify/blob/main/frontend/src/App.jsx) (App routing), [`backend/src/server.js`](https://github.com/yashg504/connectify/blob/main/backend/src/server.js) (HTTP application), [`backend/src/lib/socket.js`](https://github.com/yashg504/connectify/blob/main/backend/src/lib/socket.js) (Socket event hub), [`frontend/src/lib/api.js`](https://github.com/yashg504/connectify/blob/main/frontend/src/lib/api.js) (API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client experience"]
  node_app["App routing<br/>[App.jsx]"]
  node_authui["Auth and onboarding<br/>[LoginPage.jsx]"]
  node_chatui["Direct messaging<br/>[ChatPage.jsx]"]
  node_channelui["Channels<br/>[ChannelPage.jsx]"]
  node_callui["Calling<br/>[CallPage.jsx]"]
  node_aiclient["AI actions<br/>[useAI.js]"]
  node_theme["Theme and presence state<br/>[useThemeStore.js]"]
  node_api_client["API client<br/>[api.js]"]
end

subgraph group_api["Backend API"]
  node_server["HTTP application<br/>[server.js]"]
  node_auth_routes["Authentication routes<br/>[auth.route.js]"]
  node_chat_routes["Chat routes<br/>[chat.route.js]"]
  node_channel_routes["Channel routes<br/>[channel.route.js]"]
  node_user_routes["User routes<br/>[user.route.js]"]
  node_ai_routes["AI routes<br/>[ai.route.js]"]
  node_auth_controller["Authentication logic<br/>[auth.controller.js]"]
  node_chat_controller["Message handling<br/>[chat.controller.js]"]
  node_channel_controller["Channel handling"]
  node_user_controller["Friends and profiles<br/>[user.controller.js]"]
  node_ai_controller["AI processing<br/>[ai.controller.js]"]
  node_guards["Request protection<br/>[auth.middleware.js]"]
end

subgraph group_realtime["Live communication"]
  node_socket_client["Socket client<br/>[socket.js]"]
  node_socket_server["Socket event hub<br/>[socket.js]"]
end

subgraph group_data["Persistence and services"]
  node_models_user["User records<br/>[User.js]"]
  node_models_message["Message records<br/>[Message.js]"]
  node_models_channel["Channel records<br/>[Channel.js]"]
  node_friend_requests["Friend requests<br/>[FriendRequest.js]"]
  node_mongo[("MongoDB")]
  node_cloudinary["Cloudinary media<br/>[cloudinary.js]"]
end

node_person(("User"))
node_external_cloudinary["Cloudinary service"]
node_ai_service["AI provider"]

node_person -->|"uses"| node_app
node_app -->|"routes to"| node_authui
node_app -->|"routes to"| node_chatui
node_app -->|"routes to"| node_channelui
node_app -->|"routes to"| node_callui
node_app -->|"reads"| node_theme
node_app -->|"connects"| node_socket_client
node_authui -.->|"submits"| node_api_client
node_chatui -->|"requests"| node_api_client
node_channelui -->|"requests"| node_api_client
node_chatui -->|"listens"| node_socket_client
node_channelui -->|"listens"| node_socket_client
node_callui -->|"signals"| node_socket_client
node_aiclient -->|"invokes"| node_api_client
node_api_client -->|"calls API"| node_server
node_server -->|"mounts"| node_auth_routes
node_server -->|"mounts"| node_chat_routes
node_server -->|"mounts"| node_channel_routes
node_server -->|"mounts"| node_user_routes
node_server -->|"mounts"| node_ai_routes
node_auth_routes -->|"dispatches"| node_auth_controller
node_chat_routes -->|"dispatches"| node_chat_controller
node_user_routes -->|"dispatches"| node_user_controller
node_auth_routes -->|"protects"| node_guards
node_chat_routes -->|"protects"| node_guards
node_user_routes -->|"protects"| node_guards
node_auth_controller -->|"reads and writes"| node_models_user
node_auth_controller -.->|"persists tokens"| node_mongo
node_chat_controller -->|"reads and writes"| node_models_message
node_chat_controller -->|"emits events"| node_socket_server
node_chat_controller -->|"uploads media"| node_cloudinary
node_cloudinary -->|"uploads"| node_external_cloudinary
node_channel_controller -->|"reads and writes"| node_models_channel
node_channel_controller -->|"uses"| node_models_message
node_channel_controller -->|"emits events"| node_socket_server
node_user_controller -->|"reads and writes"| node_models_user
node_user_controller -->|"manages requests"| node_friend_requests
node_user_controller -->|"notifies users"| node_socket_server
node_guards -->|"loads identity"| node_models_user
node_ai_routes -.->|"dispatches"| node_ai_controller
node_ai_controller -->|"reads context"| node_models_message
node_ai_controller -.->|"requests AI"| node_ai_service
node_socket_client -->|"exchanges events"| node_socket_server
node_socket_server -->|"loads memberships"| node_models_channel
node_socket_server -->|"updates last seen"| node_models_user
node_models_user -->|"stored in"| node_mongo
node_models_message -->|"stored in"| node_mongo
node_models_channel -->|"stored in"| node_mongo

click node_app "https://github.com/yashg504/connectify/blob/main/frontend/src/App.jsx"
click node_authui "https://github.com/yashg504/connectify/blob/main/frontend/src/pages/LoginPage.jsx"
click node_chatui "https://github.com/yashg504/connectify/blob/main/frontend/src/pages/ChatPage.jsx"
click node_channelui "https://github.com/yashg504/connectify/blob/main/frontend/src/pages/ChannelPage.jsx"
click node_callui "https://github.com/yashg504/connectify/blob/main/frontend/src/pages/CallPage.jsx"
click node_aiclient "https://github.com/yashg504/connectify/blob/main/frontend/src/hooks/useAI.js"
click node_theme "https://github.com/yashg504/connectify/blob/main/frontend/src/store/useThemeStore.js"
click node_api_client "https://github.com/yashg504/connectify/blob/main/frontend/src/lib/api.js"
click node_socket_client "https://github.com/yashg504/connectify/blob/main/frontend/src/lib/socket.js"
click node_server "https://github.com/yashg504/connectify/blob/main/backend/src/server.js"
click node_auth_routes "https://github.com/yashg504/connectify/blob/main/backend/src/routes/auth.route.js"
click node_chat_routes "https://github.com/yashg504/connectify/blob/main/backend/src/routes/chat.route.js"
click node_channel_routes "https://github.com/yashg504/connectify/blob/main/backend/src/routes/channel.route.js"
click node_user_routes "https://github.com/yashg504/connectify/blob/main/backend/src/routes/user.route.js"
click node_ai_routes "https://github.com/yashg504/connectify/blob/main/backend/src/routes/ai.route.js"
click node_auth_controller "https://github.com/yashg504/connectify/blob/main/backend/src/controllers/auth.controller.js"
click node_chat_controller "https://github.com/yashg504/connectify/blob/main/backend/src/controllers/chat.controller.js"
click node_channel_controller "https://github.com/yashg504/connectify/blob/main/backend/src/controllers/channel.controller.js"
click node_user_controller "https://github.com/yashg504/connectify/blob/main/backend/src/controllers/user.controller.js"
click node_ai_controller "https://github.com/yashg504/connectify/blob/main/backend/src/controllers/ai.controller.js"
click node_guards "https://github.com/yashg504/connectify/blob/main/backend/src/middleware/auth.middleware.js"
click node_models_user "https://github.com/yashg504/connectify/blob/main/backend/src/models/User.js"
click node_models_message "https://github.com/yashg504/connectify/blob/main/backend/src/models/Message.js"
click node_models_channel "https://github.com/yashg504/connectify/blob/main/backend/src/models/Channel.js"
click node_friend_requests "https://github.com/yashg504/connectify/blob/main/backend/src/models/FriendRequest.js"
click node_socket_server "https://github.com/yashg504/connectify/blob/main/backend/src/lib/socket.js"
click node_cloudinary "https://github.com/yashg504/connectify/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_authui,node_chatui,node_channelui,node_callui,node_aiclient,node_theme,node_api_client,node_person toneBlue
class node_server,node_auth_routes,node_chat_routes,node_channel_routes,node_user_routes,node_ai_routes,node_auth_controller,node_chat_controller,node_channel_controller,node_user_controller,node_ai_controller,node_guards toneAmber
class node_socket_client,node_socket_server toneMint
class node_models_user,node_models_message,node_models_channel,node_friend_requests,node_mongo,node_cloudinary toneRose
class node_external_cloudinary,node_ai_service toneIndigo
```

## Components

### Client experience

- [App routing](https://github.com/yashg504/connectify/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Auth and onboarding](https://github.com/yashg504/connectify/blob/main/frontend/src/pages/LoginPage.jsx): `frontend/src/pages/LoginPage.jsx`
- [Direct messaging](https://github.com/yashg504/connectify/blob/main/frontend/src/pages/ChatPage.jsx): `frontend/src/pages/ChatPage.jsx`
- [Channels](https://github.com/yashg504/connectify/blob/main/frontend/src/pages/ChannelPage.jsx): `frontend/src/pages/ChannelPage.jsx`
- [Calling](https://github.com/yashg504/connectify/blob/main/frontend/src/pages/CallPage.jsx): `frontend/src/pages/CallPage.jsx`
- [AI actions](https://github.com/yashg504/connectify/blob/main/frontend/src/hooks/useAI.js): `frontend/src/hooks/useAI.js`
- [Theme and presence state](https://github.com/yashg504/connectify/blob/main/frontend/src/store/useThemeStore.js): `frontend/src/store/useThemeStore.js`
- [API client](https://github.com/yashg504/connectify/blob/main/frontend/src/lib/api.js): `frontend/src/lib/api.js`

### Backend API

- [HTTP application](https://github.com/yashg504/connectify/blob/main/backend/src/server.js): `backend/src/server.js`
- [Authentication routes](https://github.com/yashg504/connectify/blob/main/backend/src/routes/auth.route.js): `backend/src/routes/auth.route.js`
- [Chat routes](https://github.com/yashg504/connectify/blob/main/backend/src/routes/chat.route.js): `backend/src/routes/chat.route.js`
- [Channel routes](https://github.com/yashg504/connectify/blob/main/backend/src/routes/channel.route.js): `backend/src/routes/channel.route.js`
- [User routes](https://github.com/yashg504/connectify/blob/main/backend/src/routes/user.route.js): `backend/src/routes/user.route.js`
- [AI routes](https://github.com/yashg504/connectify/blob/main/backend/src/routes/ai.route.js): `backend/src/routes/ai.route.js`
- [Authentication logic](https://github.com/yashg504/connectify/blob/main/backend/src/controllers/auth.controller.js): `backend/src/controllers/auth.controller.js`
- [Message handling](https://github.com/yashg504/connectify/blob/main/backend/src/controllers/chat.controller.js): `backend/src/controllers/chat.controller.js`
- [Channel handling](https://github.com/yashg504/connectify/blob/main/backend/src/controllers/channel.controller.js): `backend/src/controllers/channel.controller.js`
- [Friends and profiles](https://github.com/yashg504/connectify/blob/main/backend/src/controllers/user.controller.js): `backend/src/controllers/user.controller.js`
- [AI processing](https://github.com/yashg504/connectify/blob/main/backend/src/controllers/ai.controller.js): `backend/src/controllers/ai.controller.js`
- [Request protection](https://github.com/yashg504/connectify/blob/main/backend/src/middleware/auth.middleware.js): `backend/src/middleware/auth.middleware.js`

### Live communication

- [Socket client](https://github.com/yashg504/connectify/blob/main/frontend/src/lib/socket.js): `frontend/src/lib/socket.js`
- [Socket event hub](https://github.com/yashg504/connectify/blob/main/backend/src/lib/socket.js): `backend/src/lib/socket.js`

### Persistence and services

- [User records](https://github.com/yashg504/connectify/blob/main/backend/src/models/User.js): `backend/src/models/User.js`
- [Message records](https://github.com/yashg504/connectify/blob/main/backend/src/models/Message.js): `backend/src/models/Message.js`
- [Channel records](https://github.com/yashg504/connectify/blob/main/backend/src/models/Channel.js): `backend/src/models/Channel.js`
- [Friend requests](https://github.com/yashg504/connectify/blob/main/backend/src/models/FriendRequest.js): `backend/src/models/FriendRequest.js`
- **MongoDB**
- [Cloudinary media](https://github.com/yashg504/connectify/blob/main/backend/src/lib/cloudinary.js): `backend/src/lib/cloudinary.js`

### Other components

- **User**
- **Cloudinary service**
- **AI provider**

## Connections

- User → App routing: uses
- App routing → Auth and onboarding: routes to (evidence: `frontend/src/App.jsx`)
- App routing → Direct messaging: routes to (evidence: `frontend/src/App.jsx`)
- App routing → Channels: routes to (evidence: `frontend/src/App.jsx`)
- App routing → Calling: routes to (evidence: `frontend/src/App.jsx`)
- App routing → Theme and presence state: reads (evidence: `frontend/src/App.jsx`)
- App routing → Socket client: connects (evidence: `frontend/src/App.jsx`)
- Auth and onboarding → API client: submits
- Direct messaging → API client: requests (evidence: `frontend/src/pages/ChatPage.jsx`)
- Channels → API client: requests (evidence: `frontend/src/pages/ChannelPage.jsx`)
- Direct messaging → Socket client: listens (evidence: `frontend/src/pages/ChatPage.jsx`)
- Channels → Socket client: listens (evidence: `frontend/src/pages/ChannelPage.jsx`)
- Calling → Socket client: signals (evidence: `frontend/src/pages/CallPage.jsx`)
- AI actions → API client: invokes (evidence: `frontend/src/hooks/useAI.js`)
- API client → HTTP application: calls API (evidence: `frontend/src/lib/api.js`)
- HTTP application → Authentication routes: mounts (evidence: `backend/src/server.js`)
- HTTP application → Chat routes: mounts (evidence: `backend/src/server.js`)
- HTTP application → Channel routes: mounts (evidence: `backend/src/server.js`)
- HTTP application → User routes: mounts (evidence: `backend/src/server.js`)
- HTTP application → AI routes: mounts (evidence: `backend/src/server.js`)
- Authentication routes → Authentication logic: dispatches (evidence: `backend/src/routes/auth.route.js`)
- Chat routes → Message handling: dispatches (evidence: `backend/src/routes/chat.route.js`)
- User routes → Friends and profiles: dispatches (evidence: `backend/src/routes/user.route.js`)
- Authentication routes → Request protection: protects (evidence: `backend/src/routes/auth.route.js`)
- Chat routes → Request protection: protects (evidence: `backend/src/routes/chat.route.js`)
- User routes → Request protection: protects (evidence: `backend/src/routes/user.route.js`)
- Authentication logic → User records: reads and writes (evidence: `backend/src/controllers/auth.controller.js`)
- Authentication logic → MongoDB: persists tokens
- Message handling → Message records: reads and writes (evidence: `backend/src/controllers/chat.controller.js`)
- Message handling → Socket event hub: emits events (evidence: `backend/src/controllers/chat.controller.js`)
- Message handling → Cloudinary media: uploads media (evidence: `backend/src/controllers/chat.controller.js`)
- Cloudinary media → Cloudinary service: uploads (evidence: `backend/src/lib/cloudinary.js`)
- Channel handling → Channel records: reads and writes (evidence: `backend/src/controllers/channel.controller.js`)
- Channel handling → Message records: uses (evidence: `backend/src/controllers/channel.controller.js`)
- Channel handling → Socket event hub: emits events (evidence: `backend/src/controllers/channel.controller.js`)
- Friends and profiles → User records: reads and writes (evidence: `backend/src/controllers/user.controller.js`)
- Friends and profiles → Friend requests: manages requests (evidence: `backend/src/controllers/user.controller.js`)
- Friends and profiles → Socket event hub: notifies users (evidence: `backend/src/controllers/user.controller.js`)
- Request protection → User records: loads identity (evidence: `backend/src/middleware/auth.middleware.js`)
- AI routes → AI processing: dispatches
- AI processing → Message records: reads context (evidence: `backend/src/controllers/ai.controller.js`)
- AI processing → AI provider: requests AI
- Socket client → Socket event hub: exchanges events
- Socket event hub → Channel records: loads memberships (evidence: `backend/src/lib/socket.js`)
- Socket event hub → User records: updates last seen (evidence: `backend/src/lib/socket.js`)
- User records → MongoDB: stored in
- Message records → MongoDB: stored in
- Channel records → MongoDB: stored in
