# vinith-krish/nexchat-full-stack-mern-app architecture

> Architecture diagram of the GitHub repository vinith-krish/nexchat-full-stack-mern-app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vinith-krish/nexchat-full-stack-mern-app
- Repository: https://github.com/vinith-krish/nexchat-full-stack-mern-app

## Overview

NexChat supports account recovery and profile setup, skill-based collaborator discovery, and conversations with persisted, encrypted messages, attachments, read/delete events, and online presence. The main path runs from browser pages through React contexts to the Express routes and controllers; Socket.IO carries presence and message events. README documents capabilities beyond the sampled excerpts, so unsampled subsystem wiring is shown only where the routes and documented architecture support it.

Main entry points: [`server/controllers/messageController.js`](https://github.com/vinith-krish/nexchat-full-stack-mern-app/blob/main/server/controllers/messageController.js) (Message controller), [`server/server.js`](https://github.com/vinith-krish/nexchat-full-stack-mern-app/blob/main/server/server.js) (Express and Socket.IO), [`client/context/AuthContext.jsx`](https://github.com/vinith-krish/nexchat-full-stack-mern-app/blob/main/client/context/AuthContext.jsx) (Auth context), [`server/routes/userRoutes.js`](https://github.com/vinith-krish/nexchat-full-stack-mern-app/blob/main/server/routes/userRoutes.js) (Account routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Browser client"]
  node_app["App routes<br/>[App.jsx]"]
  node_authctx["Auth context<br/>[AuthContext.jsx]"]
  node_chatctx["Chat context<br/>[ChatContext.jsx]"]
  node_authpages["Auth and profile"]
  node_homepage["Chat workspace<br/>[HomePage.jsx]"]
  node_chatui["Conversation UI<br/>[ChatContainer.jsx]"]
  node_discoverui["Collaborator discovery"]
end

subgraph group_account["Accounts and discovery"]
  node_useroutes["Account routes<br/>[userRoutes.js]"]
  node_userctrl["Account controller<br/>[userController.js]"]
  node_authmw["Cookie auth<br/>[auth.js]"]
end

subgraph group_chat["Messaging and realtime"]
  node_server["Express and Socket.IO<br/>[server.js]"]
  node_messageroutes["Message routes<br/>[messageRoutes.js]"]
  node_msgctrl["Message controller"]
end

subgraph group_data["Persistence and integrations"]
  node_userdb[("User records<br/>[User.js]")]
  node_messagedb[("Message records<br/>[Message.js]")]
  node_encryption["Message encryption<br/>[encryption.js]"]
end

node_user(("Browser user"))
node_mongodb[("MongoDB")]
node_cloudinary["Cloudinary"]

node_user -->|"uses"| node_app
node_app -->|"routes to"| node_authpages
node_app -->|"routes to"| node_homepage
node_authpages -->|"authenticates and updates"| node_authctx
node_homepage -->|"loads conversations"| node_chatctx
node_homepage -->|"opens discovery"| node_discoverui
node_chatui -->|"sends and reads"| node_chatctx
node_authctx -->|"HTTP requests"| node_useroutes
node_chatctx -->|"HTTP requests"| node_messageroutes
node_authctx -->|"opens socket"| node_server
node_server -->|"presence events"| node_authctx
node_server -->|"message events"| node_chatctx
node_server -->|"mounts routes"| node_useroutes
node_server -->|"mounts routes"| node_messageroutes
node_useroutes -->|"protects requests"| node_authmw
node_useroutes -->|"dispatches account actions"| node_userctrl
node_messageroutes -->|"protects requests"| node_authmw
node_messageroutes -->|"dispatches message actions"| node_msgctrl
node_userctrl -->|"reads and updates"| node_userdb
node_userctrl -.->|"uploads profile image"| node_cloudinary
node_authmw -->|"loads session user"| node_userdb
node_msgctrl -->|"checks users and skills"| node_userdb
node_msgctrl -->|"reads and writes messages"| node_messagedb
node_msgctrl -->|"encrypts and decrypts"| node_encryption
node_msgctrl -.->|"uploads attachments"| node_cloudinary
node_msgctrl -->|"dispatches socket events"| node_server
node_userdb -->|"persists"| node_mongodb
node_messagedb -->|"persists"| node_mongodb

click node_app "https://github.com/vinith-krish/nexchat-full-stack-mern-app/blob/main/client/src/App.jsx"
click node_authctx "https://github.com/vinith-krish/nexchat-full-stack-mern-app/blob/main/client/context/AuthContext.jsx"
click node_chatctx "https://github.com/vinith-krish/nexchat-full-stack-mern-app/blob/main/client/context/ChatContext.jsx"
click node_authpages "https://github.com/vinith-krish/nexchat-full-stack-mern-app/tree/main/client/src/pages"
click node_homepage "https://github.com/vinith-krish/nexchat-full-stack-mern-app/blob/main/client/src/pages/HomePage.jsx"
click node_chatui "https://github.com/vinith-krish/nexchat-full-stack-mern-app/blob/main/client/src/components/ChatContainer.jsx"
click node_discoverui "https://github.com/vinith-krish/nexchat-full-stack-mern-app/blob/main/client/src/components/CollaborationDiscovery.jsx"
click node_server "https://github.com/vinith-krish/nexchat-full-stack-mern-app/blob/main/server/server.js"
click node_useroutes "https://github.com/vinith-krish/nexchat-full-stack-mern-app/blob/main/server/routes/userRoutes.js"
click node_userctrl "https://github.com/vinith-krish/nexchat-full-stack-mern-app/blob/main/server/controllers/userController.js"
click node_authmw "https://github.com/vinith-krish/nexchat-full-stack-mern-app/blob/main/server/middleware/auth.js"
click node_messageroutes "https://github.com/vinith-krish/nexchat-full-stack-mern-app/blob/main/server/routes/messageRoutes.js"
click node_msgctrl "https://github.com/vinith-krish/nexchat-full-stack-mern-app/blob/main/server/controllers/messageController.js"
click node_userdb "https://github.com/vinith-krish/nexchat-full-stack-mern-app/blob/main/server/models/User.js"
click node_messagedb "https://github.com/vinith-krish/nexchat-full-stack-mern-app/blob/main/server/models/Message.js"
click node_encryption "https://github.com/vinith-krish/nexchat-full-stack-mern-app/blob/main/server/lib/encryption.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_authctx,node_chatctx,node_authpages,node_homepage,node_chatui,node_discoverui,node_user toneBlue
class node_useroutes,node_userctrl,node_authmw,node_mongodb toneAmber
class node_server,node_messageroutes,node_msgctrl toneMint
class node_userdb,node_messagedb,node_encryption toneRose
class node_cloudinary toneIndigo
```

## Components

### Browser client

- [App routes](https://github.com/vinith-krish/nexchat-full-stack-mern-app/blob/main/client/src/App.jsx): `client/src/App.jsx`
- [Auth context](https://github.com/vinith-krish/nexchat-full-stack-mern-app/blob/main/client/context/AuthContext.jsx): `client/context/AuthContext.jsx`
- [Chat context](https://github.com/vinith-krish/nexchat-full-stack-mern-app/blob/main/client/context/ChatContext.jsx): `client/context/ChatContext.jsx`
- [Auth and profile](https://github.com/vinith-krish/nexchat-full-stack-mern-app/tree/main/client/src/pages): `client/src/pages`
- [Chat workspace](https://github.com/vinith-krish/nexchat-full-stack-mern-app/blob/main/client/src/pages/HomePage.jsx): `client/src/pages/HomePage.jsx`
- [Conversation UI](https://github.com/vinith-krish/nexchat-full-stack-mern-app/blob/main/client/src/components/ChatContainer.jsx): `client/src/components/ChatContainer.jsx`
- [Collaborator discovery](https://github.com/vinith-krish/nexchat-full-stack-mern-app/blob/main/client/src/components/CollaborationDiscovery.jsx): `client/src/components/CollaborationDiscovery.jsx`

### Accounts and discovery

- [Account routes](https://github.com/vinith-krish/nexchat-full-stack-mern-app/blob/main/server/routes/userRoutes.js): `server/routes/userRoutes.js`
- [Account controller](https://github.com/vinith-krish/nexchat-full-stack-mern-app/blob/main/server/controllers/userController.js): `server/controllers/userController.js`
- [Cookie auth](https://github.com/vinith-krish/nexchat-full-stack-mern-app/blob/main/server/middleware/auth.js): `server/middleware/auth.js`

### Messaging and realtime

- [Express and Socket.IO](https://github.com/vinith-krish/nexchat-full-stack-mern-app/blob/main/server/server.js): `server/server.js`
- [Message routes](https://github.com/vinith-krish/nexchat-full-stack-mern-app/blob/main/server/routes/messageRoutes.js): `server/routes/messageRoutes.js`
- [Message controller](https://github.com/vinith-krish/nexchat-full-stack-mern-app/blob/main/server/controllers/messageController.js): `server/controllers/messageController.js`

### Persistence and integrations

- [User records](https://github.com/vinith-krish/nexchat-full-stack-mern-app/blob/main/server/models/User.js): `server/models/User.js`
- [Message records](https://github.com/vinith-krish/nexchat-full-stack-mern-app/blob/main/server/models/Message.js): `server/models/Message.js`
- [Message encryption](https://github.com/vinith-krish/nexchat-full-stack-mern-app/blob/main/server/lib/encryption.js): `server/lib/encryption.js`

### Other components

- **Browser user**
- **MongoDB**
- **Cloudinary**

## Connections

- Browser user → App routes: uses
- App routes → Auth and profile: routes to
- App routes → Chat workspace: routes to
- Auth and profile → Auth context: authenticates and updates
- Chat workspace → Chat context: loads conversations
- Chat workspace → Collaborator discovery: opens discovery
- Conversation UI → Chat context: sends and reads
- Auth context → Account routes: HTTP requests
- Chat context → Message routes: HTTP requests
- Auth context → Express and Socket.IO: opens socket
- Express and Socket.IO → Auth context: presence events
- Express and Socket.IO → Chat context: message events
- Express and Socket.IO → Account routes: mounts routes
- Express and Socket.IO → Message routes: mounts routes
- Account routes → Cookie auth: protects requests
- Account routes → Account controller: dispatches account actions
- Message routes → Cookie auth: protects requests
- Message routes → Message controller: dispatches message actions
- Account controller → User records: reads and updates
- Account controller → Cloudinary: uploads profile image
- Cookie auth → User records: loads session user
- Message controller → User records: checks users and skills
- Message controller → Message records: reads and writes messages
- Message controller → Message encryption: encrypts and decrypts
- Message controller → Cloudinary: uploads attachments
- Message controller → Express and Socket.IO: dispatches socket events
- User records → MongoDB: persists
- Message records → MongoDB: persists
