# barmanji/threadly architecture

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

- Interactive diagram: https://gitdiagram.com/barmanji/threadly
- Repository: https://github.com/barmanji/threadly

## Overview

Threadly is a retro-themed real-time chat product. Its main workflow is a user signing in, opening or creating a conversation, exchanging messages and attachments in real time, and optionally starting a peer-to-peer or group call. The map also preserves account verification and recovery, call history, collaborative whiteboarding, and the public changelog. Backend socket internals and several feature implementations were not excerpted; dashed, uncited links mark relationships documented as capabilities but not verified in source.

Main entry points: [`apps/http-server-Be/src/controllers/message.controller.ts`](https://github.com/barmanji/threadly/blob/main/apps/http-server-Be/src/controllers/message.controller.ts) (Message handlers), [`apps/http-server-Be/src/socket/socket.ts`](https://github.com/barmanji/threadly/blob/main/apps/http-server-Be/src/socket/socket.ts) (Socket services), [`apps/http-server-Be/src/models/chat/chat.model.ts`](https://github.com/barmanji/threadly/blob/main/apps/http-server-Be/src/models/chat/chat.model.ts) (Chat records), [`apps/http-server-Be/src/models/chat/message.model.ts`](https://github.com/barmanji/threadly/blob/main/apps/http-server-Be/src/models/chat/message.model.ts) (Message records)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_app["App routes<br/>[App.tsx]"]
  node_chatpage["Chat workspace<br/>[chat.tsx]"]
  node_theme["Theme preferences<br/>[ThemeContext.tsx]"]
  node_changelog["Release notes<br/>[changelog.tsx]"]
end

subgraph group_identity["Accounts"]
  node_authui["Auth state<br/>[AuthContext.tsx]"]
  node_authapi["Auth API<br/>[index.ts]"]
  node_usercontroller["Account handlers<br/>[user.controller.ts]"]
  node_userroute["Account routes<br/>[user.routes.ts]"]
  node_verification["Email verification"]
end

subgraph group_conversation["Chat and media"]
  node_chatapi["Chat API handlers<br/>[chat.controller.ts]"]
  node_chatroute["Chat routes<br/>[chat.routes.ts]"]
  node_messageapi["Message handlers"]
  node_messageroute["Message routes<br/>[message.routes.ts]"]
  node_upload["Cloud file storage"]
  node_callhistory["Call history<br/>[callLog.service.ts]"]
end

subgraph group_realtime["Live collaboration"]
  node_socketclient["Socket connection<br/>[SocketContext.tsx]"]
  node_socketserver["Socket services<br/>[socket.ts]"]
  node_p2pcall["1:1 calling<br/>[CallModal.tsx]"]
  node_groupcall["Group calling"]
  node_sfu["Mediasoup SFU<br/>[mediasoup.ts]"]
  node_whiteboard["Collaborative board<br/>[WhiteBoard.tsx]"]
end

subgraph group_persistence["Backend and state"]
  node_userstore[("User records<br/>[user.model.ts]")]
  node_chatstore[("Chat records<br/>[chat.model.ts]")]
  node_messagestore[("Message records<br/>[message.model.ts]")]
  node_server["HTTP and socket app<br/>[app.ts]"]
end

node_visitor(("User"))
node_mongo[("MongoDB")]
node_cloudinary[("Cloudinary")]
node_resend["Resend email"]

node_visitor -->|"opens"| node_app
node_app -->|"checks session"| node_authui
node_app -->|"routes to"| node_chatpage
node_visitor -.->|"signs in"| node_authui
node_authui -->|"requests auth"| node_authapi
node_authapi -.->|"calls endpoints"| node_userroute
node_userroute -->|"dispatches"| node_usercontroller
node_usercontroller -->|"issues codes"| node_verification
node_verification -->|"updates account"| node_userstore
node_verification -->|"emails code"| node_resend
node_usercontroller -->|"reads and writes"| node_userstore
node_chatpage -.->|"uses chat"| node_chatapi
node_chatroute -->|"dispatches"| node_chatapi
node_chatpage -.->|"sends messages"| node_messageapi
node_messageroute -->|"dispatches"| node_messageapi
node_chatapi -->|"reads and writes"| node_chatstore
node_chatapi -->|"manages messages"| node_messagestore
node_messageapi -->|"updates chat"| node_chatstore
node_messageapi -->|"stores messages"| node_messagestore
node_messageapi -->|"uploads attachments"| node_upload
node_upload -.->|"stores files"| node_cloudinary
node_chatpage -.->|"opens live channel"| node_socketclient
node_socketclient -->|"connects"| node_socketserver
node_server -->|"hosts sockets"| node_socketserver
node_socketserver -.->|"persists messages"| node_messagestore
node_socketserver -.->|"updates last message"| node_chatstore
node_p2pcall -->|"signals peers"| node_socketclient
node_visitor -.->|"starts call"| node_p2pcall
node_visitor -.->|"joins group call"| node_groupcall
node_groupcall -->|"coordinates call"| node_socketclient
node_groupcall -.->|"uses SFU"| node_sfu
node_visitor -.->|"collaborates"| node_whiteboard
node_whiteboard -.->|"syncs scene"| node_socketserver
node_callhistory -->|"updates conversation"| node_chatstore
node_callhistory -->|"records call message"| node_messagestore
node_visitor -.->|"changes appearance"| node_theme
node_visitor -->|"reads releases"| node_changelog
node_chatstore -.->|"persists"| node_mongo
node_messagestore -.->|"persists"| node_mongo
node_userstore -.->|"persists"| node_mongo

click node_app "https://github.com/barmanji/threadly/blob/main/apps/react-Fe/src/App.tsx"
click node_chatpage "https://github.com/barmanji/threadly/blob/main/apps/react-Fe/src/pages/chat.tsx"
click node_authui "https://github.com/barmanji/threadly/blob/main/apps/react-Fe/src/context/AuthContext.tsx"
click node_authapi "https://github.com/barmanji/threadly/blob/main/apps/react-Fe/src/api/index.ts"
click node_usercontroller "https://github.com/barmanji/threadly/blob/main/apps/http-server-Be/src/controllers/user.controller.ts"
click node_userroute "https://github.com/barmanji/threadly/blob/main/apps/http-server-Be/src/routes/user.routes.ts"
click node_verification "https://github.com/barmanji/threadly/blob/main/apps/http-server-Be/src/services/emailVerification.service.ts"
click node_userstore "https://github.com/barmanji/threadly/blob/main/apps/http-server-Be/src/models/user/user.model.ts"
click node_chatapi "https://github.com/barmanji/threadly/blob/main/apps/http-server-Be/src/controllers/chat.controller.ts"
click node_chatroute "https://github.com/barmanji/threadly/blob/main/apps/http-server-Be/src/routes/chat.routes.ts"
click node_messageapi "https://github.com/barmanji/threadly/blob/main/apps/http-server-Be/src/controllers/message.controller.ts"
click node_messageroute "https://github.com/barmanji/threadly/blob/main/apps/http-server-Be/src/routes/message.routes.ts"
click node_chatstore "https://github.com/barmanji/threadly/blob/main/apps/http-server-Be/src/models/chat/chat.model.ts"
click node_messagestore "https://github.com/barmanji/threadly/blob/main/apps/http-server-Be/src/models/chat/message.model.ts"
click node_upload "https://github.com/barmanji/threadly/blob/main/apps/http-server-Be/src/utils/fileUploaderCloudinary.ts"
click node_socketclient "https://github.com/barmanji/threadly/blob/main/apps/react-Fe/src/context/SocketContext.tsx"
click node_socketserver "https://github.com/barmanji/threadly/blob/main/apps/http-server-Be/src/socket/socket.ts"
click node_p2pcall "https://github.com/barmanji/threadly/blob/main/apps/react-Fe/src/components/call/CallModal.tsx"
click node_groupcall "https://github.com/barmanji/threadly/blob/main/apps/react-Fe/src/context/GroupCallContext.tsx"
click node_sfu "https://github.com/barmanji/threadly/blob/main/apps/http-server-Be/src/socket/mediasoup.ts"
click node_whiteboard "https://github.com/barmanji/threadly/blob/main/apps/react-Fe/src/components/WhiteBoard.tsx"
click node_callhistory "https://github.com/barmanji/threadly/blob/main/apps/http-server-Be/src/services/callLog.service.ts"
click node_theme "https://github.com/barmanji/threadly/blob/main/apps/react-Fe/src/context/ThemeContext.tsx"
click node_changelog "https://github.com/barmanji/threadly/blob/main/apps/react-Fe/src/pages/changelog.tsx"
click node_server "https://github.com/barmanji/threadly/blob/main/apps/http-server-Be/src/app.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_app,node_chatpage,node_theme,node_changelog,node_visitor toneBlue
class node_authui,node_authapi,node_usercontroller,node_userroute,node_verification,node_mongo,node_cloudinary toneAmber
class node_chatapi,node_chatroute,node_messageapi,node_messageroute,node_upload,node_callhistory toneMint
class node_socketclient,node_socketserver,node_p2pcall,node_groupcall,node_sfu,node_whiteboard toneRose
class node_userstore,node_chatstore,node_messagestore,node_server,node_resend toneIndigo
```

## Components

### Web client

- [App routes](https://github.com/barmanji/threadly/blob/main/apps/react-Fe/src/App.tsx): `apps/react-Fe/src/App.tsx`
- [Chat workspace](https://github.com/barmanji/threadly/blob/main/apps/react-Fe/src/pages/chat.tsx): `apps/react-Fe/src/pages/chat.tsx`
- [Theme preferences](https://github.com/barmanji/threadly/blob/main/apps/react-Fe/src/context/ThemeContext.tsx): `apps/react-Fe/src/context/ThemeContext.tsx`
- [Release notes](https://github.com/barmanji/threadly/blob/main/apps/react-Fe/src/pages/changelog.tsx): `apps/react-Fe/src/pages/changelog.tsx`

### Accounts

- [Auth state](https://github.com/barmanji/threadly/blob/main/apps/react-Fe/src/context/AuthContext.tsx): `apps/react-Fe/src/context/AuthContext.tsx`
- [Auth API](https://github.com/barmanji/threadly/blob/main/apps/react-Fe/src/api/index.ts): `apps/react-Fe/src/api/index.ts`
- [Account handlers](https://github.com/barmanji/threadly/blob/main/apps/http-server-Be/src/controllers/user.controller.ts): `apps/http-server-Be/src/controllers/user.controller.ts`
- [Account routes](https://github.com/barmanji/threadly/blob/main/apps/http-server-Be/src/routes/user.routes.ts): `apps/http-server-Be/src/routes/user.routes.ts`
- [Email verification](https://github.com/barmanji/threadly/blob/main/apps/http-server-Be/src/services/emailVerification.service.ts): `apps/http-server-Be/src/services/emailVerification.service.ts`

### Chat and media

- [Chat API handlers](https://github.com/barmanji/threadly/blob/main/apps/http-server-Be/src/controllers/chat.controller.ts): `apps/http-server-Be/src/controllers/chat.controller.ts`
- [Chat routes](https://github.com/barmanji/threadly/blob/main/apps/http-server-Be/src/routes/chat.routes.ts): `apps/http-server-Be/src/routes/chat.routes.ts`
- [Message handlers](https://github.com/barmanji/threadly/blob/main/apps/http-server-Be/src/controllers/message.controller.ts): `apps/http-server-Be/src/controllers/message.controller.ts`
- [Message routes](https://github.com/barmanji/threadly/blob/main/apps/http-server-Be/src/routes/message.routes.ts): `apps/http-server-Be/src/routes/message.routes.ts`
- [Cloud file storage](https://github.com/barmanji/threadly/blob/main/apps/http-server-Be/src/utils/fileUploaderCloudinary.ts): `apps/http-server-Be/src/utils/fileUploaderCloudinary.ts`
- [Call history](https://github.com/barmanji/threadly/blob/main/apps/http-server-Be/src/services/callLog.service.ts): `apps/http-server-Be/src/services/callLog.service.ts`

### Live collaboration

- [Socket connection](https://github.com/barmanji/threadly/blob/main/apps/react-Fe/src/context/SocketContext.tsx): `apps/react-Fe/src/context/SocketContext.tsx`
- [Socket services](https://github.com/barmanji/threadly/blob/main/apps/http-server-Be/src/socket/socket.ts): `apps/http-server-Be/src/socket/socket.ts`
- [1:1 calling](https://github.com/barmanji/threadly/blob/main/apps/react-Fe/src/components/call/CallModal.tsx): `apps/react-Fe/src/components/call/CallModal.tsx`
- [Group calling](https://github.com/barmanji/threadly/blob/main/apps/react-Fe/src/context/GroupCallContext.tsx): `apps/react-Fe/src/context/GroupCallContext.tsx`
- [Mediasoup SFU](https://github.com/barmanji/threadly/blob/main/apps/http-server-Be/src/socket/mediasoup.ts): `apps/http-server-Be/src/socket/mediasoup.ts`
- [Collaborative board](https://github.com/barmanji/threadly/blob/main/apps/react-Fe/src/components/WhiteBoard.tsx): `apps/react-Fe/src/components/WhiteBoard.tsx`

### Backend and state

- [User records](https://github.com/barmanji/threadly/blob/main/apps/http-server-Be/src/models/user/user.model.ts): `apps/http-server-Be/src/models/user/user.model.ts`
- [Chat records](https://github.com/barmanji/threadly/blob/main/apps/http-server-Be/src/models/chat/chat.model.ts): `apps/http-server-Be/src/models/chat/chat.model.ts`
- [Message records](https://github.com/barmanji/threadly/blob/main/apps/http-server-Be/src/models/chat/message.model.ts): `apps/http-server-Be/src/models/chat/message.model.ts`
- [HTTP and socket app](https://github.com/barmanji/threadly/blob/main/apps/http-server-Be/src/app.ts): `apps/http-server-Be/src/app.ts`

### Other components

- **User**
- **MongoDB**
- **Cloudinary**
- **Resend email**

## Connections

- User → App routes: opens (evidence: `apps/react-Fe/src/App.tsx`)
- App routes → Auth state: checks session (evidence: `apps/react-Fe/src/App.tsx`)
- App routes → Chat workspace: routes to (evidence: `apps/react-Fe/src/App.tsx`)
- User → Auth state: signs in (evidence: `README.md`)
- Auth state → Auth API: requests auth (evidence: `apps/react-Fe/src/context/AuthContext.tsx`)
- Auth API → Account routes: calls endpoints
- Account routes → Account handlers: dispatches (evidence: `apps/http-server-Be/src/routes/user.routes.ts`)
- Account handlers → Email verification: issues codes (evidence: `apps/http-server-Be/src/controllers/user.controller.ts`)
- Email verification → User records: updates account (evidence: `apps/http-server-Be/src/services/emailVerification.service.ts`)
- Email verification → Resend email: emails code (evidence: `apps/http-server-Be/src/services/emailVerification.service.ts`)
- Account handlers → User records: reads and writes (evidence: `apps/http-server-Be/src/controllers/user.controller.ts`)
- Chat workspace → Chat API handlers: uses chat
- Chat routes → Chat API handlers: dispatches (evidence: `apps/http-server-Be/src/routes/chat.routes.ts`)
- Chat workspace → Message handlers: sends messages
- Message routes → Message handlers: dispatches (evidence: `apps/http-server-Be/src/routes/message.routes.ts`)
- Chat API handlers → Chat records: reads and writes (evidence: `apps/http-server-Be/src/controllers/chat.controller.ts`)
- Chat API handlers → Message records: manages messages (evidence: `apps/http-server-Be/src/controllers/chat.controller.ts`)
- Message handlers → Chat records: updates chat (evidence: `apps/http-server-Be/src/controllers/message.controller.ts`)
- Message handlers → Message records: stores messages (evidence: `apps/http-server-Be/src/controllers/message.controller.ts`)
- Message handlers → Cloud file storage: uploads attachments (evidence: `apps/http-server-Be/src/controllers/message.controller.ts`)
- Cloud file storage → Cloudinary: stores files
- Chat workspace → Socket connection: opens live channel
- Socket connection → Socket services: connects (evidence: `apps/react-Fe/src/context/SocketContext.tsx`)
- HTTP and socket app → Socket services: hosts sockets (evidence: `apps/http-server-Be/src/app.ts`)
- Socket services → Message records: persists messages (evidence: `README.md`)
- Socket services → Chat records: updates last message (evidence: `README.md`)
- 1:1 calling → Socket connection: signals peers (evidence: `apps/react-Fe/src/components/call/CallModal.tsx`)
- User → 1:1 calling: starts call (evidence: `README.md`)
- User → Group calling: joins group call (evidence: `README.md`)
- Group calling → Socket connection: coordinates call (evidence: `apps/react-Fe/src/context/GroupCallContext.tsx`)
- Group calling → Mediasoup SFU: uses SFU (evidence: `README.md`)
- User → Collaborative board: collaborates (evidence: `README.md`)
- Collaborative board → Socket services: syncs scene (evidence: `README.md`)
- Call history → Chat records: updates conversation (evidence: `apps/http-server-Be/src/services/callLog.service.ts`)
- Call history → Message records: records call message (evidence: `apps/http-server-Be/src/services/callLog.service.ts`)
- User → Theme preferences: changes appearance (evidence: `README.md`)
- User → Release notes: reads releases
- Chat records → MongoDB: persists
- Message records → MongoDB: persists
- User records → MongoDB: persists
