# vaibhav2002/docubox-androidapp architecture

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

- Interactive diagram: https://gitdiagram.com/vaibhav2002/docubox-androidapp
- Repository: https://github.com/vaibhav2002/docubox-androidapp

## Overview

##### Project type and its purpose
- DocuBox is an Android mobile application that allows users to securely upload, organize, encrypt, and share their files. It connects to an external NodeJS backend deployed on Linode.
- The project adheres to modern Android development practices, clean code principles (SOLID), and employs MVVM as its core architecture.

##### File structure to identify the main components
- The “app” directory holds the Android project with clearly defined folders:
- The “src/main/java/com/docubox” package is organized into sub-packages like data, domain, service, di, ui, and util.
- Within “data,” note the separation between local (data sources, models, cache handling), remote (API services, remote data sources, remote models for authentication and file operations), and repository classes.
- The “ui” package contains adapters and screens organized by features such as authentication, main (home, documents, profile, search results), and dialogs.
- The “di” package contains modules for dependency injection (local and network related).
- Additional files include build and configuration files (Gradle scripts, AndroidManifest, etc.) and resource directories (layouts, drawables, navigation graphs) which underpin the UI and design.

##### README for further insights
- The README describes the project as a secure cloud file storage app that integrates with a NodeJS backend.
- It emphasizes key features (user authentication, file upload/download, file sharing, encryption, local data storage) and technical components (Retrofit for API calls, Kotlin coroutines and Flow for asynchronous operations, Jetpack libraries, Hilt for DI).
- The provided package structure outline in the README confirms the modularized design and the use of MVVM.

a. Main Components:
- Mobile Client (Android App)
- UI Layer (screens, adapters, fragments, activities)
- ViewModel Layer (handles state management, business logic communication)
- Domain Layer (abstracts repository interfaces, business rules)
- Data Layer:
▪ Local Data Sources (DataStore, local cache, file encryption services)
▪ Remote Data Sources (Retrofit API calls managed by services like AuthService and StorageService)
▪ Repositories that provide central data management (AuthRepoImpl, StorageRepoImpl, PreferencesRepoImpl)
- Service Component (background file upload service)
- Dependency Injection module (DI configuration with Hilt/Dagger)
- External Backend:
- NodeJS Server (hosted on Linode) handling authentication, file storage, encryption, and sharing
- REST APIs called via Retrofit from the mobile client

b. Relationships and interactions between components:
- The UI layer (Activity/Fragment) interacts directly with the ViewModel.
- The ViewModel communicates with one or more repository interfaces in the domain layer.
- Repositories decide whether to fetch data using remote data sources (via Retrofit and the API Service) or local ones (DataStore and local cache files).
- The DI modules are responsible for providing the instances for ViewModel, repositories, API clients, etc.
- A background service handles file uploads, communicating with the remote endpoints.
- Security aspects like file encryption are managed within the local data handling or utility classes.

c. Architectural patterns and design principles:
- MVVM is central: clear separation between UI, business logic (ViewModel), and data (repositories, local/remote sources).
- Dependency Injection (Hilt-Dagger) to promote low coupling.
- Repository pattern to abstract data access.
- SOLID and best practices for maintainability and testability.
- Use of asynchronous operations via Kotlin Coroutines and Flow.

d. Mention relevant technologies, frameworks, and libraries:
- Kotlin programming language, Android Jetpack components (ViewModel, LiveData/ViewBinding/DataBinding)
- Retrofit (with GSON converter) for API calling.
- Hilt-Dagger for dependency injection
- Kotlin Coroutines and Flow for managing asynchronous tasks.
- DataStore for local key-value storage.
- Timber for logging; Coil for image loading; Material Components for UI.

##### Elements
▪ Show bidirectional interactions where applicable (for instance, callbacks from repositories back to ViewModels).
- A brief note indicating the architectural pattern (MVVM) and list supporting libraries used.

