# ljzapps/questify-android architecture

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

- Interactive diagram: https://gitdiagram.com/ljzapps/questify-android
- Repository: https://github.com/ljzapps/questify-android

## Overview

##### Main Components

- User Interface (UI) Layer:
- This layer is primarily contained in the “ui” directory and its subdirectories (such as ui/features/dashboard, ui/features/login_and_register, ui/features/quests, etc.).
- It implements the presentation using modern Android technologies like Jetpack Compose and XML resources (referenced in app/src/main/res).
- Screens, dialogs, navigational elements (navigation/routes), and common UI components.

- Application and Presentation Layer:
- The “core/application” package contains the main application class (App.kt), configuration (AppConfig.kt), and constants.
- Presentation logic is implemented in separate ViewModel classes (for example, in ui/features/main, ui/features/dashboard, etc.), following the MVVM pattern.
- This layer integrates UI events with business logic.

- Domain Layer:
- Found in the “domain” package, this layer encapsulates business logic, data models (such as QuestEntity, RoutineEntity, TrophyEntity, etc.), and core functionalities like database operations.
- The Domain includes migrations, DAOs (data access objects), repositories (quest, login, trophies, etc.), and data stores (AppSettings, FeatureSettings).
- Domain objects and contracts that drive the business processes.

- Data Layer:
- Located in the “data” directory, this layer handles interactions with external sources.
- It contains API clients, services (e.g., LoginService, RegisterService), error handling (interceptors, error emitters), and network utilities.
- The API layer is responsible for forming HTTP requests, handling responses, and mapping JSON (through adapters and annotations).

- Infrastructure and Integration:
- Several dependency injection modules are defined under “core/di”. They provide the glue among components (injecting dependencies such as networking, database, emitter, shared preferences, etc.).
- External integrations are supported by components like FirebaseExperiments and potentially the AI components (see “core/ai”) where the scoring and farming detectors provide smart task evaluation.
- Security and configuration elements are included (e.g., app.properties, network security config, proguard rules).

##### Relationships and Interactions

- ViewModels interact with the domain repositories and use-cases, abstracting data fetching and business rules.
- Domain repositories, spread across “domain/repositories” and “domain/daos”, bridge the UI and the underlying data sources (local database and remote API).
- Dependency injection (from the DI modules) connects all these components together. Represent the DI container (or modules) as a separate component orchestrating dependencies.

##### Architectural Patterns and Design Principles

- MVVM: Emphasize the separation of UI (View), business logic (ViewModel), and data (Model).
- Repository Pattern: Domain repositories abstract data sources, promoting separation between data handling and business logic.
- Layered Architecture: Clear distinction among presentation, domain, and data layers.
- Dependency Injection: The use of DI modules shows an emphasis on loose coupling and testability.
- Modularization: The file structure reflects a modular design with dedicated packages for UI features, data, domain logic, and Compose components.

##### Relevant Technologies, Frameworks, and Libraries

- Kotlin language and Android SDK.
- Jetpack Compose for UI development.
- Android architecture components (ViewModel, LiveData/State management).
- Gradle (with Kotlin DSL) for build management.
- Firebase for experiments and possibly analytics.
- Possibly retrofit/okhttp (or similar libraries) for network and API calls.
- Android Room (or a similar database layer) for local storage, with database migrations.

##### Summarized Structure

- Top Section: User Interface Layer (various screens, dialogs, and navigation components).
- Middle Section: Application/Presentation Layer (ViewModels, AppConfig, and DI modules).
- Lower Section: Domain Layer (business models, repositories, DAOs, migrations) alongside the Data Layer (API services, error handling, network utilities).
- Side Section: Infrastructure & External Integrations (Firebase, AI modules, security configurations).

## Diagram (Mermaid)

```mermaid
graph TB
    %% UI Layer
    subgraph "UI Layer"
        UI["UI (Screens,Dialogs,Navigation)"]:::ui
    end

    %% Application & Presentation Layer
    subgraph "Application & Presentation Layer"
        AP["App & Presentation (App.kt,AppConfig,ViewModels)"]:::app
    end

    %% Domain Layer
    subgraph "Domain Layer"
        DM["Domain (BusinessModels,Repositories,DAOs,Migrations)"]:::domain
    end

    %% Data Layer
    subgraph "Data Layer"
        DTL["Data Layer (APIClients,NetworkUtils)"]:::data
        DB["Local Database (AppDatabase,Migrations)"]:::db
    end

    %% Infrastructure & External Integrations
    subgraph "Infrastructure & Integrations"
        DI["Dependency Injection (DI Modules)"]:::di
        AI["AI & External Services (Firebase,AI Modules)"]:::ai
    end

    %% Vertical Flow Connections
    UI -->|"triggers"| AP
    AP -->|"executes"| DM
    DM -->|"fetches"| DTL
    DM -->|"persists"| DB

    %% Dependency Injection connects to multiple layers
    DI -->|"injects"| UI
    DI -->|"injects"| AP
    DI -->|"injects"| DM
    DI -->|"injects"| DTL

    %% AI and External Integrations
    AI -->|"enhances"| DM
    AI -->|"integrates"| DTL

    %% Click Events
    click UI "https://github.com/ljzapps/questify-android/tree/main/app/src/main/kotlin/de/ljz/questify/ui"
    click AP "https://github.com/ljzapps/questify-android/tree/main/app/src/main/kotlin/de/ljz/questify/core/application"
    click DM "https://github.com/ljzapps/questify-android/tree/main/app/src/main/kotlin/de/ljz/questify/domain"
    click DTL "https://github.com/ljzapps/questify-android/tree/main/app/src/main/kotlin/de/ljz/questify/data"
    click DI "https://github.com/ljzapps/questify-android/tree/main/app/src/main/kotlin/de/ljz/questify/core/di"
    click AI "https://github.com/ljzapps/questify-android/tree/main/app/src/main/kotlin/de/ljz/questify/core/ai"
    click DB "https://github.com/ljzapps/questify-android/tree/main/app/src/main/kotlin/de/ljz/questify/domain/core"

    %% Styles
    classDef ui fill:#ADD8E6,stroke:#000,stroke-width:1px;
    classDef app fill:#80CBC4,stroke:#000,stroke-width:1px;
    classDef domain fill:#FFCC80,stroke:#000,stroke-width:1px;
    classDef data fill:#B39DDB,stroke:#000,stroke-width:1px;
    classDef di fill:#A5D6A7,stroke:#000,stroke-width:1px;
    classDef ai fill:#FFF59D,stroke:#000,stroke-width:1px;
    classDef db fill:#D7CCC8,stroke:#000,stroke-width:1px;
```
