# dattran2k/jetpack-compose-catalog architecture

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

- Interactive diagram: https://gitdiagram.com/dattran2k/jetpack-compose-catalog
- Repository: https://github.com/dattran2k/jetpack-compose-catalog

## Overview

##### Main Components
- App Module (Android Client)
- Entry point of the application (MainActivity, MyApplication)
- Android lifecycle components and ViewModel (Local UI logic)
- UI Module
- Houses Compose UI screens and feature implementations (Catalog screens for layout, animation, menu, and navigation)
- Organizes navigation and feature-specific UI components (e.g., CatalogCompose, CatalogOverview, MainScreen)
- Core Module (with submodules)
- Data: Contains repository implementations and dependency injection (e.g., DataModule, UserDataRepository)
- Datastore: Manages persistent storage through DataStore for user preferences and theme settings (PreferenceDataSource, serializers, etc.)
- Model: Defines the application's data models used across modules (UserData, DarkThemeConfig, UI models for Compose)
- Benchmark Module
- Contains performance test cases (for startup benchmarks) to measure and optimize the UI responsiveness

##### Relationships and Interactions
- Android App (in the “app” module) is the runtime host and consumer of the UI and core services.
- The MainActivity interacts with its corresponding ViewModel, which in turn leverages business logic from the core modules.
- And navigation logic implemented in the UI module will be invoked from MainActivity and its associated screens.
- The UI module calls into the DesignSystem (from core/designsystem) to render custom UI components and apply themes.
- The Data and Datastore submodules (core/data and core/datastore) interact with each other via dependency injection and service locator patterns (as set up in the respective DI packages), forming the data layer that supports features like user settings and theming.
- The Model module provides a common set of data definitions that are shared across the Data, UI, and Datastore layers.

##### Architectural Patterns & Design Principles
- MVVM (Model-View-ViewModel): Evident in the use of ViewModels and separation between business logic (core/data) and UI (ui module).
- Modularity: Clear separation between app, UI, core, and benchmark modules allow individual components to be developed and tested in isolation.
- Dependency Injection: The project uses DI modules (e.g., in core/data/di and core/datastore/di) to wire up dependencies.
- Component-based UI: The design system is built with reusable Compose components that are extended and customized.

##### Relevant Technologies, Frameworks, or Libraries
- Jetpack Compose for UI rendering and navigation (compose screens, animations, layouts).
- Material3 for modern UI theming.
- Android DataStore for persistent data storage.
- Gradle Kotlin DSL (build.gradle.kts files) managing project setup.
- Android testing frameworks for instrumented and unit tests (in the androidTest and test directories).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Android Runtime Layer
    subgraph "Android Runtime (App Module)"
        A["App Module: MainActivity, MyApplication, ViewModel"]:::android
    end

    %% UI Layer
    subgraph "UI Layer"
        U["UI Module: Compose Screens, Navigation"]:::ui
    end

    %% Core Module
    subgraph "Core Module"
        subgraph "Data Layer"
            D["Core/Data: Repositories, DI Modules"]:::coreData
        end
        subgraph "Datastore Layer"
            DS["Core/Datastore: UserPreferences, Proto Configurations"]:::coreDatastore
        end
        subgraph "Design System"
            DSys["Core/DesignSystem: Themes, Custom UI Components"]:::designsystem
        end
        subgraph "Model Layer"
            M["Core/Model: Data Models"]:::coreModel
        end
    end

    %% Benchmark Module
    subgraph "Benchmarking"
        B["Benchmark Module: Performance Tests"]:::benchmark
    end

    %% Relationships
    A -->|"triggers Navigation"| U
    A -->|"calls DataLayer"| D
    A -->|"accesses Persistence"| DS
    U -->|"applies Themes"| DSys
    U -->|"uses Models"| M
    D -->|"uses Models"| M
    DS -->|"uses Models"| M
    B -->|"tests Startup"| A

    %% Click Events
    click A "https://github.com/dattran2k/jetpack-compose-catalog/tree/master/app/src/main/java/com/dat/jetpackcomposecatalog"
    click U "https://github.com/dattran2k/jetpack-compose-catalog/tree/master/ui/src/main/java/com/dat/ui"
    click D "https://github.com/dattran2k/jetpack-compose-catalog/tree/master/core/data/src/main/java/com/dat/core/data"
    click DS "https://github.com/dattran2k/jetpack-compose-catalog/tree/master/core/datastore/src/main/java/com/dat/core/datastore"
    click DSys "https://github.com/dattran2k/jetpack-compose-catalog/tree/master/core/designsystem/src/main/java/com/dat/core/designsystem"
    click M "https://github.com/dattran2k/jetpack-compose-catalog/tree/master/core/model/src/main/java/com/dat/core/model"
    click B "https://github.com/dattran2k/jetpack-compose-catalog/tree/master/benchmark/src/main/java/com/dat/benchmark"

    %% Styles
    classDef android fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef ui fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef coreData fill:#FFE4B5,stroke:#000,stroke-width:2px;
    classDef coreDatastore fill:#FFDEAD,stroke:#000,stroke-width:2px;
    classDef designsystem fill:#E6E6FA,stroke:#000,stroke-width:2px;
    classDef coreModel fill:#F0E68C,stroke:#000,stroke-width:2px;
    classDef benchmark fill:#FF7F7F,stroke:#000,stroke-width:2px;
```
