How more-platform/more-app-multiplatform works
Project Type and Purpose
• Type: This is a Kotlin Multiplatform Mobile project that supports both Android and iOS platforms.
• Purpose: The core idea is to share common business logic via a “shared” module while having platform-specific implementations in separate androidApp and iosApp projects. The README emphasizes the cross-platform mobile architecture along with integration using Gradle (for Android/Shared) and Xcode (for iOS).
Main Components
• Root Project: As the top-level Gradle project that underpins the multi-module structure. It includes configuration files (build.gradle.kts, settings.gradle.kts, Gradle wrapper files) and global settings.
• Android Application (androidApp): Contains Android-specific code, UI components (activities, view models, composables), resources, services (for bluetooth, push notifications, sensors, etc.), and Gradle build files.
• iOS Application (iosApp): Consists of an Xcode project with Swift code (AppDelegate, ContentView, Controllers, observables, views, etc.), resource bundles (assets, localization files) and iOS-specific service implementations (bluetooth, background tasks, etc.).
• Shared Module (shared): Contains the common core logic for both platforms. It is structured into three source sets: commonMain for actual shared code, androidMain for Android-specific implementations, and iosMain for iOS-specific implementations. This module further holds the common data models, repositories (Realm database, notification, observation, schedule devices), networking (Ktor, OpenAPI based calls), and other shared utilities.
• CI/CD and Build Configurations: The .github/workflows folder shows GitHub Actions for build and deploy automation.
• External Artifacts/Dependencies: Various Kotlin libraries and interop modules (as seen in the .kotlin subdirectories) for integrating with native platforms, such as Realm, ktor, napier, atomicfu, and others.
Relationships and Interactions
• The Android and iOS apps both depend on the shared module. They interact with the shared code through a generated framework (for iOS) or a dependency (for Android).
• Communication exists between UI components and underlying services in each platform (e.g., activities and view models, SwiftUI views and view models).
• The shared module contains key business logic such as database management, networking (to call the MobileApp API defined in openapi), repository patterns, and state management.
• External services, like Firebase, network services (through ktor and openapi), and local storage providers, are integrated via services defined both in platform-specific and shared layers.
Architectural Patterns and Design Principles
• Separation of Concerns: Clear distinctions are made between platform-specific UI and shared business logic.
• Expect/Actual Mechanism: Used within the shared module to provide platform-specific implementations while keeping a common interface.
• Gradle Multi-Project Build: The Android app, shared module, and root configuration are coordinated using Gradle’s multi-project mechanism.
• Modularization for Clean Architecture: The repositories, network services, and observers are split into clearly defined modules in the shared module promoting testability and extensibility.
Specific Elements
• Labels for Each Component:
• Root Project (with Gradle build configuration)
• Android App (showing activities, view models, UI fragments, data recording services, local push notifications, etc.)
• iOS App (including AppDelegate, SwiftUI views, notification service extension, background tasks)
• Shared Module: Divide into commonMain, androidMain, iosMain – and within commonMain, highlight subcomponents (database layer, repository layer, network layer, observation management, etc.)
• From Android and iOS to the Shared Module to indicate dependency and usage.
• Between services and repositories to indicate data flow (for example, from Network Service to Repository, and Repository to UI/view models).
• Cluster CI/CD (GitHub workflows) in one area to indicate automation.
• An optional section for external APIs/integrations (Firebase, remote API endpoints defined by openapi/MobileAppAPI.yaml) can be shown.