# denisbronx/real-clean-architecture-in-android---sample architecture

> Architecture diagram of the GitHub repository denisbronx/real-clean-architecture-in-android---sample, 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/denisbronx/real-clean-architecture-in-android---sample
- Repository: https://github.com/denisbronx/real-clean-architecture-in-android---sample

## Overview

- Library Modules (e.g., cache, httpclient, designsystem, foundations, viewmodel, etc.)
- Component Modules (e.g., cart-component, money-component, product-component, user-component, wishlist-component)
- UI Modules (e.g., cart-ui, main-ui, money-ui, onboarding-ui, plp-ui, wishlist-ui)
- App Module (the central coordinating module, which integrates navigation and dependency injection)

##### Clean Architecture Layers
- For each feature module (component and UI), show the separation into:
– Domain (business rules, use cases, entities): This layer is completely framework-independent.
– Data (repositories, data transfer objects, network & cache integration): These handle data sources.
– Presentation (UI components, ViewModels, screens): Found primarily in the UI modules.
- That component modules encapsulate domain and data layers, while UI modules expose the presentation layer.

##### Connections and Data Flow
- Within each feature area (e.g., Cart, Wishlist, etc.), show that the UI interacts with its corresponding component: the UI layer calls use cases or ViewModels that in turn rely on the domain and data layers represented in the associated component module.