##### Final advice
- Be very detailed, ensuring that every architectural layer from UI presentation to network communication is represented.
- Do not overly simplify; rather, decompose the system into as many fundamental components as necessary to capture the complete picture.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Mobile Client (Android App)
    subgraph "Mobile Client (Android App)"
        subgraph "UI Layer"
            UI["UI Screens & Adapters"] 
        end
        subgraph "ViewModel Layer"
            VM["ViewModels"]
        end
        subgraph "Domain Layer"
            Domain["Repository Interfaces & Business Rules"]
        end
        subgraph "Data Layer"
            subgraph "Local Data Sources"
                DS["DataStoreManager"]
                PM["PreferencesManager"]
                SC["StorageCache"]
            end
            subgraph "Remote Data Sources"
                AuthService["AuthService"]
                StorageService["StorageService"]
                AuthData["AuthDataSource"]
                StorageData["StorageDataSource"]
            end
            subgraph "Repositories"
                AuthRepo["AuthRepoImpl"]
                StorageRepo["StorageRepoImpl"]
                PrefRepo["PreferencesRepoImpl"]
            end
        end
    end

    %% Supporting Components
    subgraph "Supporting Components"
        subgraph "DI Module"
            LocalDI["LocalModule"]
            NetworkDI["NetworkModule"]
        end
        Service["FileUploadService"]
    end

    %% External Backend
    Backend["NodeJS Backend (Linode)"]

    %% Connections within Mobile Client
    UI -->|"to"| VM
    VM -->|"to"| Domain
    Domain -->|"calls"| AuthRepo
    Domain -->|"calls"| StorageRepo
    Domain -->|"calls"| PrefRepo

    %% Repository interactions with Data Sources
    AuthRepo -->|"local"| DS
    StorageRepo -->|"local"| SC
    PrefRepo -->|"local"| PM
    AuthRepo -->|"remote"| AuthService
    StorageRepo -->|"remote"| StorageService

    %% Remote Data Sources calling External Backend
    AuthService -->|"calls"| Backend
    StorageService -->|"calls"| Backend

    %% Background Service interaction
    Service -->|"uses"| StorageService

    %% Dependency Injection flows
    LocalDI -->|"injects"| VM
    LocalDI -->|"injects"| AuthRepo
    NetworkDI -->|"injects"| StorageRepo
    NetworkDI -->|"injects"| StorageService
    NetworkDI -->|"injects"| Service

    %% Click Events
    click UI "https://github.com/vaibhav2002/docubox-androidapp/tree/master/app/src/main/java/com/docubox/ui/screens"
    click VM "https://github.com/vaibhav2002/docubox-androidapp/blob/master/app/src/main/java/com/docubox/ui/screens/auth/login/LoginViewModel.kt"
    click Domain "https://github.com/vaibhav2002/docubox-androidapp/tree/master/app/src/main/java/com/docubox/domain/repo"
    click DS "https://github.com/vaibhav2002/docubox-androidapp/blob/master/app/src/main/java/com/docubox/data/local/dataSources/dataStore/DataStoreManager.kt"
    click PM "https://github.com/vaibhav2002/docubox-androidapp/blob/master/app/src/main/java/com/docubox/data/local/dataSources/dataStore/PreferencesManager.kt"
    click SC "https://github.com/vaibhav2002/docubox-androidapp/blob/master/app/src/main/java/com/docubox/data/local/StorageCache.kt"
    click AuthService "https://github.com/vaibhav2002/docubox-androidapp/blob/master/app/src/main/java/com/docubox/data/remote/api/AuthService.kt"
    click StorageService "https://github.com/vaibhav2002/docubox-androidapp/blob/master/app/src/main/java/com/docubox/data/remote/api/StorageService.kt"
    click AuthData "https://github.com/vaibhav2002/docubox-androidapp/blob/master/app/src/main/java/com/docubox/data/remote/dataSources/AuthDataSource.kt"
    click StorageData "https://github.com/vaibhav2002/docubox-androidapp/blob/master/app/src/main/java/com/docubox/data/remote/dataSources/StorageDataSource.kt"
    click AuthRepo "https://github.com/vaibhav2002/docubox-androidapp/blob/master/app/src/main/java/com/docubox/data/repo/AuthRepoImpl.kt"
    click StorageRepo "https://github.com/vaibhav2002/docubox-androidapp/blob/master/app/src/main/java/com/docubox/data/repo/StorageRepoImpl.kt"
    click PrefRepo "https://github.com/vaibhav2002/docubox-androidapp/blob/master/app/src/main/java/com/docubox/data/repo/PreferencesRepoImpl.kt"
    click Service "https://github.com/vaibhav2002/docubox-androidapp/blob/master/app/src/main/java/com/docubox/service/FileUploadService.kt"
    click LocalDI "https://github.com/vaibhav2002/docubox-androidapp/blob/master/app/src/main/java/com/docubox/di/LocalModule.kt"
    click NetworkDI "https://github.com/vaibhav2002/docubox-androidapp/blob/master/app/src/main/java/com/docubox/di/NetworkModule.kt"

    %% Styles
    classDef client fill:#E1F5FE,stroke:#0277BD,stroke-width:2px;
    classDef di fill:#FFF9C4,stroke:#F9A825,stroke-width:2px;
    classDef backend fill:#C8E6C9,stroke:#2E7D32,stroke-width:2px;

    class UI,VM,Domain,DS,PM,SC,AuthService,StorageService,AuthData,StorageData,AuthRepo,StorageRepo,PrefRepo,Service client;
    class LocalDI,NetworkDI di;
    class Backend backend;
```
