# netguru/rnd-retail-multiplatform-public architecture

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

- Interactive diagram: https://gitdiagram.com/netguru/rnd-retail-multiplatform-public
- Repository: https://github.com/netguru/rnd-retail-multiplatform-public

## Overview

Based on our analysis of the file tree and README, this project is a Kotlin Multiplatform Mobile (KMM) application for an eCommerce furniture retail use case. The purpose is to demonstrate shared logic, state management, and resources (such as 3D models, images, fonts, strings) across iOS and Android, while encapsulating domain, data, and resource management into separate modules.

##### Main Components
- Application Frontends:
- androidApp: Contains Android-specific code including UI components (Activities, Compose views, fragments) and platform-specific configurations.
- iosApp: Contains iOS-specific code such as ViewControllers, SwiftUI views, storyboards, and resource handling.

- Shared Modules (KMM):
- common: The umbrella module that aggregates shared resources and logic, initializing the dependency graph and exposing the central Provider.
- commonDomain: This module contains the heart of the business logic. It holds the application state mechanisms (Stores), services, queries, and other domain-specific business logic.
- commonData: Implements data-related functions and dependencies. It provides implementations for various data interfaces used in the domain module.
- buildSrc: Contains Kotlin-based dependency management and build configuration logic shared across Android and iOS.

- External Tools/Configurations:
- Build scripts and configuration files (e.g., build.gradle.kts files, gradle.properties) that manage project dependencies and multiplatform setup.
- CocoaPods configuration in the iOS module (Podfile) used to integrate common libraries.

##### Relationships and Interactions
- The common module serves as a bridge between the platform-specific modules (androidApp and iosApp) and the shared business logic in commonDomain, data in commonData, and resources in commonResources.
- The Dependency Injection (DI) mechanism is set up in the common module to expose a single Provider factory, initializing and connecting Stores (state holders), Services (logic handlers), and Queries (data read/transform layer).
- Android and iOS frontends interact with the shared core via exposed APIs from the common module.
- Shared resources (images, fonts, strings) are consumed by both platforms using the Moko-resources library, adhering to platform-specific usage patterns.

##### Architectural Patterns and Design Principles
- Unidirectional Data Flow: The architecture distinctly separates writing business logic (Services that update the Store) and reading business logic (Queries to transform data for UI rendering). This separation improves modularity and maintainability.
- Dependency Inversion: The design leverages plugin modules (e.g., commonData) that provide concrete implementations for interfaces declared in the domain, promoting loosely coupled components.
- Platform Abstraction: Platform-specific modules (androidApp and iosApp) solely handle UI and platform-specific concerns, offloading business logic to the shared modules.
- Single Responsibility: Different domain units (Stores, Services, Queries) are responsible for specific aspects of state management and business logic.

##### Technologies, Frameworks, and Libraries
- Kotlin Multiplatform for sharing business logic and resources across iOS and Android.
- Moko-resources for managing shared resources like images, fonts, and strings.
- Android Studio’s infrastructure (Gradle, Jetpack Compose in parts) for Android UI.
- Xcode with Swift/SwiftUI for the iOS frontend.
- Dependency Injection pattern to initialize and expose modules across platforms.

##### Detail Coverage
- UI/Presentation Layer (iOS and Android frontends)
- Shared Logic/Business Layer (commonDomain, commonData)
- Resource Management (commonResources)
- Cross-cutting Build and Dependency Management Layer (buildSrc, Gradle/CocoaPods)

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Mobile Frontends"
        A("androidApp") 
        I("iosApp")
    end

    subgraph "Shared Modules"
        CP("common")
        CD("commonDomain")
        CData("commonData")
        CR("commonResources")
    end

    BS("buildSrc")

    A -->|"callsProvider"| CP
    I -->|"callsProvider"| CP
    CP -->|"initializesDI"| CD
    CD -->|"fetchesData"| CData
    CD -->|"usesResources"| CR

    BS -->|"buildConfig"| A
    BS -->|"buildConfig"| I
    BS -->|"managesDependencies"| CP

    click A "https://github.com/netguru/rnd-retail-multiplatform-public/tree/main/androidApp"
    click I "https://github.com/netguru/rnd-retail-multiplatform-public/tree/main/iosApp"
    click CP "https://github.com/netguru/rnd-retail-multiplatform-public/blob/main/common/src/commonMain/kotlin/com/netguru/retail/Provider.kt"
    click CD "https://github.com/netguru/rnd-retail-multiplatform-public/tree/main/commonDomain"
    click CData "https://github.com/netguru/rnd-retail-multiplatform-public/tree/main/commonData"
    click CR "https://github.com/netguru/rnd-retail-multiplatform-public/tree/main/commonResources"
    click BS "https://github.com/netguru/rnd-retail-multiplatform-public/tree/main/buildSrc"

    classDef frontend fill:#ffcc00,stroke:#333,stroke-width:2px;
    classDef common fill:#66ccff,stroke:#333,stroke-width:2px;
    classDef build fill:#99ff99,stroke:#333,stroke-width:2px;

    class A,I frontend;
    class CP,CD,CData,CR common;
    class BS build;
```
