# nikcodepro/ai-chat-app architecture

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

- Interactive diagram: https://gitdiagram.com/nikcodepro/ai-chat-app
- Repository: https://github.com/nikcodepro/ai-chat-app

## Overview

This Expo app provides account access and an authenticated AI chat experience, with separate voice- and video-call screens. The main path is app startup and session restoration, authentication when needed, then home/chat interactions; shared state coordinates API access, chat history, and messages. Voice calls use a hook to coordinate audio capture/playback and a WebSocket, while video screens use a WebRTC service. The README describes only the Expo starter, so feature coverage and relationships here rely on the supplied source index and excerpts; unsampled details are not inferred.

Main entry points: [`src/store/appStore.ts`](https://github.com/nikcodepro/ai-chat-app/blob/master/src/store/appStore.ts) (Application state), [`src/navigation/AppNavigator.tsx`](https://github.com/nikcodepro/ai-chat-app/blob/master/src/navigation/AppNavigator.tsx) (App navigator), [`src/screens/chat/ChatScreen.tsx`](https://github.com/nikcodepro/ai-chat-app/blob/master/src/screens/chat/ChatScreen.tsx) (Chat screen), [`src/hooks/useVoiceCall.ts`](https://github.com/nikcodepro/ai-chat-app/blob/master/src/hooks/useVoiceCall.ts) (Voice call coordination)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_navigation["App and navigation"]
  node_app["App entry<br/>[App.tsx]"]
  node_navigator["App navigator<br/>[AppNavigator.tsx]"]
end

subgraph group_account["Account and profile"]
  node_auth["Auth screens"]
  node_home["Home screen<br/>[HomeScreen.tsx]"]
  node_profile["Profile screen<br/>[ProfileScreen.tsx]"]
end

subgraph group_chat["Chat experience"]
  node_chat_screen["Chat screen<br/>[ChatScreen.tsx]"]
  node_chat_ui["Chat components"]
end

subgraph group_realtime["Realtime calls"]
  node_voice_screen["Voice call screen"]
  node_video_screen["Video call screen"]
  node_voice_hook["Voice call coordination<br/>[useVoiceCall.ts]"]
  node_audio["Audio service<br/>[audioService.ts]"]
  node_websocket["Voice WebSocket"]
  node_webrtc["WebRTC service<br/>[webrtcService.ts]"]
  node_audio_hooks["Audio hooks"]
end

subgraph group_shared["State and services"]
  node_chat_api["Chat API<br/>[chatApi.ts]"]
  node_app_store["Application state<br/>[appStore.ts]"]
  node_api["Authentication API<br/>[api.ts]"]
  node_tokens[("Token storage<br/>[tokenStorage.ts]")]
  node_theme["Theme tokens<br/>[colors.ts]"]
end

node_user(("App user"))

node_user -->|"opens"| node_app
node_app -->|"renders"| node_navigator
node_navigator -->|"routes"| node_auth
node_navigator -->|"routes"| node_home
node_navigator -->|"routes"| node_profile
node_navigator -->|"routes"| node_chat_screen
node_navigator -->|"routes"| node_voice_screen
node_navigator -->|"routes"| node_video_screen
node_navigator -->|"restores session"| node_app_store
node_auth -->|"requests auth"| node_api
node_auth -->|"updates state"| node_app_store
node_home -->|"requests data"| node_api
node_home -->|"reads state"| node_app_store
node_profile -->|"updates profile"| node_api
node_profile -->|"reads state"| node_app_store
node_chat_screen -->|"renders"| node_chat_ui
node_chat_screen -->|"reads and updates"| node_app_store
node_chat_screen -->|"requests chats"| node_chat_api
node_app_store -->|"loads chat data"| node_chat_api
node_app_store -->|"uses auth API"| node_api
node_app_store -->|"stores tokens"| node_tokens
node_api -->|"reads tokens"| node_tokens
node_voice_screen -->|"uses call controls"| node_voice_hook
node_voice_screen -->|"uses audio capture"| node_audio_hooks
node_video_screen -->|"uses call controls"| node_voice_hook
node_video_screen -->|"uses WebRTC"| node_webrtc
node_voice_hook -->|"controls audio"| node_audio
node_voice_hook -->|"streams voice"| node_websocket
node_voice_hook -->|"reads token"| node_app_store
node_chat_screen -->|"uses styling"| node_theme
node_chat_ui -->|"uses styling"| node_theme

click node_app "https://github.com/nikcodepro/ai-chat-app/blob/master/App.tsx"
click node_navigator "https://github.com/nikcodepro/ai-chat-app/blob/master/src/navigation/AppNavigator.tsx"
click node_auth "https://github.com/nikcodepro/ai-chat-app/tree/master/src/screens/auth"
click node_home "https://github.com/nikcodepro/ai-chat-app/blob/master/src/screens/home/HomeScreen.tsx"
click node_profile "https://github.com/nikcodepro/ai-chat-app/blob/master/src/screens/profile/ProfileScreen.tsx"
click node_chat_screen "https://github.com/nikcodepro/ai-chat-app/blob/master/src/screens/chat/ChatScreen.tsx"
click node_chat_ui "https://github.com/nikcodepro/ai-chat-app/tree/master/src/components"
click node_chat_api "https://github.com/nikcodepro/ai-chat-app/blob/master/src/services/chatApi.ts"
click node_voice_screen "https://github.com/nikcodepro/ai-chat-app/blob/master/src/screens/chat/VoiceCallScreen.tsx"
click node_video_screen "https://github.com/nikcodepro/ai-chat-app/blob/master/src/screens/chat/VideoCallScreen.tsx"
click node_voice_hook "https://github.com/nikcodepro/ai-chat-app/blob/master/src/hooks/useVoiceCall.ts"
click node_audio "https://github.com/nikcodepro/ai-chat-app/blob/master/src/services/audioService.ts"
click node_websocket "https://github.com/nikcodepro/ai-chat-app/blob/master/src/services/websocketService.ts"
click node_webrtc "https://github.com/nikcodepro/ai-chat-app/blob/master/src/services/webrtcService.ts"
click node_app_store "https://github.com/nikcodepro/ai-chat-app/blob/master/src/store/appStore.ts"
click node_api "https://github.com/nikcodepro/ai-chat-app/blob/master/src/services/api.ts"
click node_tokens "https://github.com/nikcodepro/ai-chat-app/blob/master/src/services/tokenStorage.ts"
click node_audio_hooks "https://github.com/nikcodepro/ai-chat-app/blob/master/src/hooks/useAudioRecorder.ts"
click node_theme "https://github.com/nikcodepro/ai-chat-app/blob/master/src/theme/colors.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_navigator,node_user toneBlue
class node_auth,node_home,node_profile toneAmber
class node_chat_screen,node_chat_ui toneMint
class node_voice_screen,node_video_screen,node_voice_hook,node_audio,node_websocket,node_webrtc,node_audio_hooks toneRose
class node_chat_api,node_app_store,node_api,node_tokens,node_theme toneIndigo
```

## Components

### App and navigation

- [App entry](https://github.com/nikcodepro/ai-chat-app/blob/master/App.tsx): `App.tsx`
- [App navigator](https://github.com/nikcodepro/ai-chat-app/blob/master/src/navigation/AppNavigator.tsx): `src/navigation/AppNavigator.tsx`

### Account and profile

- [Auth screens](https://github.com/nikcodepro/ai-chat-app/tree/master/src/screens/auth): `src/screens/auth`
- [Home screen](https://github.com/nikcodepro/ai-chat-app/blob/master/src/screens/home/HomeScreen.tsx): `src/screens/home/HomeScreen.tsx`
- [Profile screen](https://github.com/nikcodepro/ai-chat-app/blob/master/src/screens/profile/ProfileScreen.tsx): `src/screens/profile/ProfileScreen.tsx`

### Chat experience

- [Chat screen](https://github.com/nikcodepro/ai-chat-app/blob/master/src/screens/chat/ChatScreen.tsx): `src/screens/chat/ChatScreen.tsx`
- [Chat components](https://github.com/nikcodepro/ai-chat-app/tree/master/src/components): `src/components`

### Realtime calls

- [Voice call screen](https://github.com/nikcodepro/ai-chat-app/blob/master/src/screens/chat/VoiceCallScreen.tsx): `src/screens/chat/VoiceCallScreen.tsx`
- [Video call screen](https://github.com/nikcodepro/ai-chat-app/blob/master/src/screens/chat/VideoCallScreen.tsx): `src/screens/chat/VideoCallScreen.tsx`
- [Voice call coordination](https://github.com/nikcodepro/ai-chat-app/blob/master/src/hooks/useVoiceCall.ts): `src/hooks/useVoiceCall.ts`
- [Audio service](https://github.com/nikcodepro/ai-chat-app/blob/master/src/services/audioService.ts): `src/services/audioService.ts`
- [Voice WebSocket](https://github.com/nikcodepro/ai-chat-app/blob/master/src/services/websocketService.ts): `src/services/websocketService.ts`
- [WebRTC service](https://github.com/nikcodepro/ai-chat-app/blob/master/src/services/webrtcService.ts): `src/services/webrtcService.ts`
- [Audio hooks](https://github.com/nikcodepro/ai-chat-app/blob/master/src/hooks/useAudioRecorder.ts): `src/hooks/useAudioRecorder.ts`

### State and services

- [Chat API](https://github.com/nikcodepro/ai-chat-app/blob/master/src/services/chatApi.ts): `src/services/chatApi.ts`
- [Application state](https://github.com/nikcodepro/ai-chat-app/blob/master/src/store/appStore.ts): `src/store/appStore.ts`
- [Authentication API](https://github.com/nikcodepro/ai-chat-app/blob/master/src/services/api.ts): `src/services/api.ts`
- [Token storage](https://github.com/nikcodepro/ai-chat-app/blob/master/src/services/tokenStorage.ts): `src/services/tokenStorage.ts`
- [Theme tokens](https://github.com/nikcodepro/ai-chat-app/blob/master/src/theme/colors.ts): `src/theme/colors.ts`

### Other components

- **App user**

## Connections

- App user → App entry: opens
- App entry → App navigator: renders (evidence: `App.tsx`)
- App navigator → Auth screens: routes (evidence: `src/navigation/AppNavigator.tsx`)
- App navigator → Home screen: routes (evidence: `src/navigation/AppNavigator.tsx`)
- App navigator → Profile screen: routes (evidence: `src/navigation/AppNavigator.tsx`)
- App navigator → Chat screen: routes (evidence: `src/navigation/AppNavigator.tsx`)
- App navigator → Voice call screen: routes (evidence: `src/navigation/AppNavigator.tsx`)
- App navigator → Video call screen: routes (evidence: `src/navigation/AppNavigator.tsx`)
- App navigator → Application state: restores session (evidence: `src/navigation/AppNavigator.tsx`)
- Auth screens → Authentication API: requests auth (evidence: `src/screens/auth/LoginScreen.tsx`)
- Auth screens → Application state: updates state (evidence: `src/screens/auth/LoginScreen.tsx`)
- Home screen → Authentication API: requests data (evidence: `src/screens/home/HomeScreen.tsx`)
- Home screen → Application state: reads state (evidence: `src/screens/home/HomeScreen.tsx`)
- Profile screen → Authentication API: updates profile (evidence: `src/screens/profile/ProfileScreen.tsx`)
- Profile screen → Application state: reads state (evidence: `src/screens/profile/ProfileScreen.tsx`)
- Chat screen → Chat components: renders (evidence: `src/screens/chat/ChatScreen.tsx`)
- Chat screen → Application state: reads and updates (evidence: `src/screens/chat/ChatScreen.tsx`)
- Chat screen → Chat API: requests chats (evidence: `src/screens/chat/ChatScreen.tsx`)
- Application state → Chat API: loads chat data (evidence: `src/store/appStore.ts`)
- Application state → Authentication API: uses auth API (evidence: `src/store/appStore.ts`)
- Application state → Token storage: stores tokens (evidence: `src/store/appStore.ts`)
- Authentication API → Token storage: reads tokens (evidence: `src/services/api.ts`)
- Voice call screen → Voice call coordination: uses call controls (evidence: `src/screens/chat/VoiceCallScreen.tsx`)
- Voice call screen → Audio hooks: uses audio capture (evidence: `src/screens/chat/VoiceCallScreen.tsx`)
- Video call screen → Voice call coordination: uses call controls (evidence: `src/screens/chat/VideoCallScreen.tsx`)
- Video call screen → WebRTC service: uses WebRTC (evidence: `src/screens/chat/VideoCallScreen.tsx`)
- Voice call coordination → Audio service: controls audio (evidence: `src/hooks/useVoiceCall.ts`)
- Voice call coordination → Voice WebSocket: streams voice (evidence: `src/hooks/useVoiceCall.ts`)
- Voice call coordination → Application state: reads token (evidence: `src/hooks/useVoiceCall.ts`)
- Chat screen → Theme tokens: uses styling (evidence: `src/screens/chat/ChatScreen.tsx`)
- Chat components → Theme tokens: uses styling (evidence: `src/components/GradientCard.tsx`)
