# akabhishek2316/trusphere-chat-app architecture

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

- Interactive diagram: https://gitdiagram.com/akabhishek2316/trusphere-chat-app
- Repository: https://github.com/akabhishek2316/trusphere-chat-app

## Overview

TruSphere is a React Native messaging app. Users authenticate, browse or find contacts, open a one-to-one chat, and exchange text, image, or voice messages with status, presence, and typing features. The app also supports profiles, privacy and blocking controls, disappearing messages, and push notifications. The README documents Firebase synchronization and a Node.js notification server; sampled source confirms key app-to-service calls, but not every feature’s implementation or the server’s internal dispatch path.

Main entry points: [`src/services/chatService.ts`](https://github.com/akabhishek2316/trusphere-chat-app/blob/main/src/services/chatService.ts) (Chat operations), [`src/screens/ChatListScreen.tsx`](https://github.com/akabhishek2316/trusphere-chat-app/blob/main/src/screens/ChatListScreen.tsx) (Chat list), [`src/services/firebase.ts`](https://github.com/akabhishek2316/trusphere-chat-app/blob/main/src/services/firebase.ts) (Firebase client), [`src/services/userService.ts`](https://github.com/akabhishek2316/trusphere-chat-app/blob/main/src/services/userService.ts) (Profiles and blocks)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App and navigation"]
  node_app["App lifecycle<br/>[App.tsx]"]
  node_navigation["Navigation<br/>[AppNavigator.tsx]"]
end

subgraph group_messaging["Messaging experience"]
  node_chatlist["Chat list<br/>[ChatListScreen.tsx]"]
  node_chat["Chat screen<br/>[ChatScreen.tsx]"]
  node_messagehook["Message sync hook<br/>[useMessages.ts]"]
  node_chatui["Message composer and views<br/>[ChatInput.tsx]"]
  node_imagepreview["Image sharing"]
  node_voice["Voice playback<br/>[VoicePlayer.tsx]"]
end

subgraph group_identity["Identity and controls"]
  node_usersearch["Contact discovery"]
  node_registration["Registration<br/>[RegisterScreen.tsx]"]
  node_auth["Authentication<br/>[authService.ts]"]
  node_profile["Profiles and blocks<br/>[userService.ts]"]
  node_session["Session management<br/>[sessionService.ts]"]
end

subgraph group_services["Realtime services"]
  node_chatservice["Chat operations<br/>[chatService.ts]"]
  node_presence["Presence and typing<br/>[presenceService.ts]"]
  node_typing["Typing state<br/>[typingService.ts]"]
  node_sync["App synchronization"]
  node_firebase["Firebase client<br/>[firebase.ts]"]
  node_database[("Realtime Database")]
end

subgraph group_notifications["Push notifications"]
  node_notifications["Notification service"]
  node_server["Notification server<br/>[index.js]"]
  node_admin["Firebase Admin"]
  node_fcm["Firebase Cloud Messaging"]
end

node_user(("User"))
node_receiver(("Receiver device"))

node_user -->|"uses app"| node_navigation
node_app -->|"renders"| node_navigation
node_navigation -->|"routes to"| node_chatlist
node_navigation -->|"routes to"| node_chat
node_chatlist -->|"loads chats"| node_chatservice
node_chatlist -->|"reads contacts"| node_profile
node_chatlist -->|"reads presence"| node_presence
node_chatlist -->|"reads typing"| node_typing
node_chatlist -->|"sets notifications"| node_notifications
node_chat -->|"loads messages"| node_messagehook
node_chat -->|"manages messages"| node_chatservice
node_chat -->|"renders composer"| node_chatui
node_chatui -->|"updates typing"| node_typing
node_imagepreview -->|"sends image message"| node_chatservice
node_imagepreview -->|"updates message"| node_chatservice
node_voice -.->|"plays voice"| node_user
node_usersearch -->|"searches users"| node_profile
node_usersearch -->|"starts chats"| node_chatservice
node_registration -->|"registers account"| node_auth
node_registration -->|"creates profile"| node_profile
node_auth -->|"deletes session"| node_session
node_app -->|"updates session"| node_session
node_app -->|"starts services"| node_sync
node_app -->|"starts listener"| node_notifications
node_chatservice -->|"checks recipient"| node_profile
node_chatservice -->|"requests push"| node_notifications
node_chatservice -->|"uses database client"| node_firebase
node_messagehook -->|"subscribes messages"| node_chatservice
node_presence -->|"uses database client"| node_firebase
node_typing -->|"uses database client"| node_firebase
node_session -->|"reads and writes"| node_firebase
node_profile -->|"reads and writes"| node_firebase
node_firebase -->|"connects to"| node_database
node_notifications -->|"posts notification"| node_server
node_server -->|"uses Admin SDK"| node_admin
node_admin -->|"sends push"| node_fcm
node_fcm -->|"delivers notification"| node_receiver
node_database -->|"synchronizes messages"| node_sync

click node_app "https://github.com/akabhishek2316/trusphere-chat-app/blob/main/App.tsx"
click node_navigation "https://github.com/akabhishek2316/trusphere-chat-app/blob/main/src/navigation/AppNavigator.tsx"
click node_chatlist "https://github.com/akabhishek2316/trusphere-chat-app/blob/main/src/screens/ChatListScreen.tsx"
click node_chat "https://github.com/akabhishek2316/trusphere-chat-app/blob/main/src/screens/ChatScreen.tsx"
click node_messagehook "https://github.com/akabhishek2316/trusphere-chat-app/blob/main/src/hooks/useMessages.ts"
click node_chatui "https://github.com/akabhishek2316/trusphere-chat-app/blob/main/src/components/ChatInput.tsx"
click node_imagepreview "https://github.com/akabhishek2316/trusphere-chat-app/blob/main/src/screens/ImagePreviewScreen.tsx"
click node_voice "https://github.com/akabhishek2316/trusphere-chat-app/blob/main/src/components/VoicePlayer.tsx"
click node_chatservice "https://github.com/akabhishek2316/trusphere-chat-app/blob/main/src/services/chatService.ts"
click node_usersearch "https://github.com/akabhishek2316/trusphere-chat-app/blob/main/src/screens/SearchUserScreen.tsx"
click node_registration "https://github.com/akabhishek2316/trusphere-chat-app/blob/main/src/screens/RegisterScreen.tsx"
click node_auth "https://github.com/akabhishek2316/trusphere-chat-app/blob/main/src/services/authService.ts"
click node_profile "https://github.com/akabhishek2316/trusphere-chat-app/blob/main/src/services/userService.ts"
click node_session "https://github.com/akabhishek2316/trusphere-chat-app/blob/main/src/services/sessionService.ts"
click node_presence "https://github.com/akabhishek2316/trusphere-chat-app/blob/main/src/services/presenceService.ts"
click node_typing "https://github.com/akabhishek2316/trusphere-chat-app/blob/main/src/services/typingService.ts"
click node_sync "https://github.com/akabhishek2316/trusphere-chat-app/blob/main/src/services/messageSyncService.ts"
click node_firebase "https://github.com/akabhishek2316/trusphere-chat-app/blob/main/src/services/firebase.ts"
click node_notifications "https://github.com/akabhishek2316/trusphere-chat-app/blob/main/src/services/notificationService.ts"
click node_server "https://github.com/akabhishek2316/trusphere-chat-app/blob/main/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_app,node_navigation,node_user toneBlue
class node_chatlist,node_chat,node_messagehook,node_chatui,node_imagepreview,node_voice toneAmber
class node_usersearch,node_registration,node_auth,node_profile,node_session toneMint
class node_chatservice,node_presence,node_typing,node_sync,node_firebase,node_database toneRose
class node_notifications,node_server,node_admin,node_fcm,node_receiver toneIndigo
```

## Components

### App and navigation

- [App lifecycle](https://github.com/akabhishek2316/trusphere-chat-app/blob/main/App.tsx): `App.tsx`
- [Navigation](https://github.com/akabhishek2316/trusphere-chat-app/blob/main/src/navigation/AppNavigator.tsx): `src/navigation/AppNavigator.tsx`

### Messaging experience

- [Chat list](https://github.com/akabhishek2316/trusphere-chat-app/blob/main/src/screens/ChatListScreen.tsx): `src/screens/ChatListScreen.tsx`
- [Chat screen](https://github.com/akabhishek2316/trusphere-chat-app/blob/main/src/screens/ChatScreen.tsx): `src/screens/ChatScreen.tsx`
- [Message sync hook](https://github.com/akabhishek2316/trusphere-chat-app/blob/main/src/hooks/useMessages.ts): `src/hooks/useMessages.ts`
- [Message composer and views](https://github.com/akabhishek2316/trusphere-chat-app/blob/main/src/components/ChatInput.tsx): `src/components/ChatInput.tsx`
- [Image sharing](https://github.com/akabhishek2316/trusphere-chat-app/blob/main/src/screens/ImagePreviewScreen.tsx): `src/screens/ImagePreviewScreen.tsx`
- [Voice playback](https://github.com/akabhishek2316/trusphere-chat-app/blob/main/src/components/VoicePlayer.tsx): `src/components/VoicePlayer.tsx`

### Identity and controls

- [Contact discovery](https://github.com/akabhishek2316/trusphere-chat-app/blob/main/src/screens/SearchUserScreen.tsx): `src/screens/SearchUserScreen.tsx`
- [Registration](https://github.com/akabhishek2316/trusphere-chat-app/blob/main/src/screens/RegisterScreen.tsx): `src/screens/RegisterScreen.tsx`
- [Authentication](https://github.com/akabhishek2316/trusphere-chat-app/blob/main/src/services/authService.ts): `src/services/authService.ts`
- [Profiles and blocks](https://github.com/akabhishek2316/trusphere-chat-app/blob/main/src/services/userService.ts): `src/services/userService.ts`
- [Session management](https://github.com/akabhishek2316/trusphere-chat-app/blob/main/src/services/sessionService.ts): `src/services/sessionService.ts`

### Realtime services

- [Chat operations](https://github.com/akabhishek2316/trusphere-chat-app/blob/main/src/services/chatService.ts): `src/services/chatService.ts`
- [Presence and typing](https://github.com/akabhishek2316/trusphere-chat-app/blob/main/src/services/presenceService.ts): `src/services/presenceService.ts`
- [Typing state](https://github.com/akabhishek2316/trusphere-chat-app/blob/main/src/services/typingService.ts): `src/services/typingService.ts`
- [App synchronization](https://github.com/akabhishek2316/trusphere-chat-app/blob/main/src/services/messageSyncService.ts): `src/services/messageSyncService.ts`
- [Firebase client](https://github.com/akabhishek2316/trusphere-chat-app/blob/main/src/services/firebase.ts): `src/services/firebase.ts`
- **Realtime Database**

### Push notifications

- [Notification service](https://github.com/akabhishek2316/trusphere-chat-app/blob/main/src/services/notificationService.ts): `src/services/notificationService.ts`
- [Notification server](https://github.com/akabhishek2316/trusphere-chat-app/blob/main/server/index.js): `server/index.js`
- **Firebase Admin**
- **Firebase Cloud Messaging**

### Other components

- **User**
- **Receiver device**

## Connections

- User → Navigation: uses app
- App lifecycle → Navigation: renders (evidence: `App.tsx`)
- Navigation → Chat list: routes to (evidence: `src/navigation/AppNavigator.tsx`)
- Navigation → Chat screen: routes to (evidence: `src/navigation/AppNavigator.tsx`)
- Chat list → Chat operations: loads chats (evidence: `src/screens/ChatListScreen.tsx`)
- Chat list → Profiles and blocks: reads contacts (evidence: `src/screens/ChatListScreen.tsx`)
- Chat list → Presence and typing: reads presence (evidence: `src/screens/ChatListScreen.tsx`)
- Chat list → Typing state: reads typing (evidence: `src/screens/ChatListScreen.tsx`)
- Chat list → Notification service: sets notifications (evidence: `src/screens/ChatListScreen.tsx`)
- Chat screen → Message sync hook: loads messages (evidence: `src/screens/ChatScreen.tsx`)
- Chat screen → Chat operations: manages messages (evidence: `src/screens/ChatScreen.tsx`)
- Chat screen → Message composer and views: renders composer (evidence: `src/screens/ChatScreen.tsx`)
- Message composer and views → Typing state: updates typing (evidence: `src/components/ChatInput.tsx`)
- Image sharing → Chat operations: sends image message (evidence: `src/screens/ImagePreviewScreen.tsx`)
- Image sharing → Chat operations: updates message (evidence: `src/screens/ImagePreviewScreen.tsx`)
- Voice playback → User: plays voice
- Contact discovery → Profiles and blocks: searches users (evidence: `src/screens/SearchUserScreen.tsx`)
- Contact discovery → Chat operations: starts chats (evidence: `src/screens/SearchUserScreen.tsx`)
- Registration → Authentication: registers account (evidence: `src/screens/RegisterScreen.tsx`)
- Registration → Profiles and blocks: creates profile (evidence: `src/screens/RegisterScreen.tsx`)
- Authentication → Session management: deletes session (evidence: `src/services/authService.ts`)
- App lifecycle → Session management: updates session (evidence: `App.tsx`)
- App lifecycle → App synchronization: starts services
- App lifecycle → Notification service: starts listener (evidence: `App.tsx`)
- Chat operations → Profiles and blocks: checks recipient (evidence: `src/services/chatService.ts`)
- Chat operations → Notification service: requests push (evidence: `src/services/chatService.ts`)
- Chat operations → Firebase client: uses database client (evidence: `src/services/chatService.ts`)
- Message sync hook → Chat operations: subscribes messages (evidence: `src/hooks/useMessages.ts`)
- Presence and typing → Firebase client: uses database client (evidence: `src/services/presenceService.ts`)
- Typing state → Firebase client: uses database client (evidence: `src/services/typingService.ts`)
- Session management → Firebase client: reads and writes (evidence: `src/services/sessionService.ts`)
- Profiles and blocks → Firebase client: reads and writes (evidence: `src/services/userService.ts`)
- Firebase client → Realtime Database: connects to (evidence: `src/services/firebase.ts`)
- Notification service → Notification server: posts notification (evidence: `src/services/notificationService.ts`)
- Notification server → Firebase Admin: uses Admin SDK
- Firebase Admin → Firebase Cloud Messaging: sends push
- Firebase Cloud Messaging → Receiver device: delivers notification
- Realtime Database → App synchronization: synchronizes messages
