# lockerpm/mobile architecture

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

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

## Overview

##### Main Components
- Mobile Frontend (React Native Application): This covers the entire “app” folder where your UI components, screens, navigators (e.g., MainTabNavigator, RootNavigator), and state management models reside.
- Platform-Specific Layers: Separate subcomponents for Android (android folder) and iOS (ios folder). These include native configuration, build scripts, and native implementations for services like Autofill, push notifications, and Firebase integration.
- Core/Business Logic: The “core” directory contains abstractions, service implementations, domain models, importers, and utility functions. This layer encapsulates the business logic, encryption, API handling, and shared functionality across platforms.
- Services & API: Under both “app/services/api” and “core/services”, you have modules that communicate with the external Backend Server. This includes authentication, file upload, messaging, and more.
- External Dependencies: Highlight connections to third-party systems such as the Backend server (which must be set up per README instructions), Firebase (via GoogleService-Info.plist and google-services.json), and other libraries (e.g., push notifications, crypto libraries).

##### Relationships and Interactions
- How the presentation layer (React Native “app” components and screens) interacts with the business logic (models and services) to fetch, store, and update data.
– Data flow from UI components to the business logic (state stores like CipherStore, FolderStore, etc.).
– API requests going from the “services/api” layer to the external backend.
– Communication between the core services (in “core/services”) and platform-specific native functionalities (Android and iOS code for autofill, push notifications).
- That the mobile app’s configuration (using files in app/config and environment variables) instructs the endpoints and external service settings.

##### Architectural Patterns and Design Principles
- Layered Architecture: Present separate layers for UI, domain/business logic, integration services, and native implementations.
- Separation of Concerns: Emphasize that individual modules (e.g., components, screens, navigation in “app”, core abstractions in “core”, and API integrations) handle isolated responsibilities.
- Cross-platform Strategy: Point out that most of the business logic is shared and written in JavaScript/TypeScript, while Android and iOS have dedicated directories for platform-specific code.
- Extensibility: Note the “selfhost” folder that hints at customization of assets and branding following the guide in the README.

##### Relevant Technologies, Frameworks, and Libraries
- React Native (for the UI layer)
- Native build tools (Android Studio/Gradle for Android, Xcode for iOS)
- Firebase integration and push notification services
- Possibly MobX or another state management system (as suggested by “models/RootStore” and other store files)
- Core crypto services and multi-platform utilities found in “core/utils” and “core/abstractions”

##### Putting It All Together
– At the top, show the Mobile Application as the entry point.
– Next, split into two parallel flows: one for the cross-platform React Native components (UI and shared business logic) and one for platform-specific modules.
– At the bottom, show the external Backend and cloud services, which receive API requests from the mobile services.
– The “app” folder is broken down into UI and navigational components.
– The “core” folder is highlighted as providing abstractions and domain logic utilized by both the UI and native layers.
- Lastly, include configuration flows (e.g., environment setup using file “app/config/.env”) that customize how the application connects to external services.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Mobile Application (React Native)"
        A1["UI Components"]:::frontend
        A2["State Management & Navigation"]:::frontend
    end

    subgraph "Core Layer"
        B1["Core Business Logic"]:::core
    end

    subgraph "API Services"
        S1["Mobile API Services"]:::service
        S2["Core API Services"]:::service
    end

    subgraph "Platform-Specific Layers"
        N1["Android Native Module"]:::native
        N2["iOS Native Module"]:::native
    end

    subgraph "External Dependencies"
        E1["Backend API Server"]:::external
        E2["Firebase Services"]:::external
        E3["Branding & Configuration"]:::external
    end

    %% Connections
    A1 -->|"calls"| B1
    A2 -->|"updates"| B1
    B1 -->|"integrates"| N1
    B1 -->|"integrates"| N2
    B1 -->|"requests"| S1
    B1 -->|"requests"| S2
    S1 -->|"API_call"| E1
    S2 -->|"API_call"| E1
    S1 -->|"connects"| E2
    S2 -->|"connects"| E2
    A1 -->|"loads"| E3

    %% Click Events
    click A1 "https://github.com/lockerpm/mobile/tree/selfhost/app/"
    click N1 "https://github.com/lockerpm/mobile/tree/selfhost/android/"
    click N2 "https://github.com/lockerpm/mobile/tree/selfhost/ios/"
    click B1 "https://github.com/lockerpm/mobile/tree/selfhost/core/"
    click S1 "https://github.com/lockerpm/mobile/tree/selfhost/app/services/api/"
    click S2 "https://github.com/lockerpm/mobile/tree/selfhost/core/services/"
    click E3 "https://github.com/lockerpm/mobile/tree/selfhost/selfhost/"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef core fill:#FFE4B5,stroke:#333,stroke-width:2px;
    classDef service fill:#FFB6C1,stroke:#333,stroke-width:2px;
    classDef native fill:#98FB98,stroke:#333,stroke-width:2px;
    classDef external fill:#FFD700,stroke:#333,stroke-width:2px;
```
