# xpeho/xpeapp_android architecture

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

- Interactive diagram: https://gitdiagram.com/xpeho/xpeapp_android
- Repository: https://github.com/xpeho/xpeapp_android

## Overview

##### Project Type and Purpose
- XpeApp is an Android mobile application built with Kotlin and Jetpack Compose.
- It follows a client-side architecture that consumes REST APIs (WordPress backend), uses Firebase services, and persists local preferences via DataStore.

##### File Structure Analysis
- Top-level “app” module contains all code and resources.
- data/… – data layer (entities, models, services, repository, network interceptor)
- domain/… – business logic managers (AuthenticationManager, FeatureFlippingManager)
- di/… – dependency injection modules and providers
- ui/… – presentation layer, subdivided into viewModels, pages, components, uiState, theme, notifications
- enums/… – enum definitions for navigation screens
- `AndroidManifest.xml`, Gradle build scripts, resource folders (drawables, layouts, values, xml).
- Test directories mirror production code for unit/integration tests.
- CI/CD: GitHub workflows for linting (detekt), code quality (SonarQube), building & releasing Android App Bundle.

##### README Insights
- Requires `google-services.json` for Firebase integration.
- Configurable back-end URLs via `uat.properties` and `prod.properties`.
- Uses external UI library (`xpeho_ui_android`) imported via GitHub Packages.
- Release process automated through GitHub Actions and Google Play Console.

##### Main Components
A. Android App (Client)
1. UI Layer (Jetpack Compose screens & components)
2. ViewModels (MVVM pattern: `ui/viewModel`)
3. Domain Layer (business managers)
4. Data Layer
– Repositories (`WordpressRepository`)
– Services (`WordpressService`, `FirebaseService`)
– Network Interceptor (`AuthorizationHeaderInterceptor`)
– Local Preferences (`DatastorePref`)
5. Dependency Injection (Koin/Hilt-like module in `di/AppModule.kt`)
6. Notifications (AlarmReceiver/Scheduler)
B. External Services
1. WordPress REST API (backend endpoints)
2. Firebase Cloud Messaging (push notifications or analytics)
3. GitHub Releases (version checking for forced updates)
4. Google Play Console (app distribution)

##### Relationships and Data Flows
- UI Components → bind to → ViewModels
- ViewModels → call → Domain Managers → orchestrate → Data Layer
- Data Layer → fetch/update → External REST API (WordPress) & Firebase, or Local DataStore
- DI Container → provides → all above dependencies at app startup (via XpeApp.kt)
- On release: GitHub Actions → build AAB → Google Play → publish → app version check via GitHub Releases

##### Architectural Patterns & Principles
- MVVM: clear separation between UI, state (uiState), and logic (ViewModel).
- Clean architecture layers: UI → Domain → Data.
- Single responsibility modules: each package has a focused concern.
- Dependency Injection centralizes object creation for decoupling and testability.
- Reactive state management: UI state flows from ViewModels exposing state objects.

