# andriawan24/wordle-id-kmp architecture

> Architecture diagram of the GitHub repository andriawan24/wordle-id-kmp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/andriawan24/wordle-id-kmp
- Repository: https://github.com/andriawan24/wordle-id-kmp

## Overview

- Mobile Client (Compose Multiplatform)
- Common Source Code: Contains shared business logic, domain models, use cases, data sources, dependency injection (Koin), and presentation (viewmodels, UI components, theme, etc.).
- Platform-Specific Implementations:
- Android Module: Looks after Android-specific UI parts (AndroidManifest.xml, activity classes like MainActivity.kt, platform-specific resources).
- iOS Module: Contains iOS-specific code (MainViewController.kt, iOS-specific UI files, ContentView.swift, etc.).
- Backend Server
- Server Code: This comprises the main application entry (Application.kt), routing (Routing.kt, MainRoutes.kt), database integration (Database.kt, data.db), network services (WordService.kt), and supporting utilities (CsvHelper.kt, Serialization.kt).
- Data Persistence Components: Represented by the Database file and the resource folder where the data.db is stored.
- External Dependencies & Shared Infrastructure
- Gradle and Build Scripts: Represent the build configuration (build.gradle.kts files in multiple modules, gradle wrapper, etc.) which tie together the multiplatform build process.
- Configuration and Assets: Include configuration for both mobile (res/ folders, iOS assets) and server (documentation.yaml, logback.xml).

##### Establish the relationships and interactions
- The Mobile Client interacts with the Backend Server through network APIs. This is defined in the common module through classes like WordleApiService and NetworkHelper.
- The Domain and Data layers within the client communicate with the Presentation layer via ViewModels to drive the UI on both Android and iOS.
- Dependency Injection (via Koin) ties together the modules within the client, ensuring proper initialization and configuration.
- The Backend Server exposes REST endpoints (configured in Routing.kt and MainRoutes.kt) which the mobile client consumes. The server handles data logic, persistence, and business rules.
- Build systems and configuration components (Gradle scripts, project configuration files) serve as the foundation to compile, package, and deploy the application across different platforms.

##### Important architectural patterns and design principles
- Modular/Layered architecture in the client: Separation between presentation (UI), domain (use cases, models), and data (networking and local data sources).
- MVVM Pattern: Evident by the use of components like GameViewModel and composable UI components.
- Dependency Injection: Using Koin to manage dependencies across modules.
- Client-Server Architecture: The mobile client is decoupled from the backend server, communicating over defined APIs.
- Multiplatform shared code: Common business logic is maintained in a shared module to maximize code reuse across Android and iOS.

##### Specific technologies and frameworks
- For the client: Compose Multiplatform, Kotlin, and shared resources along with platform-specific UI frameworks (Android’s native UI components, iOS using Swift/SwiftUI integration).
- For the server: Kotlin, likely Ktor or a similar lightweight server framework (inferred from the structure and naming in the server folder), as well as logging (logback.xml) and database access components.
- Build Tools: Gradle with Kotlin DSL (build.gradle.kts) and the Gradle wrapper.

- Clear, descriptive labels for each of the components (e.g., “Compose Shared Module”, “Android UI”, “iOS Integration”, “API Gateway”, “Database”, etc.).

##### Final advice
- Be very detailed – break down the project into as many components as logical based on the file structure.
- Both platform-specific differences and shared logic.
- Showing how different layers interact (e.g., data flows from the API to the repository, and then to the viewmodel and UI).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Mobile Client"
        MS1["Common Shared Module\n(shared business logic, domain, use cases)"]:::module
        MS2["Android-Specific Implementation\n(Android UI, resources)"]:::module
        MS3["iOS-Specific Implementation\n(iOS UI & Integration)"]:::module
    end

    subgraph "Backend Server"
        BS1["Main Application & Routing\n(Application.kt, Routing.kt, MainRoutes.kt)"]:::module
        BS2["Data Persistence\n(Database.kt, data.db)"]:::database
        BS3["Service Layer\n(WordService.kt)"]:::module
    end

    subgraph "External Dependencies & Config"
        EX1["Build Scripts & Gradle Config\n(build.gradle.kts, gradle wrapper, etc.)"]:::config
        EX2["Logging & Config Assets\n(logback.xml, documentation.yaml)"]:::config
    end

    %% Relationships within the Mobile Client
    MS1 -->|"drives"| MS2
    MS1 -->|"drives"| MS3

    %% Client-Server Interaction
    MS1 -->|"makes_API_call_to"| BS1

    %% Backend internal flow
    BS1 -->|"integrates_with"| BS2
    BS1 -->|"utilizes"| BS3

    %% External Dependencies support both client and server
    EX1 -->|"configures"| MS1
    EX1 -->|"configures"| BS1
    EX2 -->|"provides_assets_to"| MS1
    EX2 -->|"provides_assets_to"| BS1

    %% Annotations for key frameworks/dependencies
    KOIN["Koin_Dependency_Injection"]:::note
    COMPOSE["Compose_UI_Framework"]:::note
    KTOR["Ktor_Server_Framework"]:::note
    MS1 ---|"utilizes"| KOIN
    MS2 ---|"implements"| COMPOSE
    BS1 ---|"built_with"| KTOR

    %% Click Events
    click MS1 "https://github.com/andriawan24/wordle-id-kmp/tree/main/composeApp/src/commonMain"
    click MS2 "https://github.com/andriawan24/wordle-id-kmp/tree/main/composeApp/src/androidMain"
    click MS3 "https://github.com/andriawan24/wordle-id-kmp/tree/main/composeApp/src/iosMain"
    click BS1 "https://github.com/andriawan24/wordle-id-kmp/tree/main/server/src/main/kotlin/id/fawwaz/wordle_server"
    click BS2 "https://github.com/andriawan24/wordle-id-kmp/tree/main/server/src/main/resources"
    click BS3 "https://github.com/andriawan24/wordle-id-kmp/tree/main/server/src/main/kotlin/id/fawwaz/wordle_server/services"
    click EX1 "https://github.com/andriawan24/wordle-id-kmp/blob/main/build.gradle.kts"
    click EX2 "https://github.com/andriawan24/wordle-id-kmp/tree/main/server/src/main/resources"

    %% Styles
    classDef module fill:#bbf,stroke:#333,stroke-width:2px;
    classDef database fill:#afa,stroke:#333,stroke-width:2px;
    classDef config fill:#f9d,stroke:#333,stroke-width:2px;
    classDef note fill:#ffd,stroke:#333,stroke-width:2px;
```
