# deiivid/clean_arquitecture_compose architecture

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

- Interactive diagram: https://gitdiagram.com/deiivid/clean_arquitecture_compose
- Repository: https://github.com/deiivid/clean_arquitecture_compose

## Overview

##### Main Architectural Layers
- Presentation Layer: This includes the UI components (Jetpack Compose screens, navigation elements, and view models located under the “ui” and “presentation” directories in Java), as well as state management with resource state, error screens, and loading screens.
- Domain Layer: Contains business logic and use cases (see directories under “domain”), including use cases like AllCharactersUseCase, AllEpisodesUseCase, and AllLocationsUseCase.
- Data Layer: Holds all repository implementations, remote data stores, API communication (Retrofit), mapping, pagination (Paging 3), and models. Directories like “data/remote”, “data/service”, and “data/di” are key here.
- Dependency Injection: Implemented via Dagger Hilt. This is critical for wiring up components from the data, domain, and presentation layers together (note the “data/di” module and application class components).

##### Out the Relationships/Interactions Between Components
- ViewModels (Presentation Layer): Act as the intermediary between the UI and the Domain. They invoke use cases from the Domain and provide data back to the UI.
- Domain Layer: Contains the business logic in the form of use cases. Use cases call the repositories in the Data Layer to retrieve or update data.
- Data Layer: Responsible for API communication via Retrofit (e.g., RickyMortyService) and manages data transformation (using response mappers) before handing it off to the domain. It also includes error handling, pagination (Paging 3), and factory classes for model creation.
- External Libraries & Tools: Represent libraries like Kotlin Coroutines (for asynchronous processing), Paging 3 for pagination support, Lottie for animations, and Material 3 for theming.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        PresChars["Characters Screens"]:::presentation
        PresEps["Episodes Screens"]:::presentation
        PresLoc["Locations Screens"]:::presentation
        PresSplash["Splash Screen"]:::presentation
        PresNav["Navigation Graphs"]:::presentation
        PV_Chars["CharactersViewModel"]:::presentation
        PV_Eps["EpisodesViewModel"]:::presentation
        PV_Loc["LocationsViewModel"]:::presentation
    end

    %% Domain Layer
    subgraph "Domain Layer"
        Dom_Char["AllCharactersUseCase"]:::domain
        Dom_Eps["AllEpisodesUseCase"]:::domain
        Dom_Loc["AllLocationsUseCase"]:::domain
        Dom_Repo["Domain Repositories"]:::domain
    end

    %% Data Layer
    subgraph "Data Layer"
        Data_API["RickyMortyService"]:::data
        Data_CharStore["RemoteCharacterDataStoreImpl"]:::data
        Data_CharMap["CharactersResponseMapper"]:::data
        Data_CharRepo["CharacterRepositoryImpl"]:::data
        Data_EpsStore["RemoteEpisodesDataStoreImpl"]:::data
        Data_EpsMap["EpisodesResponseMapper"]:::data
        Data_EpsRepo["EpisodesRepositoryImpl"]:::data
        Data_LocStore["RemoteLocationsDataStoreImpl"]:::data
        Data_LocMap["LocationsResponseMapper"]:::data
        Data_LocRepo["LocationsRepository"]:::data
    end

    %% Dependency Injection
    subgraph "Dependency Injection"
        DI_Network["NetworkModule (DI)"]:::di
        DI_App["CleanArchitectureComposeDN"]:::di
    end

    %% Presentation Layer Connections
    PresChars --> PV_Chars
    PresEps --> PV_Eps
    PresLoc --> PV_Loc
    PresNav --> PresChars
    PresNav --> PresEps
    PresNav --> PresLoc

    %% ViewModel to Domain Layer Connections
    PV_Chars --> Dom_Char
    PV_Eps --> Dom_Eps
    PV_Loc --> Dom_Loc

    %% Domain to Data Layer Connections
    Dom_Char --> Data_CharRepo
    Dom_Eps --> Data_EpsRepo
    Dom_Loc --> Data_LocRepo

    %% Data Layer Internal Connections
    Data_CharStore --> Data_CharRepo
    Data_CharMap --> Data_CharRepo
    Data_EpsStore --> Data_EpsRepo
    Data_EpsMap --> Data_EpsRepo
    Data_LocStore --> Data_LocRepo
    Data_LocMap --> Data_LocRepo

    %% Data Layer API Calls
    Data_CharStore --> Data_API
    Data_EpsStore --> Data_API
    Data_LocStore --> Data_API

    %% Dependency Injection Connections
    DI_Network --> Data_API
    DI_Network --> Data_CharRepo
    DI_Network --> Data_EpsRepo
    DI_Network --> Data_LocRepo
    DI_App --> PV_Chars
    DI_App --> PV_Eps
    DI_App --> PV_Loc

    %% Style Definitions
    classDef presentation fill:#ADD8E6,stroke:#000,stroke-width:1px;
    classDef domain fill:#90EE90,stroke:#000,stroke-width:1px;
    classDef data fill:#FFA500,stroke:#000,stroke-width:1px;
    classDef di fill:#DA70D6,stroke:#000,stroke-width:1px;

    %% Click Events for Presentation Layer
    click PresChars "https://github.com/deiivid/clean_arquitecture_compose/tree/master/app/src/main/java/es/clean/architecture/ui/views/characters/screens"
    click PresEps "https://github.com/deiivid/clean_arquitecture_compose/tree/master/app/src/main/java/es/clean/architecture/ui/views/episodes"
    click PresLoc "https://github.com/deiivid/clean_arquitecture_compose/tree/master/app/src/main/java/es/clean/architecture/ui/views/locations"
    click PresSplash "https://github.com/deiivid/clean_arquitecture_compose/blob/master/app/src/main/java/es/clean/architecture/ui/views/splash/AnimatedSplashScreen.kt"
    click PresNav "https://github.com/deiivid/clean_arquitecture_compose/tree/master/app/src/main/java/es/clean/architecture/ui/common/navigation"
    click PV_Chars "https://github.com/deiivid/clean_arquitecture_compose/blob/master/app/src/main/java/es/clean/architecture/ui/views/characters/viewmodel/CharactersViewModel.kt"
    click PV_Eps "https://github.com/deiivid/clean_arquitecture_compose/blob/master/app/src/main/java/es/clean/architecture/ui/views/episodes/viewmodel/EpisodesViewModel.kt"
    click PV_Loc "https://github.com/deiivid/clean_arquitecture_compose/blob/master/app/src/main/java/es/clean/architecture/ui/views/locations/viewmodel/LocationsViewModel.kt"

    %% Click Events for Domain Layer
    click Dom_Char "https://github.com/deiivid/clean_arquitecture_compose/blob/master/app/src/main/java/es/clean/architecture/domain/characters/repository/characters/AllCharactersUseCase.kt"
    click Dom_Eps "https://github.com/deiivid/clean_arquitecture_compose/blob/master/app/src/main/java/es/clean/architecture/domain/episodes/repository/AllEpisodesUseCase.kt"
    click Dom_Loc "https://github.com/deiivid/clean_arquitecture_compose/blob/master/app/src/main/java/es/clean/architecture/domain/locations/repository/AllLocationsUseCase.kt"
    click Dom_Repo "https://github.com/deiivid/clean_arquitecture_compose/tree/master/app/src/main/java/es/clean/architecture/domain"

    %% Click Events for Data Layer
    click Data_API "https://github.com/deiivid/clean_arquitecture_compose/blob/master/app/src/main/java/es/clean/architecture/data/service/RickyMortyService.kt"
    click Data_CharStore "https://github.com/deiivid/clean_arquitecture_compose/blob/master/app/src/main/java/es/clean/architecture/data/remote/characters/datastore/RemoteCharacterDataStoreImpl.kt"
    click Data_CharMap "https://github.com/deiivid/clean_arquitecture_compose/blob/master/app/src/main/java/es/clean/architecture/data/remote/characters/mapper/CharactersResponseMapper.kt"
    click Data_CharRepo "https://github.com/deiivid/clean_arquitecture_compose/blob/master/app/src/main/java/es/clean/architecture/data/remote/characters/repository/CharacterRepositoryImpl.kt"
    click Data_EpsStore "https://github.com/deiivid/clean_arquitecture_compose/blob/master/app/src/main/java/es/clean/architecture/data/remote/episodes/datastore/RemoteEpisodesDataStoreImpl.kt"
    click Data_EpsMap "https://github.com/deiivid/clean_arquitecture_compose/blob/master/app/src/main/java/es/clean/architecture/data/remote/episodes/mapper/EpisodesResponseMapper.kt"
    click Data_EpsRepo "https://github.com/deiivid/clean_arquitecture_compose/blob/master/app/src/main/java/es/clean/architecture/data/remote/episodes/repository/EpisodesRepositoryImpl.kt"
    click Data_LocStore "https://github.com/deiivid/clean_arquitecture_compose/blob/master/app/src/main/java/es/clean/architecture/data/remote/locations/datastore/RemoteLocationsDataStoreImpl.kt"
    click Data_LocMap "https://github.com/deiivid/clean_arquitecture_compose/blob/master/app/src/main/java/es/clean/architecture/data/remote/locations/mapper/LocationsResponseMapper.kt"
    click Data_LocRepo "https://github.com/deiivid/clean_arquitecture_compose/blob/master/app/src/main/java/es/clean/architecture/data/remote/locations/repository/LocationsRepository.kt"

    %% Click Events for Dependency Injection
    click DI_Network "https://github.com/deiivid/clean_arquitecture_compose/blob/master/app/src/main/java/es/clean/architecture/data/di/NetworkModule.kt"
    click DI_App "https://github.com/deiivid/clean_arquitecture_compose/blob/master/app/src/main/java/es/clean/architecture/ui/application/CleanArchitectureComposeDN.kt"
```
