# 21nayan/chatsphere-frontend architecture

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

- Interactive diagram: https://gitdiagram.com/21nayan/chatsphere-frontend
- Repository: https://github.com/21nayan/chatsphere-frontend

## Overview

ChatSphere is a React real-time chat frontend. Users authenticate, enter the chat workspace, select a room or direct conversation, load history, and exchange messages over REST and STOMP/SockJS. The workspace also supports group and contact management, online presence, profiles, pinned chats, and customizable themes. The graph follows documented and indexed component relationships; several feature implementations and routing details are unsampled, so uncertain links are omitted.

Main entry points: [`src/pages/ChatPage.jsx`](https://github.com/21nayan/chatsphere-frontend/blob/main/src/pages/ChatPage.jsx) (Chat workspace), [`src/services/api.js`](https://github.com/21nayan/chatsphere-frontend/blob/main/src/services/api.js) (REST client), [`src/components/ChatWindow.jsx`](https://github.com/21nayan/chatsphere-frontend/blob/main/src/components/ChatWindow.jsx) (Conversation window), [`src/App.jsx`](https://github.com/21nayan/chatsphere-frontend/blob/main/src/App.jsx) (Application router)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["App and identity"]
  node_app["Application router<br/>[App.jsx]"]
  node_authpages["Sign in and recovery<br/>[LoginPage.jsx]"]
  node_register["Registration<br/>[RegisterPage.jsx]"]
  node_auth["Session context<br/>[AuthContext.jsx]"]
end

subgraph group_messaging["Chat workspace"]
  node_workspace["Chat workspace<br/>[ChatPage.jsx]"]
  node_rooms["Room and DM navigation<br/>[RoomList.jsx]"]
  node_chatwindow["Conversation window<br/>[ChatWindow.jsx]"]
  node_messageui["Messages and composer<br/>[Chat.jsx]"]
  node_voice["Voice messages<br/>[VoiceMessage.jsx]"]
  node_online["Online presence panel<br/>[OnlineUsers.jsx]"]
end

subgraph group_management["People and groups"]
  node_contacts["Contact management"]
  node_newdm["New direct message<br/>[NewDMModal.jsx]"]
  node_groups["Group creation<br/>[GroupModal.jsx]"]
  node_groupinfo["Group administration<br/>[GroupInfoPanel.jsx]"]
end

subgraph group_preferences["Profile and themes"]
  node_profile["Profile settings<br/>[ProfilePage.jsx]"]
  node_themeui["Theme controls<br/>[ThemePanel.jsx]"]
  node_theme["Theme state<br/>[ThemeContext.jsx]"]
end

subgraph group_integration["Backend services"]
  node_api["REST client<br/>[api.js]"]
  node_websocket["STOMP connection<br/>[websocket.js]"]
end

node_user(("Chat user"))
node_backend[("ChatSphere backend")]

node_user -->|"opens app"| node_app
node_app -->|"routes unauthenticated"| node_authpages
node_app -->|"routes authenticated"| node_workspace
node_authpages -.->|"authenticates"| node_auth
node_register -->|"creates session"| node_auth
node_auth -->|"marks presence"| node_api
node_workspace -->|"renders"| node_rooms
node_workspace -->|"renders"| node_chatwindow
node_workspace -->|"renders"| node_online
node_workspace -->|"opens"| node_contacts
node_workspace -->|"opens"| node_groups
node_workspace -->|"renders"| node_groupinfo
node_workspace -->|"opens"| node_profile
node_workspace -->|"opens"| node_themeui
node_rooms -->|"opens"| node_newdm
node_chatwindow -->|"renders"| node_messageui
node_chatwindow -->|"loads and sends"| node_api
node_chatwindow -->|"sends typing"| node_websocket
node_messageui -.->|"supports recording"| node_voice
node_workspace -->|"loads workspace data"| node_api
node_workspace -.->|"connects presence"| node_websocket
node_groupinfo -->|"updates membership"| node_api
node_profile -->|"updates profile"| node_api
node_themeui -->|"sets preferences"| node_theme
node_theme -->|"applies appearance"| node_user
node_api -->|"calls REST endpoints"| node_backend
node_websocket -->|"connects and exchanges"| node_backend

click node_app "https://github.com/21nayan/chatsphere-frontend/blob/main/src/App.jsx"
click node_authpages "https://github.com/21nayan/chatsphere-frontend/blob/main/src/pages/LoginPage.jsx"
click node_register "https://github.com/21nayan/chatsphere-frontend/blob/main/src/pages/RegisterPage.jsx"
click node_auth "https://github.com/21nayan/chatsphere-frontend/blob/main/src/context/AuthContext.jsx"
click node_workspace "https://github.com/21nayan/chatsphere-frontend/blob/main/src/pages/ChatPage.jsx"
click node_rooms "https://github.com/21nayan/chatsphere-frontend/blob/main/src/components/RoomList.jsx"
click node_chatwindow "https://github.com/21nayan/chatsphere-frontend/blob/main/src/components/ChatWindow.jsx"
click node_messageui "https://github.com/21nayan/chatsphere-frontend/blob/main/src/components/Chat.jsx"
click node_voice "https://github.com/21nayan/chatsphere-frontend/blob/main/src/components/VoiceMessage.jsx"
click node_online "https://github.com/21nayan/chatsphere-frontend/blob/main/src/components/OnlineUsers.jsx"
click node_contacts "https://github.com/21nayan/chatsphere-frontend/blob/main/src/components/AddContactModal.jsx"
click node_newdm "https://github.com/21nayan/chatsphere-frontend/blob/main/src/components/NewDMModal.jsx"
click node_groups "https://github.com/21nayan/chatsphere-frontend/blob/main/src/components/GroupModal.jsx"
click node_groupinfo "https://github.com/21nayan/chatsphere-frontend/blob/main/src/components/GroupInfoPanel.jsx"
click node_profile "https://github.com/21nayan/chatsphere-frontend/blob/main/src/pages/ProfilePage.jsx"
click node_themeui "https://github.com/21nayan/chatsphere-frontend/blob/main/src/components/ThemePanel.jsx"
click node_theme "https://github.com/21nayan/chatsphere-frontend/blob/main/src/context/ThemeContext.jsx"
click node_api "https://github.com/21nayan/chatsphere-frontend/blob/main/src/services/api.js"
click node_websocket "https://github.com/21nayan/chatsphere-frontend/blob/main/src/services/websocket.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_authpages,node_register,node_auth,node_user toneBlue
class node_workspace,node_rooms,node_chatwindow,node_messageui,node_voice,node_online,node_backend toneAmber
class node_contacts,node_newdm,node_groups,node_groupinfo toneMint
class node_profile,node_themeui,node_theme toneRose
class node_api,node_websocket toneIndigo
```

## Components

### App and identity

- [Application router](https://github.com/21nayan/chatsphere-frontend/blob/main/src/App.jsx): `src/App.jsx`
- [Sign in and recovery](https://github.com/21nayan/chatsphere-frontend/blob/main/src/pages/LoginPage.jsx): `src/pages/LoginPage.jsx`
- [Registration](https://github.com/21nayan/chatsphere-frontend/blob/main/src/pages/RegisterPage.jsx): `src/pages/RegisterPage.jsx`
- [Session context](https://github.com/21nayan/chatsphere-frontend/blob/main/src/context/AuthContext.jsx): `src/context/AuthContext.jsx`

### Chat workspace

- [Chat workspace](https://github.com/21nayan/chatsphere-frontend/blob/main/src/pages/ChatPage.jsx): `src/pages/ChatPage.jsx`
- [Room and DM navigation](https://github.com/21nayan/chatsphere-frontend/blob/main/src/components/RoomList.jsx): `src/components/RoomList.jsx`
- [Conversation window](https://github.com/21nayan/chatsphere-frontend/blob/main/src/components/ChatWindow.jsx): `src/components/ChatWindow.jsx`
- [Messages and composer](https://github.com/21nayan/chatsphere-frontend/blob/main/src/components/Chat.jsx): `src/components/Chat.jsx`
- [Voice messages](https://github.com/21nayan/chatsphere-frontend/blob/main/src/components/VoiceMessage.jsx): `src/components/VoiceMessage.jsx`
- [Online presence panel](https://github.com/21nayan/chatsphere-frontend/blob/main/src/components/OnlineUsers.jsx): `src/components/OnlineUsers.jsx`

### People and groups

- [Contact management](https://github.com/21nayan/chatsphere-frontend/blob/main/src/components/AddContactModal.jsx): `src/components/AddContactModal.jsx`
- [New direct message](https://github.com/21nayan/chatsphere-frontend/blob/main/src/components/NewDMModal.jsx): `src/components/NewDMModal.jsx`
- [Group creation](https://github.com/21nayan/chatsphere-frontend/blob/main/src/components/GroupModal.jsx): `src/components/GroupModal.jsx`
- [Group administration](https://github.com/21nayan/chatsphere-frontend/blob/main/src/components/GroupInfoPanel.jsx): `src/components/GroupInfoPanel.jsx`

### Profile and themes

- [Profile settings](https://github.com/21nayan/chatsphere-frontend/blob/main/src/pages/ProfilePage.jsx): `src/pages/ProfilePage.jsx`
- [Theme controls](https://github.com/21nayan/chatsphere-frontend/blob/main/src/components/ThemePanel.jsx): `src/components/ThemePanel.jsx`
- [Theme state](https://github.com/21nayan/chatsphere-frontend/blob/main/src/context/ThemeContext.jsx): `src/context/ThemeContext.jsx`

### Backend services

- [REST client](https://github.com/21nayan/chatsphere-frontend/blob/main/src/services/api.js): `src/services/api.js`
- [STOMP connection](https://github.com/21nayan/chatsphere-frontend/blob/main/src/services/websocket.js): `src/services/websocket.js`

### Other components

- **Chat user**
- **ChatSphere backend**

## Connections

- Chat user → Application router: opens app (evidence: `README.md`)
- Application router → Sign in and recovery: routes unauthenticated (evidence: `README.md`)
- Application router → Chat workspace: routes authenticated (evidence: `README.md`)
- Sign in and recovery → Session context: authenticates
- Registration → Session context: creates session (evidence: `src/pages/RegisterPage.jsx`)
- Session context → REST client: marks presence (evidence: `src/context/AuthContext.jsx`)
- Chat workspace → Room and DM navigation: renders (evidence: `src/pages/ChatPage.jsx`)
- Chat workspace → Conversation window: renders (evidence: `src/pages/ChatPage.jsx`)
- Chat workspace → Online presence panel: renders (evidence: `src/pages/ChatPage.jsx`)
- Chat workspace → Contact management: opens (evidence: `src/pages/ChatPage.jsx`)
- Chat workspace → Group creation: opens (evidence: `src/pages/ChatPage.jsx`)
- Chat workspace → Group administration: renders (evidence: `src/pages/ChatPage.jsx`)
- Chat workspace → Profile settings: opens (evidence: `src/pages/ChatPage.jsx`)
- Chat workspace → Theme controls: opens (evidence: `src/pages/ChatPage.jsx`)
- Room and DM navigation → New direct message: opens (evidence: `src/components/RoomList.jsx`)
- Conversation window → Messages and composer: renders (evidence: `src/components/ChatWindow.jsx`)
- Conversation window → REST client: loads and sends (evidence: `src/components/ChatWindow.jsx`)
- Conversation window → STOMP connection: sends typing (evidence: `src/components/ChatWindow.jsx`)
- Messages and composer → Voice messages: supports recording
- Chat workspace → REST client: loads workspace data (evidence: `src/pages/ChatPage.jsx`)
- Chat workspace → STOMP connection: connects presence (evidence: `src/pages/ChatPage.jsx`)
- Group administration → REST client: updates membership (evidence: `src/components/GroupInfoPanel.jsx`)
- Profile settings → REST client: updates profile (evidence: `src/pages/ProfilePage.jsx`)
- Theme controls → Theme state: sets preferences (evidence: `src/components/ThemePanel.jsx`)
- Theme state → Chat user: applies appearance (evidence: `src/context/ThemeContext.jsx`)
- REST client → ChatSphere backend: calls REST endpoints (evidence: `README.md`)
- STOMP connection → ChatSphere backend: connects and exchanges (evidence: `src/services/websocket.js`)
