# tuanemapero/baseprojectkmp architecture

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

- Interactive diagram: https://gitdiagram.com/tuanemapero/baseprojectkmp
- Repository: https://github.com/tuanemapero/baseprojectkmp

## Overview

##### Project type and purpose
- This is a Kotlin Multiplatform mobile demo. It ships:
- aiservicekmp – a reusable AI-service client library (remote datasources, models, signature, HTTP client)
- shared – the core business-logic module (domain models, use-cases, repository implementations, local persistence, remote-config, DataStore)
- androidApp – an Android-native wrapper that pulls in shared & aiservicekmp
- composeApp – a Compose Multiplatform UI that targets Android & iOS
- iosApp – an iOS-native shell that pulls in shared & aiservicekmp

##### File structure
- Top-level modules map to runtime artifacts:
- “aiservicekmp” and “shared” are MPP libraries (commonMain + androidMain + iosMain).
- “androidApp” is a pure Android application.
- “composeApp” is a cross-platform Compose UI application.
- “iosApp” is an Xcode project for iOS.
- Within each MPP library you see:
- commonMain/kotlin/com/... – platform-agnostic code (models, interfaces, DI modules, domain/use-cases)
- androidMain/… – Android-specific wiring (AndroidManifest, HTTP client, DB, signature parser)
- iosMain/… – iOS-specific wiring (HTTP client, signature parser, platform entry points)
- Patterns:
- Clean architecture (DataSource → Repository → UseCase → Presentation)
- DI via Koin (AiServiceModule, ClientModule, RepositoryModule, SharedModuleConfig, ComposeAppModule, ViewModelModule)
- Presentation: MVVM/MVI in composeApp, simple Activity in androidApp

