# rohansantra/connecto architecture

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

- Interactive diagram: https://gitdiagram.com/rohansantra/connecto
- Repository: https://github.com/rohansantra/connecto

## Overview

Connecto is a real-time messaging and calling application with account onboarding, profiles, group and direct chats, encrypted messages, media, device management, blocking, and administration. Users authenticate, complete profile setup, then use the protected chat interface for conversations and calls; the frontend stores coordinate API and socket interactions. The backend routes requests to domain controllers and persists data in MongoDB models, while sockets support live events and signaling. The README is empty; connections involving unsampled modules are omitted unless visible in the source index.

Main entry points: [`backend/src/models`](https://github.com/rohansantra/connecto/tree/main/backend/src/models) (MongoDB domain models), [`backend/src/app.js`](https://github.com/rohansantra/connecto/blob/main/backend/src/app.js) (HTTP app and routes), [`backend/src/socket/index.js`](https://github.com/rohansantra/connecto/blob/main/backend/src/socket/index.js) (Socket events), [`frontend/src/store/useAuthStore.js`](https://github.com/rohansantra/connecto/blob/main/frontend/src/store/useAuthStore.js) (Auth state)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_app["Route and shell<br/>[App.jsx]"]
  node_auth_ui["Sign-in and OTP"]
  node_auth_store["Auth state<br/>[useAuthStore.js]"]
  node_chat_ui["Chat workspace"]
  node_chat_store["Chat state<br/>[useChatStore.js]"]
  node_message_store["Message state<br/>[useMessageStore.js]"]
  node_profile_store["Profile state<br/>[useProfileStore.js]"]
  node_calls_ui["Call interface"]
  node_webrtc["WebRTC handling<br/>[useWebRTC.js]"]
end

subgraph group_backend["API backend"]
  node_api_app["HTTP app and routes<br/>[app.js]"]
  node_auth_controller["Authentication<br/>[auth.controller.js]"]
  node_chat_controller["Chat management<br/>[chat.controller.js]"]
  node_message_controller["Message handling"]
  node_profile_controller["Profile management"]
  node_cloudinary["Media storage adapter<br/>[cloudinary.js]"]
  node_block_utils["Block checks<br/>[block.utils.js]"]
end

subgraph group_realtime["Realtime and calls"]
  node_socket["Socket events<br/>[index.js]"]
  node_call_service["Call services<br/>[call.service.js]"]
end

subgraph group_persistence["Domain storage"]
  node_models[("MongoDB domain models")]
end

subgraph group_admin["Administration"]
  node_admin_ui["Admin analytics UI"]
  node_admin_controller["Admin reporting"]
end

node_user(("User"))
node_database[("MongoDB")]
node_cloudinary_service["Cloudinary"]

node_user -->|"opens"| node_app
node_app -->|"routes to"| node_auth_ui
node_app -->|"renders"| node_calls_ui
node_auth_ui -.->|"submits to"| node_auth_store
node_auth_store -.->|"requests auth"| node_api_app
node_auth_store -->|"starts socket"| node_socket
node_auth_store -->|"coordinates"| node_chat_store
node_auth_store -->|"coordinates"| node_message_store
node_auth_store -->|"coordinates"| node_profile_store
node_chat_ui -.->|"uses state"| node_chat_store
node_chat_store -->|"coordinates"| node_message_store
node_chat_store -->|"uses state"| node_profile_store
node_message_store -->|"uses state"| node_chat_store
node_message_store -->|"uses state"| node_profile_store
node_calls_ui -.->|"uses"| node_webrtc
node_webrtc -.->|"signals through"| node_socket
node_api_app -->|"routes auth"| node_auth_controller
node_api_app -->|"routes chats"| node_chat_controller
node_api_app -->|"routes messages"| node_message_controller
node_api_app -->|"routes profiles"| node_profile_controller
node_api_app -->|"routes admin"| node_admin_controller
node_chat_controller -->|"reads and writes"| node_models
node_message_controller -->|"reads and writes"| node_models
node_profile_controller -->|"reads and writes"| node_models
node_auth_controller -->|"reads and writes"| node_models
node_admin_controller -->|"aggregates"| node_models
node_models -.->|"persists"| node_database
node_chat_controller -->|"emits events"| node_socket
node_message_controller -->|"emits events"| node_socket
node_message_controller -->|"uploads media"| node_cloudinary
node_chat_controller -->|"uploads avatars"| node_cloudinary
node_cloudinary -.->|"stores files"| node_cloudinary_service
node_message_controller -->|"checks blocking"| node_block_utils
node_socket -->|"checks blocking"| node_block_utils
node_socket -->|"reads and updates"| node_models
node_call_service -->|"dispatches call events"| node_socket
node_call_service -->|"uses call data"| node_models
node_admin_ui -.->|"requests analytics"| node_api_app

click node_app "https://github.com/rohansantra/connecto/blob/main/frontend/src/App.jsx"
click node_auth_ui "https://github.com/rohansantra/connecto/tree/main/frontend/src/components/auth"
click node_auth_store "https://github.com/rohansantra/connecto/blob/main/frontend/src/store/useAuthStore.js"
click node_chat_ui "https://github.com/rohansantra/connecto/tree/main/frontend/src/components/chat"
click node_chat_store "https://github.com/rohansantra/connecto/blob/main/frontend/src/store/useChatStore.js"
click node_message_store "https://github.com/rohansantra/connecto/blob/main/frontend/src/store/useMessageStore.js"
click node_profile_store "https://github.com/rohansantra/connecto/blob/main/frontend/src/store/useProfileStore.js"
click node_calls_ui "https://github.com/rohansantra/connecto/tree/main/frontend/src/components/calls"
click node_webrtc "https://github.com/rohansantra/connecto/blob/main/frontend/src/hooks/useWebRTC.js"
click node_admin_ui "https://github.com/rohansantra/connecto/blob/main/frontend/src/pages/admin/AdminAnalyticsPage.jsx"
click node_api_app "https://github.com/rohansantra/connecto/blob/main/backend/src/app.js"
click node_auth_controller "https://github.com/rohansantra/connecto/blob/main/backend/src/controllers/auth.controller.js"
click node_chat_controller "https://github.com/rohansantra/connecto/blob/main/backend/src/controllers/chat.controller.js"
click node_message_controller "https://github.com/rohansantra/connecto/blob/main/backend/src/controllers/message.controller.js"
click node_profile_controller "https://github.com/rohansantra/connecto/blob/main/backend/src/controllers/profile.controller.js"
click node_admin_controller "https://github.com/rohansantra/connecto/blob/main/backend/src/controllers/admin.controller.js"
click node_socket "https://github.com/rohansantra/connecto/blob/main/backend/src/socket/index.js"
click node_call_service "https://github.com/rohansantra/connecto/blob/main/backend/src/services/call.service.js"
click node_models "https://github.com/rohansantra/connecto/tree/main/backend/src/models"
click node_cloudinary "https://github.com/rohansantra/connecto/blob/main/backend/src/utils/cloudinary.js"
click node_block_utils "https://github.com/rohansantra/connecto/blob/main/backend/src/utils/block.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_auth_ui,node_auth_store,node_chat_ui,node_chat_store,node_message_store,node_profile_store,node_calls_ui,node_webrtc,node_user toneBlue
class node_api_app,node_auth_controller,node_chat_controller,node_message_controller,node_profile_controller,node_cloudinary,node_block_utils,node_database toneAmber
class node_socket,node_call_service toneMint
class node_models toneRose
class node_admin_ui,node_admin_controller,node_cloudinary_service toneIndigo
```

## Components

### Web client

- [Route and shell](https://github.com/rohansantra/connecto/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Sign-in and OTP](https://github.com/rohansantra/connecto/tree/main/frontend/src/components/auth): `frontend/src/components/auth`
- [Auth state](https://github.com/rohansantra/connecto/blob/main/frontend/src/store/useAuthStore.js): `frontend/src/store/useAuthStore.js`
- [Chat workspace](https://github.com/rohansantra/connecto/tree/main/frontend/src/components/chat): `frontend/src/components/chat`
- [Chat state](https://github.com/rohansantra/connecto/blob/main/frontend/src/store/useChatStore.js): `frontend/src/store/useChatStore.js`
- [Message state](https://github.com/rohansantra/connecto/blob/main/frontend/src/store/useMessageStore.js): `frontend/src/store/useMessageStore.js`
- [Profile state](https://github.com/rohansantra/connecto/blob/main/frontend/src/store/useProfileStore.js): `frontend/src/store/useProfileStore.js`
- [Call interface](https://github.com/rohansantra/connecto/tree/main/frontend/src/components/calls): `frontend/src/components/calls`
- [WebRTC handling](https://github.com/rohansantra/connecto/blob/main/frontend/src/hooks/useWebRTC.js): `frontend/src/hooks/useWebRTC.js`

### API backend

- [HTTP app and routes](https://github.com/rohansantra/connecto/blob/main/backend/src/app.js): `backend/src/app.js`
- [Authentication](https://github.com/rohansantra/connecto/blob/main/backend/src/controllers/auth.controller.js): `backend/src/controllers/auth.controller.js`
- [Chat management](https://github.com/rohansantra/connecto/blob/main/backend/src/controllers/chat.controller.js): `backend/src/controllers/chat.controller.js`
- [Message handling](https://github.com/rohansantra/connecto/blob/main/backend/src/controllers/message.controller.js): `backend/src/controllers/message.controller.js`
- [Profile management](https://github.com/rohansantra/connecto/blob/main/backend/src/controllers/profile.controller.js): `backend/src/controllers/profile.controller.js`
- [Media storage adapter](https://github.com/rohansantra/connecto/blob/main/backend/src/utils/cloudinary.js): `backend/src/utils/cloudinary.js`
- [Block checks](https://github.com/rohansantra/connecto/blob/main/backend/src/utils/block.utils.js): `backend/src/utils/block.utils.js`

### Realtime and calls

- [Socket events](https://github.com/rohansantra/connecto/blob/main/backend/src/socket/index.js): `backend/src/socket/index.js`
- [Call services](https://github.com/rohansantra/connecto/blob/main/backend/src/services/call.service.js): `backend/src/services/call.service.js`

### Domain storage

- [MongoDB domain models](https://github.com/rohansantra/connecto/tree/main/backend/src/models): `backend/src/models`

### Administration

- [Admin analytics UI](https://github.com/rohansantra/connecto/blob/main/frontend/src/pages/admin/AdminAnalyticsPage.jsx): `frontend/src/pages/admin/AdminAnalyticsPage.jsx`
- [Admin reporting](https://github.com/rohansantra/connecto/blob/main/backend/src/controllers/admin.controller.js): `backend/src/controllers/admin.controller.js`

### Other components

- **User**
- **MongoDB**
- **Cloudinary**

## Connections

- User → Route and shell: opens
- Route and shell → Sign-in and OTP: routes to (evidence: `frontend/src/App.jsx`)
- Route and shell → Call interface: renders (evidence: `frontend/src/App.jsx`)
- Sign-in and OTP → Auth state: submits to
- Auth state → HTTP app and routes: requests auth
- Auth state → Socket events: starts socket (evidence: `frontend/src/store/useAuthStore.js`)
- Auth state → Chat state: coordinates (evidence: `frontend/src/store/useAuthStore.js`)
- Auth state → Message state: coordinates (evidence: `frontend/src/store/useAuthStore.js`)
- Auth state → Profile state: coordinates (evidence: `frontend/src/store/useAuthStore.js`)
- Chat workspace → Chat state: uses state
- Chat state → Message state: coordinates (evidence: `frontend/src/store/useChatStore.js`)
- Chat state → Profile state: uses state (evidence: `frontend/src/store/useChatStore.js`)
- Message state → Chat state: uses state (evidence: `frontend/src/store/useMessageStore.js`)
- Message state → Profile state: uses state (evidence: `frontend/src/store/useMessageStore.js`)
- Call interface → WebRTC handling: uses
- WebRTC handling → Socket events: signals through
- HTTP app and routes → Authentication: routes auth (evidence: `backend/src/app.js`)
- HTTP app and routes → Chat management: routes chats (evidence: `backend/src/app.js`)
- HTTP app and routes → Message handling: routes messages (evidence: `backend/src/app.js`)
- HTTP app and routes → Profile management: routes profiles (evidence: `backend/src/app.js`)
- HTTP app and routes → Admin reporting: routes admin (evidence: `backend/src/app.js`)
- Chat management → MongoDB domain models: reads and writes (evidence: `backend/src/controllers/chat.controller.js`)
- Message handling → MongoDB domain models: reads and writes (evidence: `backend/src/controllers/message.controller.js`)
- Profile management → MongoDB domain models: reads and writes (evidence: `backend/src/controllers/profile.controller.js`)
- Authentication → MongoDB domain models: reads and writes (evidence: `backend/src/controllers/auth.controller.js`)
- Admin reporting → MongoDB domain models: aggregates (evidence: `backend/src/controllers/admin.controller.js`)
- MongoDB domain models → MongoDB: persists
- Chat management → Socket events: emits events (evidence: `backend/src/controllers/chat.controller.js`)
- Message handling → Socket events: emits events (evidence: `backend/src/controllers/message.controller.js`)
- Message handling → Media storage adapter: uploads media (evidence: `backend/src/controllers/message.controller.js`)
- Chat management → Media storage adapter: uploads avatars (evidence: `backend/src/controllers/chat.controller.js`)
- Media storage adapter → Cloudinary: stores files
- Message handling → Block checks: checks blocking (evidence: `backend/src/controllers/message.controller.js`)
- Socket events → Block checks: checks blocking (evidence: `backend/src/socket/index.js`)
- Socket events → MongoDB domain models: reads and updates (evidence: `backend/src/socket/index.js`)
- Call services → Socket events: dispatches call events (evidence: `backend/src/services/call.service.js`)
- Call services → MongoDB domain models: uses call data (evidence: `backend/src/services/call.service.js`)
- Admin analytics UI → HTTP app and routes: requests analytics
