# francescocartelli/nyla-instant-messaging-app architecture

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

- Interactive diagram: https://gitdiagram.com/francescocartelli/nyla-instant-messaging-app
- Repository: https://github.com/francescocartelli/nyla-instant-messaging-app

## Overview

Nyla is a browser-based instant messaging application: users authenticate, find people, create direct or group chats, and exchange and manage rich-text messages. The React SPA calls an Express REST API for account, user, chat, and message operations; a separate WebSocket server delivers real-time notifications, coordinated with the API through Redis. MongoDB backs application data. The main workflow and server links are supported by the excerpts and README; several client and service internals were not sampled, so their finer-grained connections are omitted.

Main entry points: [`server-api/app.ts`](https://github.com/francescocartelli/nyla-instant-messaging-app/blob/master/server-api/app.ts) (Express routes), [`client/src/App.jsx`](https://github.com/francescocartelli/nyla-instant-messaging-app/blob/master/client/src/App.jsx) (Routed SPA), [`server-api/src/controllers/Chat.ts`](https://github.com/francescocartelli/nyla-instant-messaging-app/blob/master/server-api/src/controllers/Chat.ts) (Chat controllers), [`client/src/pages/Chats/Chat.jsx`](https://github.com/francescocartelli/nyla-instant-messaging-app/blob/master/client/src/pages/Chats/Chat.jsx) (Chat screens)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["React client"]
  node_spa["Routed SPA<br/>[App.jsx]"]
  node_accountui["Account screens<br/>[Account.jsx]"]
  node_peopleui["People search<br/>[Users.jsx]"]
  node_chatui["Chat screens<br/>[Chat.jsx]"]
  node_editor["Rich text editor<br/>[editor.jsx]"]
  node_messageview["Message views"]
  node_wscontext["WebSocket context<br/>[WsContext.jsx]"]
  node_clientapi["API clients<br/>[chatAPI.js]"]
end

subgraph group_api["REST API"]
  node_rest["Express routes<br/>[app.ts]"]
  node_auth["Account controllers<br/>[Account.ts]"]
  node_chatctrl["Chat controllers<br/>[Chat.ts]"]
  node_msgctrl["Message controllers<br/>[Message.ts]"]
  node_userctrl["User controllers<br/>[User.ts]"]
  node_chatservices["Chat services<br/>[Chat.ts]"]
  node_messageservices["Message services<br/>[Message.ts]"]
  node_userservices["User services<br/>[User.ts]"]
end

subgraph group_realtime["Realtime delivery"]
  node_wsserver["WebSocket server<br/>[server.ts]"]
  node_connections["Connection groups"]
end

subgraph group_data["Persistence and messaging"]
  node_mongo[("MongoDB")]
  node_redis["Redis queue"]
end

node_person(("App user"))

node_person -->|"uses"| node_spa
node_spa -->|"routes to"| node_accountui
node_spa -->|"routes to"| node_peopleui
node_spa -->|"routes to"| node_chatui
node_chatui -.->|"displays"| node_messageview
node_chatui -.->|"composes messages"| node_editor
node_spa -->|"provides"| node_wscontext
node_accountui -.->|"requests account data"| node_clientapi
node_peopleui -.->|"searches users"| node_clientapi
node_chatui -.->|"requests chat data"| node_clientapi
node_clientapi -.->|"HTTP requests"| node_rest
node_rest -->|"routes authentication"| node_auth
node_rest -->|"routes chat operations"| node_chatctrl
node_rest -->|"routes message operations"| node_msgctrl
node_rest -->|"routes user operations"| node_userctrl
node_chatctrl -->|"calls"| node_chatservices
node_chatctrl -->|"deletes messages"| node_messageservices
node_chatctrl -->|"looks up users"| node_userservices
node_msgctrl -->|"calls"| node_messageservices
node_msgctrl -->|"checks chats"| node_chatservices
node_msgctrl -.->|"publishes events"| node_redis
node_chatctrl -->|"notifies chat changes"| node_redis
node_auth -->|"uses accounts"| node_userservices
node_userctrl -->|"calls"| node_userservices
node_userservices -->|"reads and writes"| node_mongo
node_chatservices -.->|"stores chat data"| node_mongo
node_messageservices -.->|"stores messages"| node_mongo
node_wscontext -.->|"WebSocket connection"| node_wsserver
node_wsserver -->|"groups connections"| node_connections
node_wsserver -->|"subscribes and forwards"| node_redis
node_wsserver -->|"fetches current user"| node_rest
node_rest -->|"persists application data"| node_mongo
node_rest -->|"coordinates notifications"| node_redis

click node_spa "https://github.com/francescocartelli/nyla-instant-messaging-app/blob/master/client/src/App.jsx"
click node_accountui "https://github.com/francescocartelli/nyla-instant-messaging-app/blob/master/client/src/pages/Account/Account.jsx"
click node_peopleui "https://github.com/francescocartelli/nyla-instant-messaging-app/blob/master/client/src/pages/Users/Users.jsx"
click node_chatui "https://github.com/francescocartelli/nyla-instant-messaging-app/blob/master/client/src/pages/Chats/Chat.jsx"
click node_editor "https://github.com/francescocartelli/nyla-instant-messaging-app/blob/master/client/src/components/SEditor/editor.jsx"
click node_messageview "https://github.com/francescocartelli/nyla-instant-messaging-app/blob/master/client/src/components/Chats/useMessagesContainer.js"
click node_wscontext "https://github.com/francescocartelli/nyla-instant-messaging-app/blob/master/client/src/components/Ws/WsContext.jsx"
click node_clientapi "https://github.com/francescocartelli/nyla-instant-messaging-app/blob/master/client/src/api/chatAPI.js"
click node_rest "https://github.com/francescocartelli/nyla-instant-messaging-app/blob/master/server-api/app.ts"
click node_auth "https://github.com/francescocartelli/nyla-instant-messaging-app/blob/master/server-api/src/controllers/Account.ts"
click node_chatctrl "https://github.com/francescocartelli/nyla-instant-messaging-app/blob/master/server-api/src/controllers/Chat.ts"
click node_msgctrl "https://github.com/francescocartelli/nyla-instant-messaging-app/blob/master/server-api/src/controllers/Message.ts"
click node_userctrl "https://github.com/francescocartelli/nyla-instant-messaging-app/blob/master/server-api/src/controllers/User.ts"
click node_chatservices "https://github.com/francescocartelli/nyla-instant-messaging-app/blob/master/server-api/src/services/Chat.ts"
click node_messageservices "https://github.com/francescocartelli/nyla-instant-messaging-app/blob/master/server-api/src/services/Message.ts"
click node_userservices "https://github.com/francescocartelli/nyla-instant-messaging-app/blob/master/server-api/src/services/User.ts"
click node_wsserver "https://github.com/francescocartelli/nyla-instant-messaging-app/blob/master/server-ws/server.ts"
click node_connections "https://github.com/francescocartelli/nyla-instant-messaging-app/blob/master/server-ws/utilities/ConnectionManager.ts"

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_spa,node_accountui,node_peopleui,node_chatui,node_editor,node_messageview,node_wscontext,node_clientapi,node_person toneBlue
class node_rest,node_auth,node_chatctrl,node_msgctrl,node_userctrl,node_chatservices,node_messageservices,node_userservices toneAmber
class node_wsserver,node_connections toneMint
class node_mongo,node_redis toneRose
```

## Components

### React client

- [Routed SPA](https://github.com/francescocartelli/nyla-instant-messaging-app/blob/master/client/src/App.jsx): `client/src/App.jsx`
- [Account screens](https://github.com/francescocartelli/nyla-instant-messaging-app/blob/master/client/src/pages/Account/Account.jsx): `client/src/pages/Account/Account.jsx`
- [People search](https://github.com/francescocartelli/nyla-instant-messaging-app/blob/master/client/src/pages/Users/Users.jsx): `client/src/pages/Users/Users.jsx`
- [Chat screens](https://github.com/francescocartelli/nyla-instant-messaging-app/blob/master/client/src/pages/Chats/Chat.jsx): `client/src/pages/Chats/Chat.jsx`
- [Rich text editor](https://github.com/francescocartelli/nyla-instant-messaging-app/blob/master/client/src/components/SEditor/editor.jsx): `client/src/components/SEditor/editor.jsx`
- [Message views](https://github.com/francescocartelli/nyla-instant-messaging-app/blob/master/client/src/components/Chats/useMessagesContainer.js): `client/src/components/Chats/useMessagesContainer.js`
- [WebSocket context](https://github.com/francescocartelli/nyla-instant-messaging-app/blob/master/client/src/components/Ws/WsContext.jsx): `client/src/components/Ws/WsContext.jsx`
- [API clients](https://github.com/francescocartelli/nyla-instant-messaging-app/blob/master/client/src/api/chatAPI.js): `client/src/api/chatAPI.js`

### REST API

- [Express routes](https://github.com/francescocartelli/nyla-instant-messaging-app/blob/master/server-api/app.ts): `server-api/app.ts`
- [Account controllers](https://github.com/francescocartelli/nyla-instant-messaging-app/blob/master/server-api/src/controllers/Account.ts): `server-api/src/controllers/Account.ts`
- [Chat controllers](https://github.com/francescocartelli/nyla-instant-messaging-app/blob/master/server-api/src/controllers/Chat.ts): `server-api/src/controllers/Chat.ts`
- [Message controllers](https://github.com/francescocartelli/nyla-instant-messaging-app/blob/master/server-api/src/controllers/Message.ts): `server-api/src/controllers/Message.ts`
- [User controllers](https://github.com/francescocartelli/nyla-instant-messaging-app/blob/master/server-api/src/controllers/User.ts): `server-api/src/controllers/User.ts`
- [Chat services](https://github.com/francescocartelli/nyla-instant-messaging-app/blob/master/server-api/src/services/Chat.ts): `server-api/src/services/Chat.ts`
- [Message services](https://github.com/francescocartelli/nyla-instant-messaging-app/blob/master/server-api/src/services/Message.ts): `server-api/src/services/Message.ts`
- [User services](https://github.com/francescocartelli/nyla-instant-messaging-app/blob/master/server-api/src/services/User.ts): `server-api/src/services/User.ts`

### Realtime delivery

- [WebSocket server](https://github.com/francescocartelli/nyla-instant-messaging-app/blob/master/server-ws/server.ts): `server-ws/server.ts`
- [Connection groups](https://github.com/francescocartelli/nyla-instant-messaging-app/blob/master/server-ws/utilities/ConnectionManager.ts): `server-ws/utilities/ConnectionManager.ts`

### Persistence and messaging

- **MongoDB**
- **Redis queue**

### Other components

- **App user**

## Connections

- App user → Routed SPA: uses
- Routed SPA → Account screens: routes to (evidence: `client/src/App.jsx`)
- Routed SPA → People search: routes to (evidence: `client/src/App.jsx`)
- Routed SPA → Chat screens: routes to (evidence: `client/src/App.jsx`)
- Chat screens → Message views: displays
- Chat screens → Rich text editor: composes messages
- Routed SPA → WebSocket context: provides (evidence: `client/src/App.jsx`)
- Account screens → API clients: requests account data
- People search → API clients: searches users
- Chat screens → API clients: requests chat data
- API clients → Express routes: HTTP requests
- Express routes → Account controllers: routes authentication (evidence: `server-api/app.ts`)
- Express routes → Chat controllers: routes chat operations (evidence: `server-api/app.ts`)
- Express routes → Message controllers: routes message operations (evidence: `server-api/app.ts`)
- Express routes → User controllers: routes user operations (evidence: `server-api/app.ts`)
- Chat controllers → Chat services: calls (evidence: `server-api/src/controllers/Chat.ts`)
- Chat controllers → Message services: deletes messages (evidence: `server-api/src/controllers/Chat.ts`)
- Chat controllers → User services: looks up users (evidence: `server-api/src/controllers/Chat.ts`)
- Message controllers → Message services: calls (evidence: `server-api/src/controllers/Message.ts`)
- Message controllers → Chat services: checks chats (evidence: `server-api/src/controllers/Message.ts`)
- Message controllers → Redis queue: publishes events
- Chat controllers → Redis queue: notifies chat changes (evidence: `server-api/src/controllers/Chat.ts`)
- Account controllers → User services: uses accounts (evidence: `server-api/src/controllers/Account.ts`)
- User controllers → User services: calls (evidence: `server-api/src/controllers/User.ts`)
- User services → MongoDB: reads and writes (evidence: `server-api/src/services/User.ts`)
- Chat services → MongoDB: stores chat data
- Message services → MongoDB: stores messages
- WebSocket context → WebSocket server: WebSocket connection
- WebSocket server → Connection groups: groups connections (evidence: `server-ws/server.ts`)
- WebSocket server → Redis queue: subscribes and forwards (evidence: `server-ws/server.ts`)
- WebSocket server → Express routes: fetches current user (evidence: `server-ws/server.ts`)
- Express routes → MongoDB: persists application data
- Express routes → Redis queue: coordinates notifications