##### Architectural Patterns and Design Principles
- That modularization is done by feature (Package by Component) rather than by typical layer, and note that component modules compile quickly since they’re pure Kotlin (or multiplatform) and independent from the Android framework.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% App Module
    subgraph "App Module"
        APP["App Module"]:::app
    end

    %% Library Modules
    subgraph "Library Modules"
        CACHE["Cache"]:::library
        HTTP["HTTP Client"]:::library
        DS["Design System"]:::library
        FND["Foundations"]:::library
        VM["ViewModel"]:::library
        CTD["Coroutines Test Dispatcher"]:::library
    end

    %% Component Modules
    subgraph "Component Modules"
        %% Cart Component
        subgraph "cart-component"
            CART_DOM["Cart Domain"]:::component
            CART_DATA["Cart Data"]:::component
            CART_DOM -->|"repo"| CART_DATA
        end

        %% Money Component
        subgraph "money-component"
            MONEY_DOM["Money Domain"]:::component
            MONEY_DATA["Money Data"]:::component
            MONEY_DOM -->|"repo"| MONEY_DATA
        end

        %% Product Component
        subgraph "product-component"
            PRODUCT_DOM["Product Domain"]:::component
            PRODUCT_DATA["Product Data"]:::component
            PRODUCT_DOM -->|"repo"| PRODUCT_DATA
        end

        %% User Component
        subgraph "user-component"
            USER_DOM["User Domain"]:::component
            USER_DATA["User Data"]:::component
            USER_DOM -->|"repo"| USER_DATA
        end

        %% Wishlist Component
        subgraph "wishlist-component"
            WISHLIST_DOM["Wishlist Domain"]:::component
            WISHLIST_DATA["Wishlist Data"]:::component
            WISHLIST_DOM -->|"repo"| WISHLIST_DATA
        end
    end

    %% UI Modules
    subgraph "UI Modules"
        CART_UI["Cart UI (Presentation)"]:::ui
        MAIN_UI["Main UI (Presentation)"]:::ui
        MONEY_UI["Money UI (Presentation)"]:::ui
        ONBOARDING_UI["Onboarding UI (Presentation)"]:::ui
        PLP_UI["PLP UI (Presentation)"]:::ui
        WISHLIST_UI["Wishlist UI (Presentation)"]:::ui
    end

    %% Connections from App Module to UI Modules and Component Modules
    APP -->|"navi"| CART_UI
    APP -->|"navi"| MAIN_UI
    APP -->|"navi"| MONEY_UI
    APP -->|"navi"| ONBOARDING_UI
    APP -->|"navi"| PLP_UI
    APP -->|"navi"| WISHLIST_UI

    APP -->|"DI"| CART_DOM
    APP -->|"DI"| MONEY_DOM
    APP -->|"DI"| PRODUCT_DOM
    APP -->|"DI"| USER_DOM
    APP -->|"DI"| WISHLIST_DOM

    %% Connections between UI Modules and corresponding Component Domains
    CART_UI -->|"usecase"| CART_DOM
    MONEY_UI -->|"usecase"| MONEY_DOM
    ONBOARDING_UI -->|"usecase"| USER_DOM
    PLP_UI -->|"usecase"| PRODUCT_DOM
    WISHLIST_UI -->|"usecase"| WISHLIST_DOM

    %% Library Modules provide support via dependency injection/dashed arrows to Component Data layers
    CACHE ---|"cache"| CART_DATA
    CACHE ---|"cache"| MONEY_DATA
    CACHE ---|"cache"| PRODUCT_DATA
    CACHE ---|"cache"| USER_DATA
    CACHE ---|"cache"| WISHLIST_DATA

    HTTP ---|"network"| CART_DATA
    HTTP ---|"network"| MONEY_DATA
    HTTP ---|"network"| PRODUCT_DATA
    HTTP ---|"network"| USER_DATA
    HTTP ---|"network"| WISHLIST_DATA

    %% Library Modules support UI modules as well (e.g., Design and ViewModel utilities)
    DS ---|"ui-style"| CART_UI
    DS ---|"ui-style"| MAIN_UI
    DS ---|"ui-style"| MONEY_UI
    DS ---|"ui-style"| ONBOARDING_UI
    DS ---|"ui-style"| PLP_UI
    DS ---|"ui-style"| WISHLIST_UI

    VM ---|"vm-helper"| CART_UI
    VM ---|"vm-helper"| MAIN_UI
    VM ---|"vm-helper"| MONEY_UI
    VM ---|"vm-helper"| ONBOARDING_UI
    VM ---|"vm-helper"| PLP_UI
    VM ---|"vm-helper"| WISHLIST_UI

    %% Styles for clarity
    classDef app fill:#FFA07A,stroke:#000,stroke-width:2px;
    classDef library fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef component fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef ui fill:#FFB6C1,stroke:#000,stroke-width:2px;

    %% Click Events for Library Modules
    click CACHE "https://github.com/denisbronx/real-clean-architecture-in-android---sample/tree/master/cache/src/commonMain/kotlin/com/denisbrandi/androidrealca/cache"
    click HTTP "https://github.com/denisbronx/real-clean-architecture-in-android---sample/tree/master/httpclient/src/commonMain/kotlin/com/denisbrandi/androidrealca/httpclient"
    click DS "https://github.com/denisbronx/real-clean-architecture-in-android---sample/tree/master/designsystem/src/main/java/com/denisbrandi/androidrealca/designsystem"
    click FND "https://github.com/denisbronx/real-clean-architecture-in-android---sample/tree/master/foundations/src/commonMain/kotlin/com/denisbrandi/androidrealca/foundations"
    click VM "https://github.com/denisbronx/real-clean-architecture-in-android---sample/tree/master/viewmodel/src/commonMain/kotlin/com/denisbrandi/androidrealca/viewmodel"
    click CTD "https://github.com/denisbronx/real-clean-architecture-in-android---sample/tree/master/coroutines-test-dispatcher/src/main/java/com/denisbrandi/androidrealca/coroutines/testdispatcher"

    %% Click Events for Component Modules
    click CART_DOM "https://github.com/denisbronx/real-clean-architecture-in-android---sample/tree/master/cart-component/src/commonMain/kotlin/com/denisbrandi/androidrealca/cart"
    click MONEY_DOM "https://github.com/denisbronx/real-clean-architecture-in-android---sample/tree/master/money-component/src/commonMain/kotlin/com/denisbrandi/androidrealca/money"
    click PRODUCT_DOM "https://github.com/denisbronx/real-clean-architecture-in-android---sample/tree/master/product-component/src/commonMain/kotlin/com/denisbrandi/androidrealca/product"
    click USER_DOM "https://github.com/denisbronx/real-clean-architecture-in-android---sample/tree/master/user-component/src/commonMain/kotlin/com/denisbrandi/androidrealca/user"
    click WISHLIST_DOM "https://github.com/denisbronx/real-clean-architecture-in-android---sample/tree/master/wishlist-component/src/commonMain/kotlin/com/denisbrandi/androidrealca/wishlist"

    %% Click Events for UI Modules
    click CART_UI "https://github.com/denisbronx/real-clean-architecture-in-android---sample/tree/master/cart-ui/src/main/java/com/denisbrandi/androidrealca/cart"
    click MAIN_UI "https://github.com/denisbronx/real-clean-architecture-in-android---sample/tree/master/main-ui/src/main/java/com/denisbrandi/androidrealca/main"
    click MONEY_UI "https://github.com/denisbronx/real-clean-architecture-in-android---sample/tree/master/money-ui/src/main/java/com/denisbrandi/androidrealca/money"
    click ONBOARDING_UI "https://github.com/denisbronx/real-clean-architecture-in-android---sample/tree/master/onboarding-ui/src/main/java/com/denisbrandi/androidrealca/onboarding"
    click PLP_UI "https://github.com/denisbronx/real-clean-architecture-in-android---sample/tree/master/plp-ui/src/main/java/com/denisbrandi/androidrealca/plp"
    click WISHLIST_UI "https://github.com/denisbronx/real-clean-architecture-in-android---sample/tree/master/wishlist-ui/src/main/java/com/denisbrandi/androidrealca/wishlist"

    %% Click Event for App Module
    click APP "https://github.com/denisbronx/real-clean-architecture-in-android---sample/tree/master/app/src/main/java/com/denisbrandi/androidrealca"
```
