# teamamaze/amazefilemanager architecture

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

- Interactive diagram: https://gitdiagram.com/teamamaze/amazefilemanager
- Repository: https://github.com/teamamaze/amazefilemanager

## Overview

##### Overall Scope and Layers
- The project’s primary purpose is to provide core file management (browsing, copying, deleting, renaming, compressing/decompressing files) with additional support for features such as tabs, root exploration, encryption, and cloud service integration.
- It is a full-fledged Android application with a complex UI layer (activities, fragments, dialogs, custom views) and a robust business logic layer (asynchronous tasks handling file operations, compression routines, and cloud integrations).

##### Main Components
a. UI/Presentation Layer
- Activities and Fragments: (e.g., MainActivity, AboutActivity, PreferencesActivity, TextEditorActivity, various fragments for file browsing, cloud integration, dialogs) – these manage user interactions.
- Custom Views and UI Resources: Layouts, themes, drawables, and resource XML files that define the Material Design look-and-feel.
b. Application Core and Business Logic
- Asynchronous Tasks & Services: Extensive asynchronous operations—for tasks such as file copy, move, compress/decompress operations (e.g., tasks in the “asynchronous/asynctasks” directories and service classes).
- File System Interaction: Separate packages for file operations on local storage, root-based commands, and interfacing with external drives (including the “filesystem”, “fileoperations”, and “fileoperations/filesystem/root” directories).
- Database Layer: Data access components including DAOs, database helpers, and schema definition (packages under “database” and their models) for storing bookmarks, history, and other state.
c. External Modules and Plug-ins
- Commons Compression Module (“commons_compress_7z”): Handling 7z format operations, decoders, and archive entry representations.
- File operations module (“file_operations”): Likely handling native operations (including C code via CMake) for low-level file system operations.
- Port Scanner Module (“portscanner”): Implements network scanning functionality which might be used for additional connectivity or network-related features.
d. Cloud and External Services Integration
e. Testing Infrastructure
- Multiple test directories (e.g., “src/test”, “src/testFdroid”, “src/testPlay”, etc.) that validate business logic and file operations.
f. Build & Infrastructure Files
- Gradle build scripts, configuration files, and CI/Integration setups (notice the GitHub workflows in the “.github” folder).

##### Relationships and Data Flow
- The UI layer (activities, fragments, dialogs) interacts with ViewModel classes (e.g., MainActivityViewModel) to trigger asynchronous tasks.
- Asynchronous tasks (for file operations, compression, encryption, etc.) run in the background, consulting the file management core (which contains the actual logic for handling file systems and cloud operations).
- Database access objects and helper classes serve as the Data Access Layer establishing persistence and state management for history, bookmarks, and settings.
- External modules (such as commons_compress_7z and file_operations) provide specialized capabilities and are integrated by the core business logic.
- Unit and integration tests verify correctness across all these layers.

##### Architectural Patterns and Principles
- A separation of concerns is evident (i.e., clear separation between UI, business logic, and data handling).
- The asynchronous/task-based programming model is critical for maintaining UI responsiveness on Android.
- An MVVM-like approach is suggested through the usage of activities and view models.
- Modularity is enforced through separation of functionality in distinct modules (compression, file operations, networking).

##### Detailed Elements
- UI Layer: MainActivity, AboutActivity, PreferencesActivity, File Browsing Fragments, Dialogs, Custom Views.
- Business Logic: Asynchronous task executor (with tasks for copy, move, compress/decompress, text editing), Service Watchers, and Error/Catch Mechanism (crash reporting via Acra).
- File System Layer: Local file system utilities (HybridFile, FileUtil, FileListSorter) and root operations support.
- Database Layer: Database helpers (like ExplorerDatabase, UtilitiesDatabase), DAO interfaces, and model classes.
- Compression and Encryption Modules: Specific classes for handling formats (7z, zip, tar variants) and encryption services.
- External Modules: PortScanner components and other network tools.
- Testing Infrastructure: Mention integration test blocks and unit test directories to show robust validation of each module.
- Build Infrastructure: Gradle build scripts, CI workflows (GitHub workflows folder) to indicate the automated build and deployment process.

