# martymfly/expo-file-manager architecture

> Architecture diagram of the GitHub repository martymfly/expo-file-manager, 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/martymfly/expo-file-manager
- Repository: https://github.com/martymfly/expo-file-manager

## Overview

##### Main Components
- App Entry Point: At the center is the App.tsx file which initializes the application.
- Navigation Layers: The /navigation folder contains various navigators (MainNavigator, HomeStackNavigator, SettingsStackNavigator) that define the screen routing logic.
- UI Screens: Under the /screens folder are specific pages such as Browser, FileTransfer, ImageGalleryView, LockScreen, Main, MiscFileView, Settings, VideoPlayer, and Web. These represent the higher-level visual components of the application.
- UI & Reusable Components: The /components folder includes UI pieces like ActionSheet, a collection of Browser UI components (dialogs, file items, image selection components), and file viewers (e.g., PDFViewer). These are the building blocks used within screens.
- State Management / Features: The /features folder shows Redux-like slices (imagesSlice, snackbarSlice, tabbarStyleSlice, themeSlice) managing different parts of the application state. Also, store.ts is central to managing and wiring the global application state.
- External Patches & Configurations: The patches folder (for example, a patch for react-native-image-viewing) and various configuration files (.eslintrc, babel.config.js, tsconfig.json, etc.) represent non-business logic but are critical for build and runtime behavior.

##### Relationships and Interactions
- The App.tsx acts as the entry point that ties together the navigation setup, state management (Redux store, slices) and conditionally loads screens.
- Navigation components determine the flow between screens (e.g., from the Browser screen to FileTransfer or Settings), with navigators managing stacks and screen hierarchies.
- UI screens interact with Features (Redux slices) to fetch, manipulate, and display file and app state. Data flows from hooks and state management to screen components.
- Reusable components (in /components) are embedded within the screens and communicate with the state (via Redux or hooks) to reflect user actions (like downloading files, selecting images, etc.).
- Utility functions are used by both components and features to perform common operations.
- Integration with external systems (like file transfer over websockets) is indicated in the README and may be reflected as external service blocks along with the built-in Web Browser component.

