# ryanw-mobile/octometer architecture

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

- Interactive diagram: https://gitdiagram.com/ryanw-mobile/octometer
- Repository: https://github.com/ryanw-mobile/octometer

## Overview

##### Main Components of the System
- Shared ComposeApp Module – This is the core of the application where code is organized for multiplatform targets. Within ComposeApp, you have:
- commonMain: Contains shared business logic, UI components (via Compose), domain models, use cases, repository interfaces, and common utilities.
- androidMain, desktopMain, iosMain: Platform-specific code that connects to native APIs while reusing most of the shared common logic.
- Additional layers such as “data” (repositories, network data sources, local databases via Room/SQLite, and preferences via Multiplatform Settings) and “ui” (components, navigation, view models).

- BaselineProfile Module – A dedicated module (found under “baselineprofile”) to generate Android baseline profiles for improving startup performance. This module likely helps in benchmarking and optimizing when running on Android.

- Platform-specific Modules:
- iosApp: Contains the native iOS wrapper (with Swift entry-points, Assets, Xcode project configuration) that bootstraps the shared Kotlin code.
- Desktop (and any additional wrappers): The desktop target under desktopMain provides the JVM application entry.

- External Services / Dependencies – These include:
- Network Layer: Uses Ktor for REST calls, Apollo GraphQL for GraphQL endpoints, and corresponding DTOs for interfacing with Octopus Energy APIs.
- Local Storage: Room database for Android (and multiplatform SQLite implementations) and Multiplatform Preferences.
- Dependency Injection: Handled by Koin and/or DI modules in the “di” packages.
- Logging, testing, and additional libraries (e.g., Kermit, KoalaPlot, Material3 Window Size Class, etc.).

##### Architectural Patterns and Relationships
- Layered Architecture:
- Presentation Layer: Compose UI components, Navigation (in ui/navigation) and view models.
- Domain Layer: Use cases, business logic, and abstract repository interfaces defined in the “domain” folders.
- Data Layer: Concrete implementations in the “data” source directories (network, local database, preferences) which interact with external APIs and caching/local persistence.

- Clear Separation between Platform-specific and Shared Code:
- Demonstrate how platform-specific code (androidMain, iosMain, desktopMain) extends or calls shared functionalities from commonMain.

- Integration with External APIs:

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% ComposeApp Shared Module
    subgraph "ComposeApp Shared Module"
        S1["UI & Navigation (Compose UI)"] 
        S2["Domain & UseCases"]
        S3["Data Layer"]
        S4["DI Modules"]
    end

    %% Platform-Specific Modules
    subgraph "Platform-Specific Modules"
        AN["Android (composeApp/src/androidMain)"]
        BP["BaselineProfile Module"]
        IO["iOS Wrapper (iosApp)"]
        OS["iOS Code (composeApp/src/iosMain)"]
        DE["Desktop (composeApp/src/desktopMain)"]
    end

    %% External Services & Dependencies
    subgraph "External Services & Dependencies"
        NET["REST API (Ktor)"]
        GQL["GraphQL API (Apollo)"]
        DB["Local Storage (Room/SQLite & Preferences)"]
    end

    %% Inter-layer Connections
    S1 -->|"calls"| AN
    S1 -->|"calls"| IO
    S1 -->|"calls"| DE
    S2 -->|"uses"| S3
    S3 -->|"fetches"| NET
    S3 -->|"queries"| GQL
    S3 -->|"caches to"| DB
    S4 -->|"injects to"| S1
    S4 -->|"injects to"| S2
    S4 -->|"injects to"| S3

    %% Platform-specific extensions of Shared Module
    AN -->|"extends"| S1
    IO -->|"integrates"| S1
    DE -->|"runs"| S1

    %% iOS Wrapper bridging to iOS Code
    IO -->|"bridges to"| OS

    %% Android baseline optimization
    AN -->|"optimized by"| BP

    %% Styling
    class S1,S2,S3,S4 shared
    class AN,BP,IO,OS,DE platform
    class NET,GQL,DB external

    %% Click Events
    click S1 "https://github.com/ryanw-mobile/octometer/tree/main/composeApp/src/commonMain/kotlin/com/rwmobi/kunigami/ui"
    click S2 "https://github.com/ryanw-mobile/octometer/tree/main/composeApp/src/commonMain/kotlin/com/rwmobi/kunigami/domain"
    click S3 "https://github.com/ryanw-mobile/octometer/tree/main/composeApp/src/commonMain/kotlin/com/rwmobi/kunigami/data"
    click S4 "https://github.com/ryanw-mobile/octometer/tree/main/composeApp/src/commonMain/kotlin/com/rwmobi/kunigami/di"
    click AN "https://github.com/ryanw-mobile/octometer/tree/main/composeApp/src/androidMain"
    click BP "https://github.com/ryanw-mobile/octometer/tree/main/baselineprofile/"
    click IO "https://github.com/ryanw-mobile/octometer/tree/main/iosApp"
    click OS "https://github.com/ryanw-mobile/octometer/tree/main/composeApp/src/iosMain"
    click DE "https://github.com/ryanw-mobile/octometer/tree/main/composeApp/src/desktopMain"
    click NET "https://github.com/ryanw-mobile/octometer/tree/main/composeApp/src/commonMain/kotlin/com/rwmobi/kunigami/data/source/network"
    click GQL "https://github.com/ryanw-mobile/octometer/tree/main/composeApp/src/commonMain/kotlin/com/rwmobi/kunigami/graphql"
    click DB "https://github.com/ryanw-mobile/octometer/tree/main/composeApp/src/commonMain/kotlin/com/rwmobi/kunigami/data/source/local/database"

    %% Class Definitions for Colors
    classDef shared fill:#cce5ff,stroke:#007bff,stroke-width:2px;
    classDef platform fill:#d4edda,stroke:#28a745,stroke-width:2px;
    classDef external fill:#f8d7da,stroke:#dc3545,stroke-width:2px;
```