– Make separate views if needed (one for high-level module interaction and another for deeper internal layering such as the relationship between asynchronous tasks, file operations, and database access).

## Diagram (Mermaid)

```mermaid
graph TD
    %% UI/Presentation Layer
    subgraph "UI/Presentation Layer"
        U1("UI Components (Activities, Fragments, Dialogs, Custom Views)"):::ui
    end

    %% Application Core & Business Logic
    subgraph "Application Core & Business Logic"
        B1("Asynchronous Tasks & Services"):::logic
        B2("File System Interaction"):::logic
        B3("Database Layer"):::logic
    end

    %% External Modules & Plug-ins
    subgraph "External Modules & Plug-ins"
        E1("Commons Compression Module"):::external
        E2("File Operations Module"):::external
        E3("Port Scanner Module"):::external
    end

    %% Cloud and External Services Integration
    subgraph "Cloud Services Integration"
        C1("Cloud Services Support"):::cloud
    end

    %% Build & Testing Infrastructure
    subgraph "Build & Testing"
        T1("Testing Infrastructure"):::testing
        T2("Gradle Build Scripts"):::build
        T3("CI Workflows"):::build
    end

    %% Relationships
    U1 -->|"initiates"| B1
    B1 -->|"triggers"| B2
    B1 -->|"updates"| B3
    B2 -->|"uses"| E1
    B2 -->|"calls"| E2
    B1 -->|"executes"| E3
    B2 -->|"syncs"| C1

    %% Optional connections from Testing/Build to core layers for validation and build pipelines
    T1 -->|"validates"| B1
    T2 -->|"builds"| U1
    T2 -->|"builds"| B1
    T3 -->|"deploys"| U1

    %% Styles and Colors
    classDef ui fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef logic fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef external fill:#F5B7B1,stroke:#922B21,stroke-width:2px;
    classDef cloud fill:#D7BDE2,stroke:#6C3483,stroke-width:2px;
    classDef testing fill:#A9DFBF,stroke:#196F3D,stroke-width:2px;
    classDef build fill:#FAD7A0,stroke:#B9770E,stroke-width:2px;

    %% Click Events
    click U1 "https://github.com/teamamaze/amazefilemanager/tree/release/4.0/app/src/main/java/com/amaze/filemanager/ui"
    click B1 "https://github.com/teamamaze/amazefilemanager/tree/release/4.0/app/src/main/java/com/amaze/filemanager/asynchronous"
    click B2 "https://github.com/teamamaze/amazefilemanager/tree/release/4.0/app/src/main/java/com/amaze/filemanager/filesystem"
    click B3 "https://github.com/teamamaze/amazefilemanager/tree/release/4.0/app/src/main/java/com/amaze/filemanager/database"
    click E1 "https://github.com/teamamaze/amazefilemanager/tree/release/4.0/commons_compress_7z/src/main/java/com/amaze/filemanager/filesystem/compressed/sevenz"
    click E2 "https://github.com/teamamaze/amazefilemanager/tree/release/4.0/file_operations/src/main/java/com/amaze/filemanager/fileoperations"
    click E3 "https://github.com/teamamaze/amazefilemanager/tree/release/4.0/portscanner/src/main/java/com/stealthcopter/networktools"
    click C1 "https://github.com/teamamaze/amazefilemanager/tree/release/4.0/app/src/fdroid/java/com/cloudrail/si/services"
    click T1 "https://github.com/teamamaze/amazefilemanager/tree/release/4.0/app/src/test"
    click T2 "https://github.com/teamamaze/amazefilemanager/blob/release/4.0/app/build.gradle"
    click T3 "https://github.com/teamamaze/amazefilemanager/tree/release/4.0/.github/workflows"
```