##### Architectural Patterns
- Component-Based Architecture: The clear separation into screens, components, and feature slices implies a modular, reusable design.
- MV* Patterns: The “view” layer is built with React Native components; state is managed with Redux-like slices; and logic is abstracted into hooks.
- Navigation Patterns: Use of stack navigators indicates a typical mobile navigation flow.
- Separation of Concerns: The distinctions between UI components, state management, and utility functions ensure each module has a single responsibility.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% App Entry Point
    subgraph "App Entry"
        AppEntry["App.tsx"]:::entry
    end

    %% Navigation Layer
    subgraph "Navigation Layer"
        MainNav["MainNavigator"]:::nav
        HomeNav["HomeStackNavigator"]:::nav
        SettingsNav["SettingsStackNavigator"]:::nav
    end

    %% UI Screens
    subgraph "UI Screens"
        BrowserScreen["Browser Screen"]:::screen
        FileTransferScreen["File Transfer Screen"]:::screen
        ImageGalleryView["Image Gallery View"]:::screen
        LockScreen["Lock Screen"]:::screen
        MainScreen["Main Screen"]:::screen
        MiscFileView["Misc File View"]:::screen
        SettingsScreen["Settings Screen"]:::screen
        PasscodeScreen["Set Passcode Screen"]:::screen
        VideoPlayerScreen["Video Player Screen"]:::screen
        WebScreen["Web Screen"]:::screen
    end

    %% UI & Reusable Components
    subgraph "UI Components"
        ActionSheet["ActionSheet"]:::component
        DownloadDialog["Download Dialog"]:::component
        FileTransferDialog["File Transfer Dialog"]:::component
        FileItem["File Item"]:::component
        NewFolderDialog["New Folder Dialog"]:::component
        PickImages["PickImages Component"]:::component
        PDFViewer["PDFViewer"]:::component
    end

    %% State Management / Features
    subgraph "State Management"
        subgraph "Redux Slices"
            ImagesSlice["Images Slice"]:::state
            SnackbarSlice["Snackbar Slice"]:::state
            TabbarSlice["TabbarStyle Slice"]:::state
            ThemeSlice["Theme Slice"]:::state
        end
        GlobalStore["Global Store"]:::state
    end

    %% Utility and Hooks
    subgraph "Utility & Hooks"
        CustomHooks["Custom Hooks"]:::hook
        UtilityFunctions["Utility Functions"]:::hook
    end

    %% External Patches & Configurations
    subgraph "External & Configurations"
        ImageViewingPatch["Image Viewing Patch"]:::external
        Configurations["Configurations"]:::external
    end

    %% Connections from App Entry
    AppEntry -->|initializes| MainNav
    AppEntry -->|initializes| HomeNav
    AppEntry -->|initializes| SettingsNav
    AppEntry -->|loads| GlobalStore

    %% Navigation to Screens
    MainNav -->|routes to| MainScreen
    HomeNav -->|routes to| BrowserScreen
    HomeNav -->|routes to| FileTransferScreen
    HomeNav -->|routes to| ImageGalleryView
    HomeNav -->|routes to| LockScreen
    HomeNav -->|routes to| MiscFileView
    HomeNav -->|routes to| VideoPlayerScreen
    HomeNav -->|routes to| WebScreen
    SettingsNav -->|routes to| SettingsScreen
    SettingsNav -->|routes to| PasscodeScreen

    %% Screens to UI Components (embedding components)
    BrowserScreen -->|contains| DownloadDialog
    BrowserScreen -->|contains| FileTransferDialog
    BrowserScreen -->|invokes| PickImages
    MainScreen -->|uses| ActionSheet
    MiscFileView -->|renders| PDFViewer

    %% Screens interactions with State Management
    BrowserScreen -->|dispatches| ImagesSlice
    FileTransferScreen -->|dispatches| SnackbarSlice
    MainScreen -->|dispatches| TabbarSlice
    SettingsScreen -->|dispatches| ThemeSlice
    PasscodeScreen -->|updates| ThemeSlice

    %% Screens interactions with Custom Hooks
    BrowserScreen -->|hooks| CustomHooks
    FileTransferScreen -->|hooks| CustomHooks
    MainScreen -->|hooks| CustomHooks
    SettingsScreen -->|hooks| CustomHooks

    %% UI Components interactions with Utilities and State
    ActionSheet -->|utilizes| UtilityFunctions
    DownloadDialog -->|notifies| SnackbarSlice
    FileItem -->|notifies| SnackbarSlice
    PickImages -->|utilizes| UtilityFunctions

    %% Custom Hooks usage of State Management
    CustomHooks -->|accesses| ImagesSlice
    CustomHooks -->|accesses| SnackbarSlice

    %% External integrations
    ImageViewingPatch -->|patches| PDFViewer
    FileTransferScreen -->|configures| Configurations

    %% Click Events
    click AppEntry "https://github.com/martymfly/expo-file-manager/blob/main/App.tsx"
    click MainNav "https://github.com/martymfly/expo-file-manager/blob/main//navigation/MainNavigator.tsx"
    click HomeNav "https://github.com/martymfly/expo-file-manager/blob/main//navigation/HomeStackNavigator.tsx"
    click SettingsNav "https://github.com/martymfly/expo-file-manager/blob/main//navigation/SettingsStackNavigator.tsx"
    
    click BrowserScreen "https://github.com/martymfly/expo-file-manager/blob/main//screens/Browser.tsx"
    click FileTransferScreen "https://github.com/martymfly/expo-file-manager/blob/main//screens/FileTransfer.tsx"
    click ImageGalleryView "https://github.com/martymfly/expo-file-manager/blob/main//screens/ImageGalleryView.tsx"
    click LockScreen "https://github.com/martymfly/expo-file-manager/blob/main//screens/LockScreen.tsx"
    click MainScreen "https://github.com/martymfly/expo-file-manager/blob/main//screens/Main.tsx"
    click MiscFileView "https://github.com/martymfly/expo-file-manager/blob/main//screens/MiscFileView.tsx"
    click SettingsScreen "https://github.com/martymfly/expo-file-manager/blob/main//screens/Settings/Settings.tsx"
    click PasscodeScreen "https://github.com/martymfly/expo-file-manager/blob/main//screens/Settings/SetPassCodeScreen.tsx"
    click VideoPlayerScreen "https://github.com/martymfly/expo-file-manager/blob/main//screens/VideoPlayer.tsx"
    click WebScreen "https://github.com/martymfly/expo-file-manager/blob/main//screens/Web.tsx"
    
    click ActionSheet "https://github.com/martymfly/expo-file-manager/blob/main//components/ActionSheet.tsx"
    click DownloadDialog "https://github.com/martymfly/expo-file-manager/blob/main//components/Browser/DownloadDialog.tsx"
    click FileTransferDialog "https://github.com/martymfly/expo-file-manager/blob/main//components/Browser/FileTransferDialog.tsx"
    click FileItem "https://github.com/martymfly/expo-file-manager/blob/main//components/Browser/Files/FileItem.tsx"
    click NewFolderDialog "https://github.com/martymfly/expo-file-manager/blob/main//components/Browser/NewFolderDialog.tsx"
    click PickImages "https://github.com/martymfly/expo-file-manager/tree/main//components/Browser/PickImages"
    click PDFViewer "https://github.com/martymfly/expo-file-manager/blob/main//components/MiscFileView/PDFViewer.tsx"
    
    click ImagesSlice "https://github.com/martymfly/expo-file-manager/blob/main//features/files/imagesSlice.ts"
    click SnackbarSlice "https://github.com/martymfly/expo-file-manager/blob/main//features/files/snackbarSlice.ts"
    click TabbarSlice "https://github.com/martymfly/expo-file-manager/blob/main//features/files/tabbarStyleSlice.ts"
    click ThemeSlice "https://github.com/martymfly/expo-file-manager/blob/main//features/files/themeSlice.ts"
    click GlobalStore "https://github.com/martymfly/expo-file-manager/blob/main/store.ts"
    
    click CustomHooks "https://github.com/martymfly/expo-file-manager/tree/main//hooks"
    click UtilityFunctions "https://github.com/martymfly/expo-file-manager/tree/main//utils"
    
    click ImageViewingPatch "https://github.com/martymfly/expo-file-manager/blob/main//patches/react-native-image-viewing+0.2.2.patch"
    click Configurations "https://github.com/martymfly/expo-file-manager/blob/main/.eslintrc"

    %% Styles
    classDef entry fill:#f4d03f,stroke:#333,stroke-width:2px;
    classDef nav fill:#85C1E9,stroke:#333,stroke-width:2px;
    classDef screen fill:#ABEBC6,stroke:#333,stroke-width:2px;
    classDef component fill:#F9E79F,stroke:#333,stroke-width:2px;
    classDef state fill:#F5B7B1,stroke:#333,stroke-width:2px;
    classDef hook fill:#D7BDE2,stroke:#333,stroke-width:2px;
    classDef external fill:#AED6F1,stroke:#333,stroke-width:2px;
```
