# arpitve560/chatflow architecture

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

- Interactive diagram: https://gitdiagram.com/arpitve560/chatflow
- Repository: https://github.com/arpitve560/chatflow

## Overview

iychat is a real-time chat and social application. Users register or log in, find people, open conversations, and exchange messages; they can also manage profiles, follow requests, and notifications. The client communicates with an Express API and a Socket.io channel; server controllers handle authenticated requests and persist domain state in MongoDB. The sampled source supports the message, follow, and user flows directly. Other client and notification wiring is represented only where paths and documented capabilities support it.

Main entry points: [`server/src/app.js`](https://github.com/arpitve560/chatflow/blob/main/server/src/app.js) (Express app), [`client/src/lib/api.js`](https://github.com/arpitve560/chatflow/blob/main/client/src/lib/api.js) (HTTP client), [`server/src/controllers/followController.js`](https://github.com/arpitve560/chatflow/blob/main/server/src/controllers/followController.js) (Follow requests), [`server/src/models/User.js`](https://github.com/arpitve560/chatflow/blob/main/server/src/models/User.js) (User records)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_login["Login and register<br/>[page.js]"]
  node_chatpage["Chat screen<br/>[page.js]"]
  node_authctx["Auth state<br/>[AuthContext.js]"]
  node_chatlist["Conversation list<br/>[ChatList.js]"]
  node_chatwindow["Message view<br/>[ChatWindow.js]"]
  node_profileui["Profile panel<br/>[ProfilePanel.js]"]
  node_notifyui["Notifications panel"]
  node_api["HTTP client<br/>[api.js]"]
  node_socketclient["Socket client<br/>[socket.js]"]
end

subgraph group_api["HTTP API"]
  node_app["Express app<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_authcontroller["Authentication<br/>[authController.js]"]
  node_usercontroller["User and profile<br/>[userController.js]"]
end

subgraph group_social["Social features"]
  node_followroutes["Follow routes<br/>[followRoutes.js]"]
  node_notificationroutes["Notification routes"]
  node_followcontroller["Follow requests"]
  node_notificationcontroller["Notification handling"]
end

subgraph group_realtime["Realtime messaging"]
  node_messagecontroller["Conversation handling"]
  node_sockethandler["Socket events<br/>[socketHandler.js]"]
end

subgraph group_data["Persistent data"]
  node_userstore[("User records<br/>[User.js]")]
  node_messagestore[("Message records<br/>[Message.js]")]
  node_followstore[("Follow requests<br/>[FollowRequest.js]")]
  node_notificationstore[("Notifications<br/>[Notification.js]")]
end

node_user(("User"))
node_mongodb[("MongoDB")]

node_user -->|"registers or logs in"| node_login
node_user -->|"uses"| node_chatpage
node_chatpage -->|"shows"| node_chatlist
node_chatpage -->|"opens"| node_chatwindow
node_user -->|"manages profile"| node_profileui
node_user -->|"views alerts"| node_notifyui
node_login -->|"updates auth state"| node_authctx
node_authctx -->|"uses"| node_api
node_chatlist -->|"requests conversations"| node_api
node_chatwindow -->|"loads and sends messages"| node_api
node_profileui -->|"requests profile"| node_api
node_notifyui -->|"requests notifications"| node_api
node_chatwindow -->|"exchanges events"| node_socketclient
node_api -->|"sends HTTP requests"| node_app
node_app -->|"mounts"| node_authroutes
node_app -->|"mounts"| node_userroutes
node_app -->|"mounts"| node_messageroutes
node_app -->|"mounts"| node_followroutes
node_app -->|"mounts"| node_notificationroutes
node_authroutes -->|"dispatches"| node_authcontroller
node_userroutes -->|"dispatches"| node_usercontroller
node_messageroutes -->|"dispatches"| node_messagecontroller
node_followroutes -->|"dispatches"| node_followcontroller
node_notificationroutes -->|"dispatches"| node_notificationcontroller
node_authcontroller -->|"reads and writes"| node_userstore
node_usercontroller -->|"reads and writes"| node_userstore
node_usercontroller -->|"reads"| node_followstore
node_messagecontroller -->|"reads and writes"| node_messagestore
node_followcontroller -->|"reads and writes"| node_followstore
node_followcontroller -->|"looks up users"| node_userstore
node_followcontroller -->|"creates notifications"| node_notificationstore
node_notificationcontroller -->|"handles notifications"| node_notificationstore
node_sockethandler -->|"dispatches events"| node_socketclient
node_messagecontroller -->|"looks up online users"| node_sockethandler
node_sockethandler -->|"provides online map"| node_followcontroller
node_userstore -->|"persists"| node_mongodb
node_messagestore -->|"persists"| node_mongodb
node_followstore -->|"persists"| node_mongodb
node_notificationstore -->|"persists"| node_mongodb

click node_login "https://github.com/arpitve560/chatflow/blob/main/client/src/app/login/page.js"
click node_chatpage "https://github.com/arpitve560/chatflow/blob/main/client/src/app/chat/page.js"
click node_authctx "https://github.com/arpitve560/chatflow/blob/main/client/src/context/AuthContext.js"
click node_chatlist "https://github.com/arpitve560/chatflow/blob/main/client/src/components/ChatList.js"
click node_chatwindow "https://github.com/arpitve560/chatflow/blob/main/client/src/components/ChatWindow.js"
click node_profileui "https://github.com/arpitve560/chatflow/blob/main/client/src/components/ProfilePanel.js"
click node_notifyui "https://github.com/arpitve560/chatflow/blob/main/client/src/components/NotificationPanel.js"
click node_api "https://github.com/arpitve560/chatflow/blob/main/client/src/lib/api.js"
click node_socketclient "https://github.com/arpitve560/chatflow/blob/main/client/src/lib/socket.js"
click node_app "https://github.com/arpitve560/chatflow/blob/main/server/src/app.js"
click node_authroutes "https://github.com/arpitve560/chatflow/blob/main/server/src/routes/authRoutes.js"
click node_userroutes "https://github.com/arpitve560/chatflow/blob/main/server/src/routes/userRoutes.js"
click node_messageroutes "https://github.com/arpitve560/chatflow/blob/main/server/src/routes/messageRoutes.js"
click node_followroutes "https://github.com/arpitve560/chatflow/blob/main/server/src/routes/followRoutes.js"
click node_notificationroutes "https://github.com/arpitve560/chatflow/blob/main/server/src/routes/notificationRoutes.js"
click node_authcontroller "https://github.com/arpitve560/chatflow/blob/main/server/src/controllers/authController.js"
click node_usercontroller "https://github.com/arpitve560/chatflow/blob/main/server/src/controllers/userController.js"
click node_messagecontroller "https://github.com/arpitve560/chatflow/blob/main/server/src/controllers/messageController.js"
click node_followcontroller "https://github.com/arpitve560/chatflow/blob/main/server/src/controllers/followController.js"
click node_notificationcontroller "https://github.com/arpitve560/chatflow/blob/main/server/src/controllers/notificationController.js"
click node_sockethandler "https://github.com/arpitve560/chatflow/blob/main/server/src/socket/socketHandler.js"
click node_userstore "https://github.com/arpitve560/chatflow/blob/main/server/src/models/User.js"
click node_messagestore "https://github.com/arpitve560/chatflow/blob/main/server/src/models/Message.js"
click node_followstore "https://github.com/arpitve560/chatflow/blob/main/server/src/models/FollowRequest.js"
click node_notificationstore "https://github.com/arpitve560/chatflow/blob/main/server/src/models/Notification.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_login,node_chatpage,node_authctx,node_chatlist,node_chatwindow,node_profileui,node_notifyui,node_api,node_socketclient,node_user toneBlue
class node_app,node_authroutes,node_userroutes,node_messageroutes,node_authcontroller,node_usercontroller,node_mongodb toneAmber
class node_followroutes,node_notificationroutes,node_followcontroller,node_notificationcontroller toneMint
class node_messagecontroller,node_sockethandler toneRose
class node_userstore,node_messagestore,node_followstore,node_notificationstore toneIndigo
```

## Components

### Web client

- [Login and register](https://github.com/arpitve560/chatflow/blob/main/client/src/app/login/page.js): `client/src/app/login/page.js`
- [Chat screen](https://github.com/arpitve560/chatflow/blob/main/client/src/app/chat/page.js): `client/src/app/chat/page.js`
- [Auth state](https://github.com/arpitve560/chatflow/blob/main/client/src/context/AuthContext.js): `client/src/context/AuthContext.js`
- [Conversation list](https://github.com/arpitve560/chatflow/blob/main/client/src/components/ChatList.js): `client/src/components/ChatList.js`
- [Message view](https://github.com/arpitve560/chatflow/blob/main/client/src/components/ChatWindow.js): `client/src/components/ChatWindow.js`
- [Profile panel](https://github.com/arpitve560/chatflow/blob/main/client/src/components/ProfilePanel.js): `client/src/components/ProfilePanel.js`
- [Notifications panel](https://github.com/arpitve560/chatflow/blob/main/client/src/components/NotificationPanel.js): `client/src/components/NotificationPanel.js`
- [HTTP client](https://github.com/arpitve560/chatflow/blob/main/client/src/lib/api.js): `client/src/lib/api.js`
- [Socket client](https://github.com/arpitve560/chatflow/blob/main/client/src/lib/socket.js): `client/src/lib/socket.js`

### HTTP API

- [Express app](https://github.com/arpitve560/chatflow/blob/main/server/src/app.js): `server/src/app.js`
- [Auth routes](https://github.com/arpitve560/chatflow/blob/main/server/src/routes/authRoutes.js): `server/src/routes/authRoutes.js`
- [User routes](https://github.com/arpitve560/chatflow/blob/main/server/src/routes/userRoutes.js): `server/src/routes/userRoutes.js`
- [Message routes](https://github.com/arpitve560/chatflow/blob/main/server/src/routes/messageRoutes.js): `server/src/routes/messageRoutes.js`
- [Authentication](https://github.com/arpitve560/chatflow/blob/main/server/src/controllers/authController.js): `server/src/controllers/authController.js`
- [User and profile](https://github.com/arpitve560/chatflow/blob/main/server/src/controllers/userController.js): `server/src/controllers/userController.js`

### Social features

- [Follow routes](https://github.com/arpitve560/chatflow/blob/main/server/src/routes/followRoutes.js): `server/src/routes/followRoutes.js`
- [Notification routes](https://github.com/arpitve560/chatflow/blob/main/server/src/routes/notificationRoutes.js): `server/src/routes/notificationRoutes.js`
- [Follow requests](https://github.com/arpitve560/chatflow/blob/main/server/src/controllers/followController.js): `server/src/controllers/followController.js`
- [Notification handling](https://github.com/arpitve560/chatflow/blob/main/server/src/controllers/notificationController.js): `server/src/controllers/notificationController.js`

### Realtime messaging

- [Conversation handling](https://github.com/arpitve560/chatflow/blob/main/server/src/controllers/messageController.js): `server/src/controllers/messageController.js`
- [Socket events](https://github.com/arpitve560/chatflow/blob/main/server/src/socket/socketHandler.js): `server/src/socket/socketHandler.js`

### Persistent data

- [User records](https://github.com/arpitve560/chatflow/blob/main/server/src/models/User.js): `server/src/models/User.js`
- [Message records](https://github.com/arpitve560/chatflow/blob/main/server/src/models/Message.js): `server/src/models/Message.js`
- [Follow requests](https://github.com/arpitve560/chatflow/blob/main/server/src/models/FollowRequest.js): `server/src/models/FollowRequest.js`
- [Notifications](https://github.com/arpitve560/chatflow/blob/main/server/src/models/Notification.js): `server/src/models/Notification.js`

### Other components

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

## Connections

- User → Login and register: registers or logs in
- User → Chat screen: uses
- Chat screen → Conversation list: shows
- Chat screen → Message view: opens
- User → Profile panel: manages profile
- User → Notifications panel: views alerts
- Login and register → Auth state: updates auth state
- Auth state → HTTP client: uses
- Conversation list → HTTP client: requests conversations
- Message view → HTTP client: loads and sends messages
- Profile panel → HTTP client: requests profile
- Notifications panel → HTTP client: requests notifications
- Message view → Socket client: exchanges events
- HTTP client → Express app: sends HTTP requests
- Express app → Auth routes: mounts
- Express app → User routes: mounts
- Express app → Message routes: mounts
- Express app → Follow routes: mounts
- Express app → Notification routes: mounts
- Auth routes → Authentication: dispatches
- User routes → User and profile: dispatches
- Message routes → Conversation handling: dispatches
- Follow routes → Follow requests: dispatches
- Notification routes → Notification handling: dispatches
- Authentication → User records: reads and writes
- User and profile → User records: reads and writes
- User and profile → Follow requests: reads
- Conversation handling → Message records: reads and writes
- Follow requests → Follow requests: reads and writes
- Follow requests → User records: looks up users
- Follow requests → Notifications: creates notifications
- Notification handling → Notifications: handles notifications
- Socket events → Socket client: dispatches events
- Conversation handling → Socket events: looks up online users
- Socket events → Follow requests: provides online map
- User records → MongoDB: persists
- Message records → MongoDB: persists
- Follow requests → MongoDB: persists
- Notifications → MongoDB: persists
