# ferprieto/spacex-prepare-for-clean-architecture-liftoff architecture

> Architecture diagram of the GitHub repository ferprieto/spacex-prepare-for-clean-architecture-liftoff, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ferprieto/spacex-prepare-for-clean-architecture-liftoff
- Repository: https://github.com/ferprieto/spacex-prepare-for-clean-architecture-liftoff

## Overview

##### Main Components
- Presentation Layer: Represented by the "app" module. Here, you have the UI components (screens, navigation components like BottomNavigationScreens, etc.) and view-models (DashboardViewModel, LaunchesViewModel, etc.) that follow the MVVM pattern.
- Domain Layer: Located in the "domain" module. This layer encapsulates business logic, use cases (like GetCompanyInfo and GetLaunches), domain models (such as CompanyInfoDomainModel and LaunchDomainModel), and domain-specific mappers.
- Data Layer: Split into two modules:
- “data”: Contains the repository implementations (e.g., SpaceXRepositoryImpl), data models, and domain-to-data mappers.
- “data-api”: Manages communication with remote services using Retrofit, remote data sources (e.g., SpaceXRemoteSourceImpl), and response mappers.
- Core Modules: “core” (base classes, events, factories) and “core-android-test” (testing utilities), which are used across the project but have strict dependency isolation.
- Testing Components: Unit tests and instrumented tests (using frameworks like Espresso, MockK, and even screenshot testing using Shot).

##### Relationships and Interactions
- The Presentation Layer interacts with the Domain Layer via use cases to drive business logic. It communicates using view-models that consume domain models.
- The Domain Layer defines the contracts (interfaces) for repository access, which are implemented in the Data Layer.
- The Data Layer handles data sourcing, converting API responses (from data-api) or caching/repository models into domain models via mappers.
- Dependency injection (via Dagger Hilt or Dagger2) ties the components together, wiring up dependencies between the Presentation, Domain, and Data layers.

