# zulip/zulip-mobile architecture

> Architecture diagram of the GitHub repository zulip/zulip-mobile, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/zulip/zulip-mobile
- Repository: https://github.com/zulip/zulip-mobile

## Overview

##### Main Components

a. Client-Side Components:

b. Platform-Specific Components:

c. External Services:

##### Component Relationships

- Data flow between Redux store and React components
- API communication between the app and Zulip server
- Navigation flow between different screens
- Push notification handling flow
- Authentication flow

##### Detailed Component Breakdown

Core Features Layer:
- Message Handling
- Composition
- Rendering
- Storage
- Navigation
- Screens
- Navigation State
- State Management
- Actions
- Reducers
- Selectors
- Native Features
- Notifications
- Storage
- Platform-specific APIs

##### Key Architectural Patterns to Highlight

a. Redux Pattern:
- Actions, Reducers, Store, and Selectors
- Unidirectional data flow

b. React Native Bridge:
- Communication between JS and Native code
- Platform-specific implementations

c. WebView Architecture:
- Message list rendering strategy
- Performance optimizations

##### Special Features

- Real-time message synchronization
- Offline support
- Push notification handling
- File sharing and media handling
- Authentication flows

##### Technical Details to Note

Annotations for:
- React Native version
- Key dependencies
- API versioning
- Storage mechanisms
- State persistence

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Legend"
        UI[UI Components]:::ui
        RD[Redux]:::redux
        NAV[Navigation]:::nav
        WV[WebView]:::webview
        NB[Native Bridge]:::bridge
        IOS[iOS]:::ios
        AND[Android]:::android
        EXT[External Services]:::external
        PUSH[Push Services]:::push
        AUTH[Auth Services]:::auth
    end

    subgraph "Client Layer"
        RNUI["React Native UI Layer"]:::ui
        click RNUI "https://github.com/zulip/zulip-mobile/tree/main/src/common/"

        subgraph "State Management"
            Store["Redux Store"]:::redux
            click Store "https://github.com/zulip/zulip-mobile/blob/main/src/boot/store.js"
            Reducers["Reducers"]:::redux
            click Reducers "https://github.com/zulip/zulip-mobile/blob/main/src/boot/reducers.js"
            Actions["Actions"]:::redux
            click Actions "https://github.com/zulip/zulip-mobile/blob/main/src/actionTypes.js"
        end

        subgraph "Navigation"
            AppNav["App Navigator"]:::nav
            click AppNav "https://github.com/zulip/zulip-mobile/blob/main/src/nav/AppNavigator.js"
            NavService["Navigation Service"]:::nav
            click NavService "https://github.com/zulip/zulip-mobile/blob/main/src/nav/NavigationService.js"
        end

        subgraph "WebView Components"
            MessageList["Message List"]:::webview
            click MessageList "https://github.com/zulip/zulip-mobile/blob/main/src/webview/MessageList.js"
            WebViewHTML["HTML Renderer"]:::webview
            click WebViewHTML "https://github.com/zulip/zulip-mobile/tree/main/src/webview/html/"
            WebViewJS["JS Controller"]:::webview
            click WebViewJS "https://github.com/zulip/zulip-mobile/tree/main/src/webview/js/"
        end
    end

    subgraph "Native Bridge Layer"
        NativeBridge["Native Modules Bridge"]:::bridge
        click NativeBridge "https://github.com/zulip/zulip-mobile/tree/main/src/nativeModules/"
    end

    subgraph "Platform Layer"
        IOSComponents["iOS Components"]:::ios
        click IOSComponents "https://github.com/zulip/zulip-mobile/tree/main/ios/ZulipMobile/"
        IOSNotif["iOS Notifications"]:::ios
        click IOSNotif "https://github.com/zulip/zulip-mobile/blob/main/ios/ZulipMobile/ZLPNotifications.swift"
        
        AndroidComponents["Android Components"]:::android
        click AndroidComponents "https://github.com/zulip/zulip-mobile/tree/main/android/app/src/main/java/com/zulipmobile/"
        AndroidNotif["Android Notifications"]:::android
        click AndroidNotif "https://github.com/zulip/zulip-mobile/tree/main/android/app/src/main/java/com/zulipmobile/notifications/"
    end

    subgraph "External Services"
        ZulipAPI["Zulip Server API"]:::external
        PushNotifications["Push Notification Services"]:::push
        click PushNotifications "https://github.com/zulip/zulip-mobile/tree/main/src/notification/"
        
        subgraph "Authentication"
            AuthScreen["Auth Screen"]:::auth
            click AuthScreen "https://github.com/zulip/zulip-mobile/blob/main/src/start/AuthScreen.js"
            PasswordAuth["Password Auth"]:::auth
            click PasswordAuth "https://github.com/zulip/zulip-mobile/blob/main/src/start/PasswordAuthScreen.js"
            DevAuth["Dev Auth"]:::auth
            click DevAuth "https://github.com/zulip/zulip-mobile/blob/main/src/start/DevAuthScreen.js"
        end
    end

    %% Relationships
    Store --> RNUI
    Actions --> Store
    Reducers --> Store
    
    RNUI --> AppNav
    AppNav --> NavService
    
    RNUI --> MessageList
    MessageList --> WebViewHTML
    MessageList --> WebViewJS
    
    NativeBridge --> IOSComponents
    NativeBridge --> AndroidComponents
    
    PushNotifications --> IOSNotif
    PushNotifications --> AndroidNotif
    
    AuthScreen --> PasswordAuth
    AuthScreen --> DevAuth
    
    ZulipAPI --> Store

    %% Styles
    classDef ui fill:#3498db
    classDef redux fill:#9b59b6
    classDef nav fill:#2ecc71
    classDef webview fill:#e67e22
    classDef bridge fill:#f1c40f
    classDef ios fill:#87ceeb
    classDef android fill:#90ee90
    classDef external fill:#95a5a6
    classDef push fill:#e74c3c
    classDef auth fill:#d35400
```
