# ohlesl1e/unfriendly-chat architecture

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

- Interactive diagram: https://gitdiagram.com/ohlesl1e/unfriendly-chat
- Repository: https://github.com/ohlesl1e/unfriendly-chat

## Overview

Unfriendly Chat is a browser-based private messaging application. Users register or log in, create Signal-protocol key material, find or open a room, establish an encrypted session, and exchange ciphertext over Socket.IO; room and account data are served through REST endpoints. The map separates browser flows, cryptographic state, server routes, and persistence. Home and some client behavior are represented from the documented frontend structure and source index; their detailed interactions were not sampled, so no unverified calls are asserted.

Main entry points: [`application/client/src/pages/Room.jsx`](https://github.com/ohlesl1e/unfriendly-chat/blob/main/application/client/src/pages/Room.jsx) (Chat room), [`application/server/routes/auth.js`](https://github.com/ohlesl1e/unfriendly-chat/blob/main/application/server/routes/auth.js) (Authentication routes), [`application/client/src/App.jsx`](https://github.com/ohlesl1e/unfriendly-chat/blob/main/application/client/src/App.jsx) (App and routing), [`application/client/src/pages/Login.jsx`](https://github.com/ohlesl1e/unfriendly-chat/blob/main/application/client/src/pages/Login.jsx) (Login)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Browser application"]
  node_entry["Client bootstrap<br/>[main.jsx]"]
  node_app["App and routing<br/>[App.jsx]"]
  node_home["Home and rooms<br/>[Home.jsx]"]
  node_login["Login<br/>[Login.jsx]"]
  node_signup["Signup<br/>[Signup.jsx]"]
  node_room["Chat room<br/>[Room.jsx]"]
  node_messageview["Message view<br/>[Message.jsx]"]
  node_resize["Window sizing<br/>[resize.js]"]
end

subgraph group_crypto["Encryption and session state"]
  node_signalstore[("Signal key store<br/>[store.js]")]
  node_signalstate["Signal store instance<br/>[state.js]"]
  node_signal["Signal protocol library"]
end

subgraph group_server["Backend services"]
  node_gateway["Express gateway<br/>[index.js]"]
  node_auth["Authentication routes<br/>[auth.js]"]
  node_validation["Input sanitization"]
  node_roomapi["Room REST and sockets<br/>[message.js]"]
end

subgraph group_persistence["Persistence"]
  node_mongo[("MongoDB")]
  node_sessions[("Session store<br/>[index.js]")]
end

node_user(("Chat user"))

node_user -->|"uses"| node_entry
node_entry -->|"renders"| node_app
node_app -->|"routes to"| node_home
node_app -->|"routes to"| node_login
node_app -->|"routes to"| node_signup
node_app -->|"routes to"| node_room
node_login -->|"posts credentials"| node_auth
node_signup -->|"registers account"| node_auth
node_login -->|"generates keys"| node_signal
node_signup -->|"generates keys"| node_signal
node_login -->|"stores key material"| node_signalstore
node_app -->|"loads persisted keys"| node_signalstate
node_signalstate -->|"exports instance"| node_signalstore
node_room -->|"encrypts and decrypts"| node_signal
node_room -->|"uses session state"| node_signalstore
node_room -->|"requests room data"| node_roomapi
node_room -->|"emits ciphertext"| node_roomapi
node_roomapi -->|"broadcasts ciphertext"| node_room
node_room -->|"reads window size"| node_resize
node_room -->|"renders messages"| node_messageview
node_gateway -->|"mounts routes"| node_auth
node_gateway -->|"mounts routes"| node_roomapi
node_auth -->|"sanitizes username"| node_validation
node_auth -->|"reads and writes users"| node_mongo
node_roomapi -->|"reads and writes rooms"| node_mongo
node_gateway -->|"configures sessions"| node_sessions
node_sessions -->|"stores sessions"| node_mongo
node_auth -->|"returns account session"| node_login
node_auth -->|"returns account session"| node_signup

click node_entry "https://github.com/ohlesl1e/unfriendly-chat/blob/main/application/client/src/main.jsx"
click node_app "https://github.com/ohlesl1e/unfriendly-chat/blob/main/application/client/src/App.jsx"
click node_home "https://github.com/ohlesl1e/unfriendly-chat/blob/main/application/client/src/pages/Home.jsx"
click node_login "https://github.com/ohlesl1e/unfriendly-chat/blob/main/application/client/src/pages/Login.jsx"
click node_signup "https://github.com/ohlesl1e/unfriendly-chat/blob/main/application/client/src/pages/Signup.jsx"
click node_room "https://github.com/ohlesl1e/unfriendly-chat/blob/main/application/client/src/pages/Room.jsx"
click node_messageview "https://github.com/ohlesl1e/unfriendly-chat/blob/main/application/client/src/components/Message.jsx"
click node_resize "https://github.com/ohlesl1e/unfriendly-chat/blob/main/application/client/src/components/resize.js"
click node_signalstore "https://github.com/ohlesl1e/unfriendly-chat/blob/main/application/client/src/signal/store.js"
click node_signalstate "https://github.com/ohlesl1e/unfriendly-chat/blob/main/application/client/src/signal/state.js"
click node_gateway "https://github.com/ohlesl1e/unfriendly-chat/blob/main/application/server/index.js"
click node_auth "https://github.com/ohlesl1e/unfriendly-chat/blob/main/application/server/routes/auth.js"
click node_validation "https://github.com/ohlesl1e/unfriendly-chat/blob/main/application/server/util/input_validation.js"
click node_roomapi "https://github.com/ohlesl1e/unfriendly-chat/blob/main/application/server/routes/message.js"
click node_sessions "https://github.com/ohlesl1e/unfriendly-chat/blob/main/application/server/index.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_entry,node_app,node_home,node_login,node_signup,node_room,node_messageview,node_resize,node_user toneBlue
class node_signalstore,node_signalstate,node_signal toneAmber
class node_gateway,node_auth,node_validation,node_roomapi toneMint
class node_mongo,node_sessions toneRose
```

## Components

### Browser application

- [Client bootstrap](https://github.com/ohlesl1e/unfriendly-chat/blob/main/application/client/src/main.jsx): `application/client/src/main.jsx`
- [App and routing](https://github.com/ohlesl1e/unfriendly-chat/blob/main/application/client/src/App.jsx): `application/client/src/App.jsx`
- [Home and rooms](https://github.com/ohlesl1e/unfriendly-chat/blob/main/application/client/src/pages/Home.jsx): `application/client/src/pages/Home.jsx`
- [Login](https://github.com/ohlesl1e/unfriendly-chat/blob/main/application/client/src/pages/Login.jsx): `application/client/src/pages/Login.jsx`
- [Signup](https://github.com/ohlesl1e/unfriendly-chat/blob/main/application/client/src/pages/Signup.jsx): `application/client/src/pages/Signup.jsx`
- [Chat room](https://github.com/ohlesl1e/unfriendly-chat/blob/main/application/client/src/pages/Room.jsx): `application/client/src/pages/Room.jsx`
- [Message view](https://github.com/ohlesl1e/unfriendly-chat/blob/main/application/client/src/components/Message.jsx): `application/client/src/components/Message.jsx`
- [Window sizing](https://github.com/ohlesl1e/unfriendly-chat/blob/main/application/client/src/components/resize.js): `application/client/src/components/resize.js`

### Encryption and session state

- [Signal key store](https://github.com/ohlesl1e/unfriendly-chat/blob/main/application/client/src/signal/store.js): `application/client/src/signal/store.js`
- [Signal store instance](https://github.com/ohlesl1e/unfriendly-chat/blob/main/application/client/src/signal/state.js): `application/client/src/signal/state.js`
- **Signal protocol library**

### Backend services

- [Express gateway](https://github.com/ohlesl1e/unfriendly-chat/blob/main/application/server/index.js): `application/server/index.js`
- [Authentication routes](https://github.com/ohlesl1e/unfriendly-chat/blob/main/application/server/routes/auth.js): `application/server/routes/auth.js`
- [Input sanitization](https://github.com/ohlesl1e/unfriendly-chat/blob/main/application/server/util/input_validation.js): `application/server/util/input_validation.js`
- [Room REST and sockets](https://github.com/ohlesl1e/unfriendly-chat/blob/main/application/server/routes/message.js): `application/server/routes/message.js`

### Persistence

- **MongoDB**
- [Session store](https://github.com/ohlesl1e/unfriendly-chat/blob/main/application/server/index.js): `application/server/index.js`

### Other components

- **Chat user**

## Connections

- Chat user → Client bootstrap: uses (evidence: `application/client/src/main.jsx`)
- Client bootstrap → App and routing: renders (evidence: `application/client/src/main.jsx`)
- App and routing → Home and rooms: routes to (evidence: `application/client/src/App.jsx`)
- App and routing → Login: routes to (evidence: `application/client/src/App.jsx`)
- App and routing → Signup: routes to (evidence: `application/client/src/App.jsx`)
- App and routing → Chat room: routes to (evidence: `application/client/src/App.jsx`)
- Login → Authentication routes: posts credentials (evidence: `application/client/src/pages/Login.jsx`)
- Signup → Authentication routes: registers account (evidence: `application/client/src/pages/Signup.jsx`)
- Login → Signal protocol library: generates keys (evidence: `application/client/src/pages/Login.jsx`)
- Signup → Signal protocol library: generates keys (evidence: `application/client/src/pages/Signup.jsx`)
- Login → Signal key store: stores key material (evidence: `application/client/src/pages/Login.jsx`)
- App and routing → Signal store instance: loads persisted keys (evidence: `application/client/src/App.jsx`)
- Signal store instance → Signal key store: exports instance (evidence: `application/client/src/signal/state.js`)
- Chat room → Signal protocol library: encrypts and decrypts (evidence: `application/client/src/pages/Room.jsx`)
- Chat room → Signal key store: uses session state (evidence: `application/client/src/pages/Room.jsx`)
- Chat room → Room REST and sockets: requests room data (evidence: `application/client/src/pages/Room.jsx`)
- Chat room → Room REST and sockets: emits ciphertext (evidence: `application/client/src/pages/Room.jsx`)
- Room REST and sockets → Chat room: broadcasts ciphertext (evidence: `application/server/routes/message.js`)
- Chat room → Window sizing: reads window size (evidence: `application/client/src/pages/Room.jsx`)
- Chat room → Message view: renders messages (evidence: `application/client/src/pages/Room.jsx`)
- Express gateway → Authentication routes: mounts routes (evidence: `application/server/index.js`)
- Express gateway → Room REST and sockets: mounts routes (evidence: `application/server/index.js`)
- Authentication routes → Input sanitization: sanitizes username (evidence: `application/server/routes/auth.js`)
- Authentication routes → MongoDB: reads and writes users (evidence: `application/server/routes/auth.js`)
- Room REST and sockets → MongoDB: reads and writes rooms (evidence: `application/server/routes/message.js`)
- Express gateway → Session store: configures sessions (evidence: `application/server/index.js`)
- Session store → MongoDB: stores sessions (evidence: `application/server/index.js`)
- Authentication routes → Login: returns account session (evidence: `application/client/src/pages/Login.jsx`)
- Authentication routes → Signup: returns account session (evidence: `application/client/src/pages/Signup.jsx`)
