# garghimanshu0786/minimallauncher architecture

> Architecture diagram of the GitHub repository garghimanshu0786/minimallauncher, 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/garghimanshu0786/minimallauncher
- Repository: https://github.com/garghimanshu0786/minimallauncher

## Overview

##### Main Components
- UI/Presentation Layer: This is clearly defined under the “view” directory with subdirectories like “composeui” (e.g., AllAppsView.kt, LauncherScreen.kt, SettingsScreen.kt). Also, there’s a theme package to handle styling.
- ViewModels: Located under the “viewmodels” directory (e.g., LauncherViewModel.kt) which manage UI state and communicate with the business logic.
- Dependency Injection (DI): Present within the “di” package (e.g., AppModule.kt). This indicates the use of Dagger Hilt for managing dependencies.
- Local Storage/Data Layer: The “localstorage” package includes interfaces and implementations (ILocalStorage.kt, PreferenceDataStore.kt) for persistent storage.
- Utility Functions: The “utils” directory provides helper methods (like AppUtility.kt and Kotlin extension functions) which support various application functionalities.
- Models: The “models” package holds data classes like AppInfo.kt that encapsulate the application’s core data elements.
- Testing: Separate test directories for unit tests as well as instrumented tests that ensure the components interact correctly.

##### Relationships and Interactions
- The UI Layer uses Jetpack Compose components to render the launcher screens. It interacts with ViewModels through reactive data flows (using Flow and Kotlin Coroutines) to update the UI as the user interacts with the launcher.
- ViewModels, acting as the mediator, retrieve or update data from the local storage or any other utility layer and also use the dependency injections provided via Dagger Hilt.
- The DI system comes in early to inject the necessary dependencies into the ViewModels, local storage, and other services ensuring modularity and easier testing.
- The application follows modern Android architectural patterns that separate concerns (presentation, state management, and data access). The use of Compose promotes a declarative UI flow, while DI and ViewModels uphold separation of business logic.

##### Incorporate Architectural Patterns and Technologies
- The project uses a Clean MVVM Pattern:
a. Model: Represents app data, e.g., AppInfo.
b. View (Compose UI): A set of composable functions handling the front-end and UI interactions.
c. ViewModel: Manages UI state and business logic.
- Dagger Hilt is integrated for dependency injection.
- DataStore is used for local persistent storage.
- Kotlin Coroutines and Flow deliver asynchronous operations and data flow management.
- Additionally, the project structure shows clearly distinct folders for tests, indicating a focus on separation of concerns and testability.

##### Specific Elements
- Android Launcher Entry Point (MainActivity)
- Compose UI Screens (e.g., LauncherScreen, SettingsScreen, AppList views)
- ViewModels (e.g., LauncherViewModel)
- DI Container (Dagger Hilt, with AppModule and any related classes)
- Local Storage (PreferenceDataStore, ILocalStorage)
- Utility and Extensions (common helper functions)
- Models/Data Entities (e.g., AppInfo)
- Data flow from the UI to the ViewModel and back.
- Dependency injection paths from the DI container to various components.
- Communication between the ViewModel and local storage.

##### Detailed Explanation for the Principal Software Engineer
- The top layer is the UI built with Jetpack Compose which interacts with the user through various screens (launcher, settings, app lists, etc.).
- Directly below are the ViewModels that encapsulate UI state and handle events triggered by the UI, making use of Kotlin Coroutines and Flow for asynchronous operations.
- Next, include the dependency injection layer (Dagger Hilt) that wires together the ViewModels, local storage components, and utility functions.
- The data layer, comprising classes for managing local persistent data (DataStore) and models, should be shown next.
- Following:
- Communication flows: How user input on the UI results in state updates via the ViewModel, and how data is persisted or retrieved from local storage.
- Modular approach: The decoupling of the UI from business logic and data handling achieved through usage of MVVM architecture and DI.
- Testing: Although not part of the runtime architecture, include annotations that testing is separately maintained to ensure robustness.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% UI Layer
    subgraph "UI Layer"
        A["MainActivity"]:::entry
        B["Compose UI Screens"]:::ui
        C["Theme & Styling"]:::ui
    end

    %% ViewModel Layer
    subgraph "ViewModel Layer"
        D["LauncherViewModel"]:::vm
    end

    %% Dependency Injection Layer
    subgraph "DI Layer"
        E["DI Container (Dagger Hilt)"]:::di
    end

    %% Data Layer
    subgraph "Data Layer"
        F["Local Storage (DataStore)"]:::data
        G["Models (AppInfo)"]:::model
    end

    %% Utility Layer
    subgraph "Utility Layer"
        H["Utility Functions"]:::util
    end

    %% Connections within UI Layer
    A -->|"launches"| B
    A -->|"initializes"| E
    B -->|"triggers updates"| D
    C -->|"supports UI"| B

    %% ViewModel interactions
    D -->|"retrieves/updates"| F
    D -->|"uses"| H

    %% Dependency Injection flows
    E -->|"injects dependency"| D
    E -->|"injects dependency"| F
    E -->|"injects dependency"| H

    %% Data Layer interactions
    F -->|"persists data"| G

    %% Click Events
    click A "https://github.com/garghimanshu0786/minimallauncher/blob/master/app/src/main/java/com/example/ciscolauncher/MainActivity.kt"
    click B "https://github.com/garghimanshu0786/minimallauncher/tree/master/app/src/main/java/com/example/ciscolauncher/view/composeui"
    click C "https://github.com/garghimanshu0786/minimallauncher/tree/master/app/src/main/java/com/example/ciscolauncher/ui/theme"
    click D "https://github.com/garghimanshu0786/minimallauncher/blob/master/app/src/main/java/com/example/ciscolauncher/viewmodels/LauncherViewModel.kt"
    click E "https://github.com/garghimanshu0786/minimallauncher/blob/master/app/src/main/java/com/example/ciscolauncher/di/AppModule.kt"
    click F "https://github.com/garghimanshu0786/minimallauncher/tree/master/app/src/main/java/com/example/ciscolauncher/localstorage"
    click G "https://github.com/garghimanshu0786/minimallauncher/blob/master/app/src/main/java/com/example/ciscolauncher/models/AppInfo.kt"
    click H "https://github.com/garghimanshu0786/minimallauncher/tree/master/app/src/main/java/com/example/ciscolauncher/utils"

    %% Styles
    classDef entry fill:#FADBD8,stroke:#E74C3C,stroke-width:2px;
    classDef ui fill:#FAD7A0,stroke:#E67E22,stroke-width:2px;
    classDef vm fill:#AED6F1,stroke:#3498DB,stroke-width:2px;
    classDef di fill:#A9DFBF,stroke:#27AE60,stroke-width:2px;
    classDef data fill:#F9E79F,stroke:#F1C40F,stroke-width:2px;
    classDef model fill:#F5B7B1,stroke:#E74C3C,stroke-width:2px;
    classDef util fill:#D2B4DE,stroke:#8E44AD,stroke-width:2px;
```
