# charlyiii/dragonballapp architecture

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

- Interactive diagram: https://gitdiagram.com/charlyiii/dragonballapp
- Repository: https://github.com/charlyiii/dragonballapp

## Overview

##### Main Components
- App Module: Acts as the Android application entry point. It may manage global configurations and app-level initializations (e.g., setting up dependency injection with Dagger Hilt).
- UI Module: Contains all presentation logic, including the screens, fragments, ViewModels (MVVM), UI components (Compose Views), and resource files. It is responsible for visual representation and user interactions.
- Domain Module: Implements the core business logic. This layer includes the models, use cases, repositories' interfaces, and domain utilities (e.g., Either for error handling). It is independent of framework-specific implementations.
- Data Module: Provides concrete implementations of repositories and data sources. It manages data interactions such as network calls using Retrofit and integration with Firebase (for the real-time database and storage). This module includes data transfer objects (DTOs), network configuration, service definitions, and dependency injection modules for wiring up data sources.

##### Relationships and Interactions
- The UI layer communicates with the Domain layer via ViewModels. ViewModels request use case executions from the Domain module that encapsulate business logic.
- The Domain layer acts as a mediator, invoking repository interfaces. These interfaces are concretely implemented inside the Data module.
- The Data module is responsible for fetching and transforming data from remote APIs (using Retrofit) and Firebase services. It exposes the results back through the system (often wrapped in domain models or error representations).
- Dependency injection with Dagger Hilt connects these layers while minimizing direct dependencies.

##### Architectural Patterns and Design Principles
- Clean Architecture: Focuses on separation of concerns and dependency inversion. The Domain layer is central and independent of both the UI and Data layers.
- MVVM (Model-View-ViewModel): Facilitates the separation between the UI and business logic. Use StateFlows to propagate data changes.
- Modular Structure: The project is broken into clear modules (app, ui, domain, data), which is reflected in the file tree.

##### Relevant Technologies, Frameworks, and Libraries
- Android and Android Studio
- Kotlin as the programming language
- Retrofit for managing network API requests
- Firebase RealTime Database and Firebase Storage for data persistence and asset management
- Dagger Hilt for dependency injection
- Clean Architecture & MVVM for software structure
- Gradle for build configuration and dependency management

- Drill down into each module if needed:
– For the UI layer, split out components such as activities, fragments, and ViewModels.
– For the Domain layer, include blocks for models, use cases, and repository interfaces.
– For the Data layer, include networking, repositories, and data sources.
- External dependencies (e.g., Retrofit, Firebase) and how they interact with the internal layers.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Android Project Architecture"
        A["App Module"]:::appModule

        subgraph "UI (Presentation Layer)"
            UI["UI Module"]:::uiModule
            U1["ViewModels"]:::component
            U2["Fragments & Screens"]:::component
            UI -->|"contains"| U1
            UI -->|"contains"| U2
        end

        subgraph "Domain (Business Logic Layer)"
            D["Domain Module"]:::domainModule
            DU1["Use Cases"]:::component
            DU2["Repository Interfaces"]:::component
            D -->|"defines"| DU1
            D -->|"defines"| DU2
        end

        subgraph "Data (Repositories & APIs)"
            DT["Data Module"]:::dataModule
            DS["Network & Firebase"]:::component
            DI["Dagger Hilt DI"]:::diModule
            DT -->|"provides"| DS
            DT -->|"wires"| DI
        end

        A -->|"initializes"| UI
        UI -->|"triggers"| D
        D -->|"calls"| DT
        DI -.->|"injects"| UI
        DI -.->|"injects"| D
    end

    %% Click Event Mapping
    click A "https://github.com/charlyiii/dragonballapp/blob/main/app/src/main/java/com/ferreiro/dragonballapp/App.kt"
    click UI "https://github.com/charlyiii/dragonballapp/tree/main/ui/src/main/java/com/ferreiro/dragonballapp/ui"
    click D "https://github.com/charlyiii/dragonballapp/tree/main/domain/src/main/java/com/ferreiro/dragonballapp/domain"
    click DT "https://github.com/charlyiii/dragonballapp/tree/main/data/src/main/java/com/example/data"
    click DI "https://github.com/charlyiii/dragonballapp/tree/main/data/src/main/java/com/example/data/di"

    %% Style Definitions
    classDef appModule fill:#FFEEAD,stroke:#000,stroke-width:2px;
    classDef uiModule fill:#AEDFF7,stroke:#000,stroke-width:2px;
    classDef domainModule fill:#C2E7B0,stroke:#000,stroke-width:2px;
    classDef dataModule fill:#F7C3CD,stroke:#000,stroke-width:2px;
    classDef diModule fill:#E5A1DD,stroke:#000,stroke-width:2px;
    classDef component fill:#FFFFFF,stroke:#333,stroke-width:1px;
```