##### Elements
- Clear labels: name each component/package.
- Configuration: note where `google-services.json` and properties files plug into the Data layer.
- CI/CD flow (optional overlay): GitHub Actions → SonarQube → Build → Release.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "UI Layer"
        UIComp["Compose UI Components"]:::ui
        AlarmRec["AlarmReceiver"]:::ui
        AlarmSched["AlarmScheduler"]:::ui
        NotifHelper["Notification Helper"]:::ui
    end

    subgraph "ViewModel Layer"
        VM["ViewModels"]:::vm
    end

    subgraph "Domain Layer"
        Domain["Authentication & Feature Managers"]:::domain
    end

    subgraph "Data Layer"
        Repo["WordpressRepository"]:::data
        WSvc["WordpressService"]:::data
        FSvc["FirebaseService"]:::data
        Interceptor["AuthorizationHeaderInterceptor"]:::data
        DataStore["DatastorePref"]:::data
    end

    subgraph "Dependency Injection"
        AppModule["AppModule"]:::di
        TokenProv["TokenProvider"]:::di
    end

    subgraph "External Services"
        WordPress["WordPress REST API"]:::ext
        Firebase["Firebase Cloud Messaging"]:::ext
        GitHub["GitHub Releases"]:::ext
        Play["Google Play Console"]:::ext
    end

    UIComp -->|binds to| VM
    AlarmRec -->|notifies via| VM
    AlarmSched -->|schedules via| VM
    NotifHelper -->|uses| VM

    VM -->|calls| Domain
    Domain -->|orchestrates| Repo
    Repo -->|fetches| WSvc
    Repo -->|updates| FSvc
    WSvc -->|requests| WordPress
    FSvc -->|pushes/analytics| Firebase
    Repo -->|persists| DataStore
    DataStore -->|reads/writes| Repo

    AppModule -->|provides| UIComp
    AppModule -->|provides| VM
    AppModule -->|provides| Domain
    AppModule -->|provides| Repo
    AppModule -->|provides| WSvc
    AppModule -->|provides| FSvc
    AppModule -->|provides| Interceptor
    AppModule -->|provides| DataStore
    TokenProv -->|supplies tokens| Interceptor

    GitHub -->|version check| VM
    GitHub -->|triggers build| Play

    click UIComp "https://github.com/xpeho/xpeapp_android/tree/main/app/src/main/java/com/xpeho/xpeapp/ui"
    click VM "https://github.com/xpeho/xpeapp_android/tree/main/app/src/main/java/com/xpeho/xpeapp/ui/viewModel"
    click Domain "https://github.com/xpeho/xpeapp_android/tree/main/app/src/main/java/com/xpeho/xpeapp/domain"
    click Repo "https://github.com/xpeho/xpeapp_android/blob/main/app/src/main/java/com/xpeho/xpeapp/data/service/WordpressRepository.kt"
    click WSvc "https://github.com/xpeho/xpeapp_android/blob/main/app/src/main/java/com/xpeho/xpeapp/data/service/WordpressService.kt"
    click FSvc "https://github.com/xpeho/xpeapp_android/blob/main/app/src/main/java/com/xpeho/xpeapp/data/service/FirebaseService.kt"
    click Interceptor "https://github.com/xpeho/xpeapp_android/blob/main/app/src/main/java/com/xpeho/xpeapp/data/service/interceptor/AuthorizationHeaderInterceptor.kt"
    click DataStore "https://github.com/xpeho/xpeapp_android/blob/main/app/src/main/java/com/xpeho/xpeapp/data/DatastorePref.kt"
    click AppModule "https://github.com/xpeho/xpeapp_android/blob/main/app/src/main/java/com/xpeho/xpeapp/di/AppModule.kt"
    click TokenProv "https://github.com/xpeho/xpeapp_android/blob/main/app/src/main/java/com/xpeho/xpeapp/di/TokenProvider.kt"
    click AlarmRec "https://github.com/xpeho/xpeapp_android/blob/main/app/src/main/java/com/xpeho/xpeapp/ui/notifications/AlarmReceiver.kt"
    click AlarmSched "https://github.com/xpeho/xpeapp_android/blob/main/app/src/main/java/com/xpeho/xpeapp/ui/notifications/AlarmScheduler.kt"
    click NotifHelper "https://github.com/xpeho/xpeapp_android/blob/main/app/src/main/java/com/xpeho/xpeapp/ui/notifications/Notification.kt"

    classDef ui fill:#cce5ff,stroke:#004085,color:#004085
    classDef vm fill:#d4edda,stroke:#155724,color:#155724
    classDef domain fill:#fff3cd,stroke:#856404,color:#856404
    classDef data fill:#fff3cd,stroke:#856404,color:#856404
    classDef di fill:#e2e3e5,stroke:#6c757d,color:#6c757d
    classDef ext fill:#f8d7da,stroke:#721c24,color:#721c24
```
