# philipplackner/runique architecture

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

- Interactive diagram: https://gitdiagram.com/philipplackner/runique
- Repository: https://github.com/philipplackner/runique

## Overview

##### Main Components
- Phone Application Module ("app"): Represents the main phone UI & navigation, handling user interaction with running features.
- Wear Application Module ("wear/app"): Represents the Wear OS counterpart with its own UI and limited features specifically designed for wearables.
- Core Shared Modules ("core"): Contains uniform functionalities such as data access, connectivity, notifications, and design systems that are shared across both platforms. Within it, you see submodules like core/data, core/domain, core/database, core/presentation (design system and UI), and connectivity.
- Feature-specific Modules: Such as "analytics" and "auth". These are self-contained modules following the same multi-layer structure (each having subdirectories like data, domain, and presentation) that deliver specific functionalities (e.g., tracking analytics and handling authentication).
- Run Modules (“run” and “wear/run”): These modules encapsulate the running tracking capabilities – initiating, syncing, displaying runs for phone and wearable interaction.
- Build Logic: The "build-logic" directory shows custom Gradle convention plugins and version catalogs used to manage and organize the large-scale multi-module build.

##### Relationships and Data Flow
- The Phone and Wear modules interact with the Core modules to access common functionality such as connectivity, network interactions, local storage (Room database via core/database), and UI design components.
- Feature modules like analytics and auth have their tri-layer architecture (data, domain, presentation) and are likely integrated into the main apps through dependency injection (noticing “di” folders in each module).
- Communication and data flow happen across layers – for example:
- The Presentation layer (in app, wear, or feature modules) sends user events to the ViewModels.
- The ViewModels call the Domain layer (repositories/services) to manage business logic.
- The Domain layer then interacts with the Data layer (network requests, local cached data) which may use functionalities from modules like connectivity, database, or networking.
- External services: The README mentions API keys for the Runique API and Google Maps. These external dependencies might be encapsulated inside the network and data modules, and their results are then piped into the UI modules.

##### Important Architectural Patterns and Design Principles
- Clean/Onion Architecture: Clear separation between presentation, domain, and data layers in each feature-specific module.
- Multi-Module Gradle Setup: Enhances component decoupling and scalability.
- Dependency Injection: Evident from “di” (dependency injection) directories across modules.
- Offline-first and dynamic features: Specific code segments (e.g., in the “run” and “auth” modules) indicate handling of offline data and dynamic feature modules.
- Platform-specific considerations: Separate modules for Wear and Phone are maintained, sharing core functionalities from common modules.

##### Relevant Technologies & Frameworks
- Jetpack Compose: Used in UI modules (as indicated by convention plugins like AndroidApplicationComposeConventionPlugin.kt).
- Room: For local database management (see core/database).
- Google Maps SDK & Runique API: For external service integration.
- Gradle (with version catalogs, convention plugins): For build orchestration.
- Architecture components & dependency injection frameworks (like Koin or Dagger – suggested from “di” directories).

- Clear Labels: Each component or module must be clearly labeled (for example, “App (Phone UI)”, “Wear App”, “Core: Data/Domain/Presentation”, “Auth Feature – Data/Domain/Presentation”).
- Architectural layers (group components by domain, data, and presentation)
- External services (APIs, maps, authentication endpoints)
- Additional Detail: Annotate key integration points such as API key configuration (external services) and offline-first behavior.

