# jesushzc/runique architecture

> Architecture diagram of the GitHub repository jesushzc/runique, 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/jesushzc/runique
- Repository: https://github.com/jesushzc/runique

## Overview

##### Main Components
- Mobile App (app module): Acts as the primary user interface and entry point for runners. It contains the main activity, navigation, and high-level app logic.
- Wear OS App (wear/app & wear/run modules): Provides a tailored interface and functionality for wearables, including sync with the mobile application and specialized features like heart rate tracking and ambient mode.
- Domain-Specific Modules:
- Analytics (analytics/…): Handles analytics features, with clear separation into feature (presentation/UI for analytics), data (persistence and repository logic), and domain layers (business rules and models).
- Authentication (auth/…): Covers user logins, registration, and credential validation. Notice the layered break into data, domain, and presentation.
- Run Tracking (run/…): Manages the core functionalities of recording runs (using location, network, and connectivity modules). It includes distinct layers like run data, domain logic, network handling, and presentation (for active run and run overview screens).
- Core Modules (core/…): Common functionalities such as connectivity, database (via Room), notifications, shared design system (UI/design system, both for mobile and wear), and utilities. These modules provide shared infrastructure (e.g., encrypted session storage, local run data sources) used across features.

##### Architectural Patterns and Design Principles
- MVI Pattern: While not mandatory to show every internal ViewModel and state, indicate that the presentation layer follows a Model-View-Intent pattern.
- Separation of Concerns: Show how responsibilities are divided (e.g., UI in presentation modules, business rules in domain, and external data handling in data modules).
- Technologies: Mention key technologies such as Jetpack Compose (for UI), Ktor (for networking), Room (for database), WorkManager (for background tasks), and services like Foreground service for long‐running tasks.

##### Relationships and Interactions
- Mobile App ↔ Auth: for user login and registration.
- Mobile App ↔ Run Tracking: for initiating, tracking, and reviewing runs.
- Mobile App ↔ Analytics: to display detailed statistics.
- A two-way communication link between Mobile App and Wear App (syncing data, run progress, etc.).
- Within each module (Auth, Analytics, Run), layout the three layers:
- Presentation Layer (UI components, activities/fragments with Jetpack Compose)
- Domain Layer (business logic, use cases)
- Data Layer (repositories, network layers using Ktor, and local persistence via Room)
- Core modules are shared and interact with multiple feature modules. For example, Core/Database is used by both Analytics and Run; similarly, Core/Connectivity facilitates communication to the wear-side components.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Mobile Platform
    subgraph "Mobile Platform"
        MobileApp["Mobile App"]:::mobile
        %% Analytics Module
        subgraph "Analytics Module"
            A_Pres["Analytics Presentation\n(Jetpack Compose)"]:::presentation
            A_Domain["Analytics Domain"]:::domain
            A_Data["Analytics Data\n(Room, Ktor)"]:::data
        end
        %% Authentication Module
        subgraph "Authentication Module"
            Auth_Pres["Auth Presentation\n(MVI)"]:::presentation
            Auth_Domain["Auth Domain"]:::domain
            Auth_Data["Auth Data\n(Ktor, Room)"]:::data
        end
        %% Run Tracking Module
        subgraph "Run Tracking Module"
            Run_Pres["Run Presentation\n(Active Run, Overview)"]:::presentation
            Run_Domain["Run Domain"]:::domain
            Run_Data["Run Data\n(Room)"]:::data
            Run_Network["Run Network\n(Ktor)"]:::data
            Run_Location["Run Location"]:::data
        end
    end

    %% Wear Platform
    subgraph "Wear Platform"
        WearUI["Wear OS App UI"]:::wear
        WearRun["Wear Run Module\n(Tracking)"]:::wear
    end

    %% Core Modules
    subgraph "Core Modules"
        Core_Connectivity["Core Connectivity"]:::core
        Core_Database["Core Database\n(Room)"]:::core
        Core_Notification["Core Notification"]:::core
        Core_Design["Core UI/DesignSystem"]:::core
    end

    %% External Services
    External["Koin DI"]:::external
    WorkManager["WorkManager & ForegroundService"]:::external

    %% Relationships between Mobile App and Feature Modules
    MobileApp <-->|"auth"| Auth_Pres
    MobileApp <-->|"analytics"| A_Pres
    MobileApp <-->|"run"| Run_Pres

    %% Interaction between Mobile App and Wear OS App
    MobileApp <-->|"sync"| WearUI
    WearUI <-->|"connect"| WearRun

    %% Layered interactions within Analytics Module
    A_Pres -->|"triggers"| A_Domain
    A_Domain -->|"accesses"| A_Data

    %% Layered interactions within Authentication Module
    Auth_Pres -->|"triggers"| Auth_Domain
    Auth_Domain -->|"accesses"| Auth_Data

    %% Layered interactions within Run Tracking Module
    Run_Pres -->|"triggers"| Run_Domain
    Run_Domain -->|"accesses"| Run_Data
    Run_Domain -->|"accesses"| Run_Network
    Run_Domain -->|"accesses"| Run_Location

    %% Integration with Core Modules
    A_Data -->|"uses"| Core_Database
    Auth_Data -->|"uses"| Core_Database
    Run_Data -->|"uses"| Core_Database
    Run_Network -->|"uses"| Core_Connectivity
    Run_Location -->|"uses"| Core_Connectivity

    %% External Services influence
    External -->|"injects"| MobileApp
    External -->|"injects"| Auth_Pres
    External -->|"injects"| A_Pres
    External -->|"injects"| Run_Pres

    MobileApp -->|"schedules"| WorkManager

    %% Click Events
    click MobileApp "https://github.com/jesushzc/runique/tree/main/app/src/main/java/com/jesushzc/runique"
    click WearUI "https://github.com/jesushzc/runique/blob/main/wear/app/src/main/java/com/jesushz/wear/app/presentation/MainActivity.kt"
    click WearRun "https://github.com/jesushzc/runique/tree/main/wear/run"
    click A_Pres "https://github.com/jesushzc/runique/tree/main/analytics/analytics_feature"
    click A_Data "https://github.com/jesushzc/runique/blob/main/analytics/data/di/AnalyticsDataModule.kt"
    click Auth_Pres "https://github.com/jesushzc/runique/blob/main/auth/presentation/LoginViewModel.kt"
    click Auth_Data "https://github.com/jesushzc/runique/blob/main/auth/data/di/AuthDataModule.kt"
    click Run_Pres "https://github.com/jesushzc/runique/blob/main/run/presentation/active_run/ActiveRunViewModel.kt"
    click Run_Data "https://github.com/jesushzc/runique/blob/main/run/data/di/RunDataModule.kt"
    click Core_Database "https://github.com/jesushzc/runique/tree/main/core/database"
    click Core_Connectivity "https://github.com/jesushzc/runique/tree/main/core/connectivity"
    click Core_Design "https://github.com/jesushzc/runique/tree/main/core/presentation/designsystem"
    click Core_Notification "https://github.com/jesushzc/runique/tree/main/core/notification"

    %% Styles
    classDef mobile fill:#ffe4b5,stroke:#333,stroke-width:2px;
    classDef wear fill:#add8e6,stroke:#333,stroke-width:2px;
    classDef presentation fill:#ffdead,stroke:#333,stroke-width:2px;
    classDef domain fill:#98fb98,stroke:#333,stroke-width:2px;
    classDef data fill:#d0e1f9,stroke:#333,stroke-width:2px;
    classDef core fill:#ffe4e1,stroke:#333,stroke-width:2px;
    classDef external fill:#d3d3d3,stroke:#333,stroke-width:2px;
```