##### Architectural Patterns and Technologies
- MVVM Pattern: In the app module, the separation of screens (View) and view-models (logic) should be depicted.
- Dependency Injection: Show that components across layers are provided via DI (Dagger Hilt/Dagger2) and indicate the DI modules (like ActivityScope, ViewModelsModule, PresentationModule, and the modules under data-api and data).
- Use of Kotlin Coroutines and Flows: Indicate asynchronous data flows between layers.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        PS1["MainScreen"]:::presentation
        PS2["DashboardScreen"]:::presentation
        PS3["LaunchesScreen"]:::presentation
        PS4["BottomNavigationScreens"]:::presentation
        PV1["DashboardViewModel"]:::presentation
        PV2["LaunchesViewModel"]:::presentation
        PS8["EntryPointActivity"]:::presentation
        PS7["PresentationModule DI"]:::presentation
    end

    %% Domain Layer
    subgraph "Domain Layer"
        DU1["GetCompanyInfo UseCase"]:::domain
        DU2["GetLaunches UseCase"]:::domain
        DM1["CompanyInfoDomainModel"]:::domain
        DM2["LaunchDomainModel"]:::domain
        DM3["LaunchesDomainFilter"]:::domain
    end

    %% Data Layer (Repository and Remote API)
    subgraph "Data Layer"
        subgraph "Repository Module"
            DR1["SpaceXRepositoryImpl"]:::data
            DR2["CompanyInfoRepoToDomainMapper"]:::data
            DR3["LaunchesRepoToDomainMapper"]:::data
            DR4["Data Models"]:::data
        end
        subgraph "Data API Module"
            DA1["ApiService"]:::dataapi
            DA2["SpaceXRemoteSourceImpl"]:::dataapi
            DA3["CompanyInfoResponseToRepoMapper"]:::dataapi
            DA4["LaunchesResponseToRepoMapper"]:::dataapi
            DA5["Api & Network DI"]:::dataapi
        end
    end

    %% Dependency Injection
    subgraph "Dependency Injection"
        DI["DI Container (Dagger Hilt/Dagger2)"]:::di
    end

    %% Core Modules
    subgraph "Core Modules"
        CORE["Core & Testing Utilities"]:::core
    end

    %% Connections from Presentation to Domain
    PS1 -->|"triggers"| PV1
    PS2 -->|"triggers"| PV1
    PS3 -->|"triggers"| PV2
    PS4 -->|"navigates"| PS1
    PV1 -->|"invokes"| DU1
    PV2 -->|"invokes"| DU2

    %% Connections from Domain to Data (Repository)
    DU1 -->|"calls"| DR1
    DU2 -->|"calls"| DR1

    %% Data repository interacts with Data API
    DR1 -->|"fetches from"| DA2
    DA2 -->|"uses"| DA1
    DA1 -->|"maps response"| DA3
    DA1 -->|"maps response"| DA4

    %% DI wiring
    DI -->|"injects"| PS7
    DI -->|"injects"| DA5
    DI -->|"wires"| DR1

    %% Core modules support testing across layers
    CORE ---|"tests"| PS1
    CORE ---|"tests"| DU1
    CORE ---|"tests"| DR1
    CORE ---|"tests"| DA1

    %% Styling Classes
    classDef presentation fill:#f9e79f,stroke:#7d6608,stroke-width:2px;
    classDef domain fill:#aed6f1,stroke:#1b4f72,stroke-width:2px;
    classDef data fill:#a9dfbf,stroke:#1d8348,stroke-width:2px;
    classDef dataapi fill:#f5b7b1,stroke:#922b21,stroke-width:2px;
    classDef di fill:#d7bde2,stroke:#6c3483,stroke-width:2px;
    classDef core fill:#d5f5e3,stroke:#239b56,stroke-width:2px;

    %% Click Events
    %% Presentation Layer Clicks
    click PS1 "https://github.com/ferprieto/spacex-prepare-for-clean-architecture-liftoff/tree/master/app/src/main/java/prieto/fernando/spacex/presentation/screens"
    click PS2 "https://github.com/ferprieto/spacex-prepare-for-clean-architecture-liftoff/tree/master/app/src/main/java/prieto/fernando/spacex/presentation/screens"
    click PS3 "https://github.com/ferprieto/spacex-prepare-for-clean-architecture-liftoff/tree/master/app/src/main/java/prieto/fernando/spacex/presentation/screens"
    click PS4 "https://github.com/ferprieto/spacex-prepare-for-clean-architecture-liftoff/blob/master/app/src/main/java/prieto/fernando/spacex/presentation/navigation/BottomNavigationScreens.kt"
    click PV1 "https://github.com/ferprieto/spacex-prepare-for-clean-architecture-liftoff/blob/master/app/src/main/java/prieto/fernando/spacex/presentation/vm/DashboardViewModel.kt"
    click PV2 "https://github.com/ferprieto/spacex-prepare-for-clean-architecture-liftoff/blob/master/app/src/main/java/prieto/fernando/spacex/presentation/vm/LaunchesViewModel.kt"
    click PS7 "https://github.com/ferprieto/spacex-prepare-for-clean-architecture-liftoff/blob/master/app/src/main/java/prieto/fernando/spacex/presentation/vm/di/PresentationModule.kt"

    %% Domain Layer Clicks
    click DU1 "https://github.com/ferprieto/spacex-prepare-for-clean-architecture-liftoff/blob/master/domain/src/main/java/prieto/fernando/domain/usecase/GetCompanyInfo.kt"
    click DU2 "https://github.com/ferprieto/spacex-prepare-for-clean-architecture-liftoff/blob/master/domain/src/main/java/prieto/fernando/domain/usecase/GetLaunches.kt"
    click DM1 "https://github.com/ferprieto/spacex-prepare-for-clean-architecture-liftoff/blob/master/domain/src/main/java/prieto/fernando/domain/model/CompanyInfoDomainModel.kt"
    click DM2 "https://github.com/ferprieto/spacex-prepare-for-clean-architecture-liftoff/blob/master/domain/src/main/java/prieto/fernando/domain/model/LaunchDomainModel.kt"
    click DM3 "https://github.com/ferprieto/spacex-prepare-for-clean-architecture-liftoff/blob/master/domain/src/main/java/prieto/fernando/domain/mapper/LaunchesDomainFilter.kt"

    %% Data Repository Module Clicks
    click DR1 "https://github.com/ferprieto/spacex-prepare-for-clean-architecture-liftoff/blob/master/data/src/main/java/prieto/fernando/data/repository/SpaceXRepositoryImpl.kt"
    click DR2 "https://github.com/ferprieto/spacex-prepare-for-clean-architecture-liftoff/blob/master/data/src/main/java/prieto/fernando/data/mapper/CompanyInfoRepositoryToDomainModelMapperImpl.kt"
    click DR3 "https://github.com/ferprieto/spacex-prepare-for-clean-architecture-liftoff/blob/master/data/src/main/java/prieto/fernando/data/mapper/LaunchesRepositoryToDomainModelMapperImpl.kt"
    click DR4 "https://github.com/ferprieto/spacex-prepare-for-clean-architecture-liftoff/tree/master/data/src/main/java/prieto/fernando/data/model"

    %% Data API Module Clicks
    click DA1 "https://github.com/ferprieto/spacex-prepare-for-clean-architecture-liftoff/blob/master/data-api/src/main/java/prieto/fernando/data_api/ApiService.kt"
    click DA2 "https://github.com/ferprieto/spacex-prepare-for-clean-architecture-liftoff/blob/master/data-api/src/main/java/prieto/fernando/data_api/data/SpaceXRemoteSourceImpl.kt"
    click DA3 "https://github.com/ferprieto/spacex-prepare-for-clean-architecture-liftoff/blob/master/data-api/src/main/java/prieto/fernando/data_api/mapper/CompanyInfoResponseToRepositoryModelMapperImpl.kt"
    click DA4 "https://github.com/ferprieto/spacex-prepare-for-clean-architecture-liftoff/blob/master/data-api/src/main/java/prieto/fernando/data_api/mapper/LaunchesResponseToRepositoryModelMapperImpl.kt"
    click DA5 "https://github.com/ferprieto/spacex-prepare-for-clean-architecture-liftoff/tree/master/data-api/src/main/java/prieto/fernando/data_api/di"

    %% Core Modules Clicks
    click CORE "https://github.com/ferprieto/spacex-prepare-for-clean-architecture-liftoff/tree/master/core-android-test/src/main/java/prieto/fernando/core_android_test"
```
