# zengcanxiang/wankmp architecture

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

- Interactive diagram: https://gitdiagram.com/zengcanxiang/wankmp
- Repository: https://github.com/zengcanxiang/wankmp

## Overview

Overview:
This project, WanKMP, is a Kotlin Multiplatform (KMP) application designed to run on Android, iOS, Web, and desktop. Its purpose is both educational and demonstrative—it serves as a testbed for integrating various Kotlin Multiplatform features and libraries (such as Ktor for networking, kotlinx serialization, datetime, paging, datastore, etc.), and exploring platform-specific capabilities while sharing core business logic.

Key Components to Represent:
##### Shared Core ("composeApp/commonMain")
- This module contains the common business logic and shared UI components.
- It is the heart of the multiplatform project where technologies like coroutines, flow, and shared libraries (ktor, serialization, etc.) are used.
##### Platform-specific Modules
- Android: Located in "composeApp/androidMain"; includes AndroidManifest.xml, Android-specific implementations (like Platform.android.kt), and resources (drawable, mipmap, values).
- iOS: Implementations live in "composeApp/iosMain" (e.g., Platform.ios.kt, MainViewController.kt) and the separate iOS native app folder "iosApp" which contains Xcode project configuration, assets, and Swift-based integration.
- Desktop: Found in "composeApp/desktopMain"; responsible for desktop-specific code (e.g., Platform.jvm.kt and main.kt).
- Web (wasm/JS): Modules under "composeApp/wasmJsMain" handle the web/WASM specific implementations, including resources like index.html.
##### Documentation/Reference
- The README and its subdocuments provide detailed explanations for each key dependency (networking, serialization, debugging, datetime, etc.)
- These documents (organized under README/*) highlight specific topics and can be represented as informational nodes or modules that clarify external dependencies and design rationale.
##### Build and Configuration
- Gradle scripts (build.gradle.kts, settings.gradle.kts, gradle properties, wrapper scripts) configure project builds across platforms.
- Version and dependency management are defined in gradle/libs.versions.toml.

Diagramming Guidelines:
A. Components and Layers:
2. Around it, position the platform-specific modules (Android, iOS, Desktop, Web) as distinct blocks. Each should indicate its integration path with the shared core.
3. External iOS native app ("iosApp") that further wraps the iOS module for native integration.
4. A block for the build system (Gradle) and configuration management, highlighting interactions with all modules.

B. Relationships and Data Flow:
4. Documentation nodes (from the README topics) that provide supplementary context on debugging, dependency usage, and runtime behavior.

C. Architectural Patterns and Design Principles:
1. Multiplatform approach—highlight separation of concerns between shared business logic (commonMain) versus platform-specific implementations.
2. That the project leverages dependency injection (even if implicit) and layering (platform abstraction layer) to manage platform differences.
- Core/shared modules,
- Platform-specific components,
- External dependencies, and
- Build/configuration aspects.

D. Specific Technologies/Frameworks:
1. Mention that the project is built with Kotlin and uses Gradle as the build tool.
2. Libraries: Ktor (networking), kotlinx serialization, kotlinx datetime, paging, datastore, coroutines/flow.
3. Platform-specific technologies like Android’s resources and manifest, iOS’s Xcode project files and UIKit/Swift integration, desktop and WASM specifics.

1. For a full-stack style view, clearly delineate shared logic vs. platform-specific adaptations.
2. That each platform branch is well-labeled and that dependencies and key third-party libraries (mentioned in the README) are visibly linked.
3. Distinguish between compile-time (build configurations, Gradle scripts) and runtime components (UI layers, platform-specific behaviors).

- Use clear labels on each component and module.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Top Layer: Build & Config and Documentation
    BuildConfig["Build & Config"]:::build
    Documentation["Documentation/Reference"]:::documentation
    External["External Libraries"]:::external

    %% Middle Layer: Shared Core
    SharedCore["Shared Core (composeApp/commonMain)"]:::shared

    %% Bottom Layer: Platform-specific Modules
    subgraph "Platform Modules"
        AndroidModule["Android Module (composeApp/androidMain)"]:::platform
        iOSModule["iOS Module (composeApp/iosMain)"]:::platform
        DesktopModule["Desktop Module (composeApp/desktopMain)"]:::platform
        WebModule["Web Module (composeApp/wasmJsMain)"]:::platform
        iOSNative["iOS Native App (iosApp)"]:::platform
    end

    %% Relationships: Build & Config & Documentation feed Shared Core
    BuildConfig -->|"configures"| SharedCore
    Documentation -->|"informs"| SharedCore
    External -->|"provides"| SharedCore

    %% Shared Core feeds platform modules
    SharedCore -->|"supplies_common_logic"| AndroidModule
    SharedCore -->|"supplies_common_logic"| iOSModule
    SharedCore -->|"supplies_common_logic"| DesktopModule
    SharedCore -->|"supplies_common_logic"| WebModule

    %% Build & Config also connects to each platform module
    BuildConfig -->|"builds"| AndroidModule
    BuildConfig -->|"builds"| iOSModule
    BuildConfig -->|"builds"| DesktopModule
    BuildConfig -->|"builds"| WebModule

    %% iOS Module connects to native iOS integration
    iOSModule -->|"integrates_with"| iOSNative

    %% Click Events
    click SharedCore "https://github.com/zengcanxiang/wankmp/tree/main/composeApp/src/commonMain"
    click AndroidModule "https://github.com/zengcanxiang/wankmp/tree/main/composeApp/src/androidMain"
    click iOSModule "https://github.com/zengcanxiang/wankmp/tree/main/composeApp/src/iosMain"
    click iOSNative "https://github.com/zengcanxiang/wankmp/tree/main/iosApp"
    click DesktopModule "https://github.com/zengcanxiang/wankmp/tree/main/composeApp/src/desktopMain"
    click WebModule "https://github.com/zengcanxiang/wankmp/tree/main/composeApp/src/wasmJsMain"
    click Documentation "https://github.com/zengcanxiang/wankmp/tree/main/README"
    click BuildConfig "https://github.com/zengcanxiang/wankmp/blob/main/build.gradle.kts"

    %% Styles
    classDef shared fill:#BBDEFB,stroke:#0D47A1,stroke-width:2px;
    classDef platform fill:#C8E6C9,stroke:#1B5E20,stroke-width:2px;
    classDef build fill:#FFF9C4,stroke:#F9A825,stroke-width:2px;
    classDef documentation fill:#FFCDD2,stroke:#C62828,stroke-width:2px;
    classDef external fill:#D1C4E9,stroke:#673AB7,stroke-width:2px;
```
