# more-platform/more-app-multiplatform architecture

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

- Interactive diagram: https://gitdiagram.com/more-platform/more-app-multiplatform
- Repository: https://github.com/more-platform/more-app-multiplatform

## Overview

##### 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.

## Diagram (Mermaid)

```mermaid
graph TD
    A["Root Project"]:::root
    B["Android Application"]:::android
    C["iOS Application"]:::ios
    X["Shared Module"]:::shared
    G["CI/CD (GitHub Workflows)"]:::cd
    H["External Artifacts/Dependencies"]:::external

    subgraph "Shared Module Details"
        X1["commonMain"]:::subshared
        X1a["Database & Repositories"]:::subshared
        X1b["Network Services"]:::subshared
        X1c["Utilities"]:::subshared
        X2["androidMain"]:::subshared
        X3["iosMain"]:::subshared
    end

    A --> B
    A --> C
    A --> X
    B --> X
    C --> X
    X --> X1
    X --> X2
    X --> X3
    X1 --> X1a
    X1 --> X1b
    X1 --> X1c
    X1b -->|"feeds"| X1a
    A --> G
    A --> H

    click A "https://github.com/more-platform/more-app-multiplatform/blob/main/build.gradle.kts"
    click B "https://github.com/more-platform/more-app-multiplatform/tree/main/androidApp"
    click C "https://github.com/more-platform/more-app-multiplatform/tree/main/iosApp"
    click X "https://github.com/more-platform/more-app-multiplatform/tree/main/shared"
    click X1 "https://github.com/more-platform/more-app-multiplatform/tree/main/shared/src/commonMain/kotlin/io/redlink/more/more_app_mutliplatform"
    click X2 "https://github.com/more-platform/more-app-multiplatform/tree/main/shared/src/androidMain"
    click X3 "https://github.com/more-platform/more-app-multiplatform/tree/main/shared/src/iosMain"
    click G "https://github.com/more-platform/more-app-multiplatform/tree/main/.github/workflows"
    click H "https://github.com/more-platform/more-app-multiplatform/blob/main/.kotlin"

    classDef root fill:#A2D9CE,stroke:#1ABC9C,stroke-width:2px;
    classDef android fill:#F9E79F,stroke:#F1C40F,stroke-width:2px;
    classDef ios fill:#AED6F1,stroke:#3498DB,stroke-width:2px;
    classDef shared fill:#D2B4DE,stroke:#9B59B6,stroke-width:2px;
    classDef cd fill:#F5B7B1,stroke:#E74C3C,stroke-width:2px;
    classDef external fill:#D5F5E3,stroke:#27AE60,stroke-width:2px;
    classDef subshared fill:#FAD7A0,stroke:#E67E22,stroke-width:2px;
```