##### Key takeaways
- 5 modules (androidApp, composeApp, iosApp, shared, aiservicekmp)
- Clean Architecture layering within shared & aiservicekmp
- Platform-specific code boundaries (androidMain vs. iosMain)
- Detail DI flow to tie everything together
- Keep it high-level; avoid drowning in file-tree minutiae, but call out important packages (data.datasource, data.repository, domain.usecase, presentation.viewmodel).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External
    ExternalAI["External AI Service"]:::external

    %% Library Layer
    subgraph "aiservicekmp"
        AiServiceModule["AiServiceModule.kt"]:::di
        ClientModule["ClientModule.kt"]:::di
        HttpClientAndroid["HttpClient.android.kt"]:::library
        HttpClientIOS["HttpClient.ios.kt"]:::library
    end

    ExternalAI -->|"HTTP Calls"| HttpClientAndroid
    ExternalAI -->|"HTTP Calls"| HttpClientIOS
    HttpClientAndroid --> ClientModule
    HttpClientIOS --> ClientModule
    ClientModule --> AiServiceModule

    %% Shared Core
    subgraph "shared"
        subgraph DI
            SharedModule["SharedModule.kt"]:::di
            UseCaseModule["UseCaseModule.kt"]:::di
            RepositoryModule["RepositoryModule.kt"]:::di
            DatabaseModule["DatabaseModule.kt"]:::di
        end
        subgraph "Domain Layer"
            GetCategoryUseCase["GetCategoryInHomeUseCase"]:::domain
            StyleRepositoryIfc["StyleItemRepository"]:::domain
        end
        subgraph "Data Layer"
            StyleRepoImpl["StyleItemRepositoryImpl"]:::data
            RemoteConfigRepo["RemoteConfigRepository"]:::data
            AppDatabase["AppDatabase"]:::data
        end
    end

    AiServiceModule --> SharedModule
    SharedModule --> UseCaseModule
    SharedModule --> RepositoryModule
    SharedModule --> DatabaseModule

    UseCaseModule --> GetCategoryUseCase
    RepositoryModule --> StyleRepositoryIfc
    DatabaseModule --> AppDatabase

    GetCategoryUseCase --> StyleRepositoryIfc
    StyleRepositoryIfc --> StyleRepoImpl
    StyleRepoImpl --> AppDatabase
    StyleRepoImpl --> RemoteConfigRepo
    StyleRepoImpl --> AiServiceModule

    %% ComposeApp Layer
    subgraph "composeApp"
        subgraph DI
            ComposeAppModule["ComposeAppModule.kt"]:::di
            ViewModelModule["ViewModelModule.kt"]:::di
        end
        subgraph "Presentation"
            AppVM["AppViewModel"]:::presentation
            HomeVM["HomeViewModel"]:::presentation
            ProfileVM["ProfileViewModel"]:::presentation
        end
        subgraph "UI Layer"
            AppScreen["AppScreen"]:::ui
            HomeScreen["HomeScreen"]:::ui
            ProfileScreen["ProfileScreen"]:::ui
        end
    end

    SharedModule -.-> ComposeAppModule
    ComposeAppModule --> AppVM
    ViewModelModule --> AppVM
    ComposeAppModule --> HomeVM
    ComposeAppModule --> ProfileVM

    AppVM --> GetCategoryUseCase
    HomeVM --> GetCategoryUseCase
    ProfileVM --> GetCategoryUseCase

    AppScreen --> AppVM
    HomeScreen --> HomeVM
    ProfileScreen --> ProfileVM

    %% AndroidApp
    subgraph "androidApp"
        MainActivity["MainActivity"]:::ui
        AppClass["App.kt"]:::ui
    end

    AppClass --> SharedModule
    MainActivity --> GetCategoryUseCase

    %% IOSApp
    subgraph "iosApp"
        IOSShell["iOSApp.swift"]:::ui
    end

    IOSShell --> GetCategoryUseCase
    IOSShell --> SharedModule

    %% Styles
    classDef ui fill:#a8d0e6,stroke:#000,color:#000;
    classDef presentation fill:#72efdd,stroke:#000,color:#000;
    classDef domain fill:#c1fba4,stroke:#000,color:#000;
    classDef data fill:#ffd97d,stroke:#000,color:#000;
    classDef library fill:#d1c4e9,stroke:#000,color:#000;
    classDef external fill:#ff8b94,stroke:#000,color:#000;
    classDef di fill:#eeeeee,stroke:#000,color:#000;

    %% Click Events
    click AiServiceModule "https://github.com/tuanemapero/baseprojectkmp/blob/master/aiservicekmp/src/commonMain/kotlin/com/apero/aiservicekmp/di/AiServiceModule.kt"
    click ClientModule "https://github.com/tuanemapero/baseprojectkmp/blob/master/aiservicekmp/src/commonMain/kotlin/com/apero/aiservicekmp/di/ClientModule.kt"
    click HttpClientAndroid "https://github.com/tuanemapero/baseprojectkmp/blob/master/aiservicekmp/src/androidMain/kotlin/com/apero/aiservicekmp/data/model/HttpClient.android.kt"
    click HttpClientIOS "https://github.com/tuanemapero/baseprojectkmp/blob/master/aiservicekmp/src/iosMain/kotlin/com/apero/aiservicekmp/data/model/HttpClient.ios.kt"
    click GetCategoryUseCase "https://github.com/tuanemapero/baseprojectkmp/blob/master/shared/src/commonMain/kotlin/com/apero/kmpdemo/domain/usecase/GetCategoryInHomeUseCase.kt"
    click StyleRepositoryIfc "https://github.com/tuanemapero/baseprojectkmp/blob/master/shared/src/commonMain/kotlin/com/apero/kmpdemo/domain/repository/StyleItemRepository.kt"
    click AppDatabase "https://github.com/tuanemapero/baseprojectkmp/blob/master/shared/src/commonMain/kotlin/com/apero/kmpdemo/data/local/database/AppDatabase.kt"
    click RemoteConfigRepo "https://github.com/tuanemapero/baseprojectkmp/blob/master/shared/src/commonMain/kotlin/com/apero/kmpdemo/data/common/remoteconfig/RemoteConfigRepository.kt"
    click StyleRepoImpl "https://github.com/tuanemapero/baseprojectkmp/blob/master/shared/src/commonMain/kotlin/com/apero/kmpdemo/data/repository/StyleItemRepositoryImpl.kt"
    click UseCaseModule "https://github.com/tuanemapero/baseprojectkmp/blob/master/shared/src/commonMain/kotlin/com/apero/kmpdemo/di/UseCaseModule.kt"
    click RepositoryModule "https://github.com/tuanemapero/baseprojectkmp/blob/master/shared/src/commonMain/kotlin/com/apero/kmpdemo/di/RepositoryModule.kt"
    click AppDatabase "https://github.com/tuanemapero/baseprojectkmp/blob/master/shared/src/androidMain/kotlin/com/apero/kmpdemo/data/local/AppDatabase.android.kt"
    click AppDatabase "https://github.com/tuanemapero/baseprojectkmp/blob/master/shared/src/iosMain/kotlin/com/apero/kmpdemo/data/local/AppDatabase.ios.kt"
    click MainActivity "https://github.com/tuanemapero/baseprojectkmp/blob/master/androidApp/src/main/java/com/apero/kmpdemo/android/MainActivity.kt"
    click AppClass "https://github.com/tuanemapero/baseprojectkmp/blob/master/androidApp/src/main/java/com/apero/kmpdemo/android/App.kt"
    click ComposeAppModule "https://github.com/tuanemapero/baseprojectkmp/blob/master/composeApp/src/commonMain/kotlin/com/apero/composeapp/di/ComposeAppModule.kt"
    click ViewModelModule "https://github.com/tuanemapero/baseprojectkmp/blob/master/composeApp/src/commonMain/kotlin/com/apero/composeapp/di/ViewModelModule.kt"
    click IOSShell "https://github.com/tuanemapero/baseprojectkmp/blob/master/iosApp/iosApp/iOSApp.swift"
```
