How ashoktallapelli/cherrykmp works
Main Components Identification
• Mobile Clients:
• Android Client (androidApp): Contains platform-specific UI components (MainActivity, MyApplication, Compose layouts, etc.).
• iOS Client (iosApp): Contains iOS-specific files (iOSApp.swift, ContentView.swift, Assets, configuration files).
• Shared Module (shared):
• Holds the common code divided by platform-specific sources (androidMain, iosMain) and commonMain.
• Contains several packages/sub-layers:
○ UI components (under "ui" including navigation and theme stuff).
○ Domain layer – Use cases, models, exceptions (under "domain").
○ Data layer – Network API definitions, repositories, data sources (both local with Room/Dao and network with Ktor).
○ Dependency Injection – Koin configuration (in "di").
• External Services:
• News API as the external data provider.
• Infrastructure Components:
• Local Database structure (Room, DAOs, entities).
• File configurations (gradle, settings, project metadata).
Relationships and Interactions
• Data Flow:
• The Android and iOS UIs interact with their related ViewModels.
• The ViewModels retrieve data by invoking use cases from the Domain layer.
• Use cases in turn abstract calls to repositories in the Data layer.
• The Data layer fetches news data either from the News API (network layer with Ktor) or locally stored data (Room for Android and platform-specific solutions for iOS).
• Dependency Injection with Koin ensures dependencies like networking clients and data stores are provided to the presentation and data layers.
• Shared modules ensure that business logic and UI components (Compose-based UI) are maintained once and then used on both platforms with minor platform-specific adjustments.
Architectural Patterns and Design Principles
• MVVM Pattern:
• Model: Represented by the Domain and Data layers.
• View: Android and iOS presentation layer components.
• ViewModel: Bridges the Domain and UI, managing state and presentation logic.
• Clean Architecture Layers:
• Presentation: Contains UI components (screens, navigation, themes).
• Domain: Contains the business logic in the form of use cases and model definitions.
• Data: Manages data sources including local persistence and remote API calls.
• Modularization: The separation into androidApp, iosApp, and shared modules.
• Cross-Platform Code Sharing: Carefully splitting code among commonMain, androidMain, and iosMain.
Relevant Technologies and Frameworks
• Kotlin Multiplatform – Central to code sharing.
• Compose Multiplatform – For declarative UI on supported platforms.
• Ktor – For performing network calls to the News API.
• Room – For Android database persistence.
• Datastore – For storing key-value pairs.
• Koin – For dependency injection.
• Kotlin Coroutines – For managing asynchronous operations throughout the app.
Practical Steps for the Principal Software Engineer
• Within the Shared section, break it down into the three Clean Architecture layers (Presentation, Domain, Data).
• Nodes for external dependencies like the News API, Room Database, etc.
– UI (Android/iOS) → ViewModel (in Shared) → Use Cases (Domain) → Repository (Data) → (Either local DB or News API).