# varsha-1906/gather architecture

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

- Interactive diagram: https://gitdiagram.com/varsha-1906/gather
- Repository: https://github.com/varsha-1906/gather

## Overview

Gather is a private one-to-one chat application. Users register or sign in, search for members, open a conversation, and exchange live messages while retaining saved history. The client coordinates authentication, conversation selection, and chat state; the Express API handles account, user, and conversation operations, while Socket.IO supports real-time chat. MongoDB stores users, conversations, and messages. The graph follows the README, source index, and shown excerpts; unsampled implementation details are represented only where paths and relationships are supported.

Main entry points: [`client/src/services/api.js`](https://github.com/varsha-1906/gather/blob/main/client/src/services/api.js) (HTTP client), [`client/src/pages/Home.jsx`](https://github.com/varsha-1906/gather/blob/main/client/src/pages/Home.jsx) (Chat home), [`server/src/config/database.js`](https://github.com/varsha-1906/gather/blob/main/server/src/config/database.js) (Database connection), [`server/src/app.js`](https://github.com/varsha-1906/gather/blob/main/server/src/app.js) (HTTP application)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Chat client"]
  node_app["App routing<br/>[App.jsx]"]
  node_authui["Auth state<br/>[AuthContext.jsx]"]
  node_authpages["Sign in and register<br/>[Register.jsx]"]
  node_home["Chat home<br/>[Home.jsx]"]
  node_search["Member search<br/>[UserSearch.jsx]"]
  node_usercard["Member card<br/>[UserCard.jsx]"]
  node_chatlist["Conversation list<br/>[ChatList.jsx]"]
  node_chatwindow["Chat window<br/>[ChatWindow.jsx]"]
  node_input["Message composer<br/>[MessageInput.jsx]"]
  node_directchat["Direct chat state<br/>[useDirectChat.js]"]
  node_api["HTTP client<br/>[api.js]"]
  node_socketclient["Socket client<br/>[socket.js]"]
end

subgraph group_server["API and realtime"]
  node_express["HTTP application<br/>[app.js]"]
  node_authroutes["Auth routes<br/>[authRoutes.js]"]
  node_userroutes["User routes<br/>[userRoutes.js]"]
  node_messageroutes["Message routes<br/>[messageRoutes.js]"]
  node_usercontroller["User search<br/>[userController.js]"]
  node_messagecontroller["Conversation operations"]
  node_socketserver["Chat socket<br/>[chatSocket.js]"]
  node_serverentry["Server startup<br/>[server.js]"]
end

subgraph group_data["Persistence"]
  node_dbconfig["Database connection<br/>[database.js]"]
  node_user[("User records<br/>[User.js]")]
  node_conversation[("Conversation records<br/>[Conversation.js]")]
  node_message[("Message records<br/>[Message.js]")]
end

subgraph group_identity["Authentication"]
  node_authcontroller["Account operations<br/>[authController.js]"]
  node_authmiddleware["Token verification<br/>[authMiddleware.js]"]
end

node_person(("Chat user"))
node_mongodb[("MongoDB")]
node_browser(("Browser"))

node_person -->|"uses"| node_app
node_app -->|"provides state"| node_authui
node_app -->|"routes to"| node_authpages
node_authpages -->|"signs in"| node_authui
node_authui -->|"requests identity"| node_api
node_authui -.->|"unlocks"| node_home
node_home -->|"loads conversations"| node_api
node_home -->|"renders"| node_search
node_home -->|"renders"| node_chatlist
node_home -->|"renders"| node_chatwindow
node_search -->|"searches members"| node_api
node_search -->|"renders"| node_usercard
node_home -->|"opens conversation"| node_api
node_chatwindow -->|"uses chat state"| node_directchat
node_chatwindow -->|"renders"| node_input
node_directchat -->|"loads history"| node_api
node_directchat -->|"joins and sends"| node_socketclient
node_api -->|"HTTP requests"| node_express
node_socketclient -.->|"realtime events"| node_socketserver
node_express -->|"mounts"| node_authroutes
node_express -->|"mounts"| node_userroutes
node_express -->|"mounts"| node_messageroutes
node_authroutes -->|"dispatches"| node_authcontroller
node_authroutes -->|"protects profile"| node_authmiddleware
node_userroutes -->|"dispatches"| node_usercontroller
node_userroutes -->|"protects routes"| node_authmiddleware
node_messageroutes -->|"dispatches"| node_messagecontroller
node_messageroutes -->|"protects routes"| node_authmiddleware
node_authcontroller -->|"reads and writes"| node_user
node_authcontroller -->|"signs tokens"| node_authmiddleware
node_usercontroller -->|"searches"| node_user
node_messagecontroller -->|"reads and creates"| node_conversation
node_messagecontroller -->|"reads history"| node_message
node_messagecontroller -->|"loads participants"| node_user
node_socketserver -->|"authenticates socket"| node_authmiddleware
node_socketserver -->|"checks membership"| node_conversation
node_socketserver -->|"handles messages"| node_message
node_serverentry -->|"starts"| node_express
node_serverentry -->|"connects before serving"| node_dbconfig
node_serverentry -->|"registers"| node_socketserver
node_dbconfig -->|"connects"| node_mongodb
node_dbconfig -->|"loads model"| node_user
node_dbconfig -->|"loads model"| node_conversation
node_dbconfig -->|"loads model"| node_message
node_browser -.->|"sends requests"| node_api

click node_app "https://github.com/varsha-1906/gather/blob/main/client/src/App.jsx"
click node_authui "https://github.com/varsha-1906/gather/blob/main/client/src/context/AuthContext.jsx"
click node_authpages "https://github.com/varsha-1906/gather/blob/main/client/src/pages/Register.jsx"
click node_home "https://github.com/varsha-1906/gather/blob/main/client/src/pages/Home.jsx"
click node_search "https://github.com/varsha-1906/gather/blob/main/client/src/components/UserSearch.jsx"
click node_usercard "https://github.com/varsha-1906/gather/blob/main/client/src/components/UserCard.jsx"
click node_chatlist "https://github.com/varsha-1906/gather/blob/main/client/src/components/ChatList.jsx"
click node_chatwindow "https://github.com/varsha-1906/gather/blob/main/client/src/components/ChatWindow.jsx"
click node_input "https://github.com/varsha-1906/gather/blob/main/client/src/components/MessageInput.jsx"
click node_directchat "https://github.com/varsha-1906/gather/blob/main/client/src/hooks/useDirectChat.js"
click node_api "https://github.com/varsha-1906/gather/blob/main/client/src/services/api.js"
click node_socketclient "https://github.com/varsha-1906/gather/blob/main/client/src/services/socket.js"
click node_express "https://github.com/varsha-1906/gather/blob/main/server/src/app.js"
click node_authroutes "https://github.com/varsha-1906/gather/blob/main/server/src/routes/authRoutes.js"
click node_userroutes "https://github.com/varsha-1906/gather/blob/main/server/src/routes/userRoutes.js"
click node_messageroutes "https://github.com/varsha-1906/gather/blob/main/server/src/routes/messageRoutes.js"
click node_authcontroller "https://github.com/varsha-1906/gather/blob/main/server/src/controllers/authController.js"
click node_authmiddleware "https://github.com/varsha-1906/gather/blob/main/server/src/middleware/authMiddleware.js"
click node_usercontroller "https://github.com/varsha-1906/gather/blob/main/server/src/controllers/userController.js"
click node_messagecontroller "https://github.com/varsha-1906/gather/blob/main/server/src/controllers/messageController.js"
click node_socketserver "https://github.com/varsha-1906/gather/blob/main/server/src/sockets/chatSocket.js"
click node_serverentry "https://github.com/varsha-1906/gather/blob/main/server/src/server.js"
click node_dbconfig "https://github.com/varsha-1906/gather/blob/main/server/src/config/database.js"
click node_user "https://github.com/varsha-1906/gather/blob/main/server/src/models/User.js"
click node_conversation "https://github.com/varsha-1906/gather/blob/main/server/src/models/Conversation.js"
click node_message "https://github.com/varsha-1906/gather/blob/main/server/src/models/Message.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_authpages,node_home,node_search,node_usercard,node_chatlist,node_chatwindow,node_input,node_directchat,node_api,node_socketclient,node_person,node_browser toneBlue
class node_express,node_authroutes,node_userroutes,node_messageroutes,node_usercontroller,node_messagecontroller,node_socketserver,node_serverentry,node_mongodb toneAmber
class node_dbconfig,node_user,node_conversation,node_message toneMint
class node_authcontroller,node_authmiddleware toneRose
```

## Components

### Chat client

- [App routing](https://github.com/varsha-1906/gather/blob/main/client/src/App.jsx): `client/src/App.jsx`
- [Auth state](https://github.com/varsha-1906/gather/blob/main/client/src/context/AuthContext.jsx): `client/src/context/AuthContext.jsx`
- [Sign in and register](https://github.com/varsha-1906/gather/blob/main/client/src/pages/Register.jsx): `client/src/pages/Register.jsx`
- [Chat home](https://github.com/varsha-1906/gather/blob/main/client/src/pages/Home.jsx): `client/src/pages/Home.jsx`
- [Member search](https://github.com/varsha-1906/gather/blob/main/client/src/components/UserSearch.jsx): `client/src/components/UserSearch.jsx`
- [Member card](https://github.com/varsha-1906/gather/blob/main/client/src/components/UserCard.jsx): `client/src/components/UserCard.jsx`
- [Conversation list](https://github.com/varsha-1906/gather/blob/main/client/src/components/ChatList.jsx): `client/src/components/ChatList.jsx`
- [Chat window](https://github.com/varsha-1906/gather/blob/main/client/src/components/ChatWindow.jsx): `client/src/components/ChatWindow.jsx`
- [Message composer](https://github.com/varsha-1906/gather/blob/main/client/src/components/MessageInput.jsx): `client/src/components/MessageInput.jsx`
- [Direct chat state](https://github.com/varsha-1906/gather/blob/main/client/src/hooks/useDirectChat.js): `client/src/hooks/useDirectChat.js`
- [HTTP client](https://github.com/varsha-1906/gather/blob/main/client/src/services/api.js): `client/src/services/api.js`
- [Socket client](https://github.com/varsha-1906/gather/blob/main/client/src/services/socket.js): `client/src/services/socket.js`

### API and realtime

- [HTTP application](https://github.com/varsha-1906/gather/blob/main/server/src/app.js): `server/src/app.js`
- [Auth routes](https://github.com/varsha-1906/gather/blob/main/server/src/routes/authRoutes.js): `server/src/routes/authRoutes.js`
- [User routes](https://github.com/varsha-1906/gather/blob/main/server/src/routes/userRoutes.js): `server/src/routes/userRoutes.js`
- [Message routes](https://github.com/varsha-1906/gather/blob/main/server/src/routes/messageRoutes.js): `server/src/routes/messageRoutes.js`
- [User search](https://github.com/varsha-1906/gather/blob/main/server/src/controllers/userController.js): `server/src/controllers/userController.js`
- [Conversation operations](https://github.com/varsha-1906/gather/blob/main/server/src/controllers/messageController.js): `server/src/controllers/messageController.js`
- [Chat socket](https://github.com/varsha-1906/gather/blob/main/server/src/sockets/chatSocket.js): `server/src/sockets/chatSocket.js`
- [Server startup](https://github.com/varsha-1906/gather/blob/main/server/src/server.js): `server/src/server.js`

### Persistence

- [Database connection](https://github.com/varsha-1906/gather/blob/main/server/src/config/database.js): `server/src/config/database.js`
- [User records](https://github.com/varsha-1906/gather/blob/main/server/src/models/User.js): `server/src/models/User.js`
- [Conversation records](https://github.com/varsha-1906/gather/blob/main/server/src/models/Conversation.js): `server/src/models/Conversation.js`
- [Message records](https://github.com/varsha-1906/gather/blob/main/server/src/models/Message.js): `server/src/models/Message.js`

### Authentication

- [Account operations](https://github.com/varsha-1906/gather/blob/main/server/src/controllers/authController.js): `server/src/controllers/authController.js`
- [Token verification](https://github.com/varsha-1906/gather/blob/main/server/src/middleware/authMiddleware.js): `server/src/middleware/authMiddleware.js`

### Other components

- **Chat user**
- **MongoDB**
- **Browser**

## Connections

- Chat user → App routing: uses (evidence: `README.md`)
- App routing → Auth state: provides state (evidence: `client/src/App.jsx`)
- App routing → Sign in and register: routes to (evidence: `client/src/App.jsx`)
- Sign in and register → Auth state: signs in (evidence: `client/src/pages/Register.jsx`)
- Auth state → HTTP client: requests identity (evidence: `client/src/context/AuthContext.jsx`)
- Auth state → Chat home: unlocks (evidence: `client/src/pages/Home.jsx`)
- Chat home → HTTP client: loads conversations (evidence: `client/src/pages/Home.jsx`)
- Chat home → Member search: renders (evidence: `client/src/pages/Home.jsx`)
- Chat home → Conversation list: renders (evidence: `client/src/pages/Home.jsx`)
- Chat home → Chat window: renders (evidence: `client/src/pages/Home.jsx`)
- Member search → HTTP client: searches members (evidence: `client/src/components/UserSearch.jsx`)
- Member search → Member card: renders (evidence: `client/src/components/UserSearch.jsx`)
- Chat home → HTTP client: opens conversation (evidence: `client/src/pages/Home.jsx`)
- Chat window → Direct chat state: uses chat state (evidence: `client/src/components/ChatWindow.jsx`)
- Chat window → Message composer: renders (evidence: `client/src/components/ChatWindow.jsx`)
- Direct chat state → HTTP client: loads history (evidence: `client/src/hooks/useDirectChat.js`)
- Direct chat state → Socket client: joins and sends (evidence: `client/src/hooks/useDirectChat.js`)
- HTTP client → HTTP application: HTTP requests (evidence: `README.md`)
- Socket client → Chat socket: realtime events
- HTTP application → Auth routes: mounts (evidence: `server/src/app.js`)
- HTTP application → User routes: mounts (evidence: `server/src/app.js`)
- HTTP application → Message routes: mounts (evidence: `server/src/app.js`)
- Auth routes → Account operations: dispatches (evidence: `server/src/routes/authRoutes.js`)
- Auth routes → Token verification: protects profile (evidence: `server/src/routes/authRoutes.js`)
- User routes → User search: dispatches (evidence: `server/src/routes/userRoutes.js`)
- User routes → Token verification: protects routes (evidence: `server/src/routes/userRoutes.js`)
- Message routes → Conversation operations: dispatches (evidence: `server/src/routes/messageRoutes.js`)
- Message routes → Token verification: protects routes (evidence: `server/src/routes/messageRoutes.js`)
- Account operations → User records: reads and writes (evidence: `server/src/controllers/authController.js`)
- Account operations → Token verification: signs tokens (evidence: `server/src/controllers/authController.js`)
- User search → User records: searches (evidence: `server/src/controllers/userController.js`)
- Conversation operations → Conversation records: reads and creates (evidence: `server/src/controllers/messageController.js`)
- Conversation operations → Message records: reads history (evidence: `server/src/controllers/messageController.js`)
- Conversation operations → User records: loads participants (evidence: `server/src/controllers/messageController.js`)
- Chat socket → Token verification: authenticates socket (evidence: `server/src/sockets/chatSocket.js`)
- Chat socket → Conversation records: checks membership (evidence: `server/src/sockets/chatSocket.js`)
- Chat socket → Message records: handles messages (evidence: `server/src/sockets/chatSocket.js`)
- Server startup → HTTP application: starts (evidence: `server/src/server.js`)
- Server startup → Database connection: connects before serving (evidence: `server/src/server.js`)
- Server startup → Chat socket: registers (evidence: `server/src/server.js`)
- Database connection → MongoDB: connects (evidence: `README.md`)
- Database connection → User records: loads model (evidence: `server/src/config/database.js`)
- Database connection → Conversation records: loads model (evidence: `server/src/config/database.js`)
- Database connection → Message records: loads model (evidence: `server/src/config/database.js`)
- Browser → HTTP client: sends requests