This approach should provide a comprehensive architectural blueprint that aligns with the project’s structure and purpose as described in the provided files.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Mobile Applications
    subgraph "Mobile Applications"
        phoneApp["Phone App (UI)"]:::phone
        wearApp["Wear App (UI)"]:::wear
    end

    %% Core Shared Modules
    subgraph "Core Shared Modules"
        Connectivity["Connectivity"]:::core
        CoreData["Core Data"]:::core
        Database["Database"]:::core
        Domain["Core Domain"]:::core
        Notification["Notification"]:::core
        DesignSystemPhone["Design System (Phone)"]:::core
        DesignSystemWear["Design System (Wear)"]:::core
        UIComponents["UI Components"]:::core
    end

    %% Feature: Analytics
    subgraph "Feature: Analytics"
        AnalyticsUI["Analytics Feature UI"]:::feature
        AnalyticsPresentation["Analytics Presentation"]:::feature
        AnalyticsDomain["Analytics Domain"]:::feature
        AnalyticsData["Analytics Data"]:::feature
    end

    %% Feature: Authentication
    subgraph "Feature: Authentication"
        AuthPresentation["Auth Presentation"]:::feature
        AuthDomain["Auth Domain"]:::feature
        AuthData["Auth Data"]:::feature
    end

    %% Run Modules
    subgraph "Run Modules"
        RunPhone["Run Module (Phone)"]:::run
        RunWear["Run Module (Wear)"]:::run
    end

    %% Build and Configuration
    subgraph "Build and Configuration"
        BuildLogic["Build Logic"]:::build
    end

    %% External Services
    subgraph "External Services"
        RuniqueAPI["Runique API"]:::external
        GoogleMaps["Google Maps"]:::external
    end

    %% Connections between Mobile Applications and Core Shared Modules
    phoneApp -->|"uses"| Connectivity
    phoneApp -->|"uses"| CoreData
    phoneApp -->|"uses"| Database
    phoneApp -->|"uses"| Domain
    phoneApp -->|"uses"| Notification
    phoneApp -->|"uses"| DesignSystemPhone
    phoneApp -->|"uses"| UIComponents

    wearApp -->|"uses"| Connectivity
    wearApp -->|"uses"| CoreData
    wearApp -->|"uses"| Database
    wearApp -->|"uses"| Domain
    wearApp -->|"uses"| Notification
    wearApp -->|"uses"| DesignSystemWear
    wearApp -->|"uses"| UIComponents

    %% Integration of Feature Modules with Mobile Applications
    phoneApp -->|"injects"| AnalyticsUI
    phoneApp -->|"injects"| AuthPresentation
    wearApp -->|"injects"| AnalyticsUI
    wearApp -->|"injects"| AuthPresentation

    %% Internal Architecture for Analytics Feature
    AnalyticsPresentation -->|"calls"| AnalyticsDomain
    AnalyticsDomain -->|"calls"| AnalyticsData

    %% Internal Architecture for Authentication Feature
    AuthPresentation -->|"calls"| AuthDomain
    AuthDomain -->|"calls"| AuthData

    %% Run Modules used by Mobile Applications
    phoneApp -->|"triggers"| RunPhone
    wearApp -->|"triggers"| RunWear

    %% External Services integration via Core Domain
    Domain -->|"integrates"| RuniqueAPI
    Domain -->|"integrates"| GoogleMaps

    %% Build Logic managing multi-module setup
    BuildLogic -->|"manages"| phoneApp
    BuildLogic -->|"manages"| wearApp
    BuildLogic -->|"manages"| Connectivity
    BuildLogic -->|"manages"| CoreData
    BuildLogic -->|"manages"| Database
    BuildLogic -->|"manages"| Domain
    BuildLogic -->|"manages"| Notification
    BuildLogic -->|"manages"| DesignSystemPhone
    BuildLogic -->|"manages"| DesignSystemWear
    BuildLogic -->|"manages"| UIComponents
    BuildLogic -->|"manages"| AnalyticsUI
    BuildLogic -->|"manages"| AuthPresentation
    BuildLogic -->|"manages"| RunPhone
    BuildLogic -->|"manages"| RunWear

    %% Click Events
    click phoneApp "https://github.com/philipplackner/runique/tree/master/app/"
    click wearApp "https://github.com/philipplackner/runique/tree/master/wear/app/"
    click Connectivity "https://github.com/philipplackner/runique/tree/master/core/connectivity/"
    click CoreData "https://github.com/philipplackner/runique/tree/master/core/data/"
    click Database "https://github.com/philipplackner/runique/tree/master/core/database/"
    click Domain "https://github.com/philipplackner/runique/tree/master/core/domain/"
    click Notification "https://github.com/philipplackner/runique/tree/master/core/notification/"
    click DesignSystemPhone "https://github.com/philipplackner/runique/tree/master/core/presentation/designsystem/"
    click DesignSystemWear "https://github.com/philipplackner/runique/tree/master/core/presentation/designsystem_wear/"
    click UIComponents "https://github.com/philipplackner/runique/tree/master/core/presentation/ui/"
    click AnalyticsUI "https://github.com/philipplackner/runique/tree/master/analytics/analytics_feature/"
    click AnalyticsData "https://github.com/philipplackner/runique/tree/master/analytics/data/"
    click AnalyticsDomain "https://github.com/philipplackner/runique/tree/master/analytics/domain/"
    click AnalyticsPresentation "https://github.com/philipplackner/runique/tree/master/analytics/presentation/"
    click AuthData "https://github.com/philipplackner/runique/tree/master/auth/data/"
    click AuthDomain "https://github.com/philipplackner/runique/tree/master/auth/domain/"
    click AuthPresentation "https://github.com/philipplackner/runique/tree/master/auth/presentation/"
    click RunPhone "https://github.com/philipplackner/runique/tree/master/run/"
    click RunWear "https://github.com/philipplackner/runique/tree/master/wear/run/"
    click BuildLogic "https://github.com/philipplackner/runique/tree/master/build-logic/"

    %% Styles
    classDef phone fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef wear fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef core fill:#D5F5E3,stroke:#1D8348,stroke-width:2px;
    classDef feature fill:#FADBD8,stroke:#922B21,stroke-width:2px;
    classDef run fill:#E8DAEF,stroke:#6C3483,stroke-width:2px;
    classDef build fill:#FDEBD0,stroke:#CA6F1E,stroke-width:2px;
    classDef external fill:#F5CBA7,stroke:#A04000,stroke-width:2px;
```
