# arjun-6573/pixabay-search architecture

> Architecture diagram of the GitHub repository arjun-6573/pixabay-search, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/arjun-6573/pixabay-search
- Repository: https://github.com/arjun-6573/pixabay-search

## Overview

##### Project type and purpose
- This is an Android mobile application (“Pixabay Search Images”) built with Kotlin.
- It follows Clean Architecture with MVVM, uses Retrofit (with cache), Coroutines & Flow, Hilt for DI, and Jetpack Compose for UI.
- Purpose: fetch and display images from the Pixabay REST API, allow searching by keyword, and show image details.

##### File structure
- app/src/main/java/com/example/pixabayseachimage
- ui/…                  → Presentation layer: Compose screens, Navigation (MyNavGraph), ViewModels
- domain/…              → Domain layer: Entities, repository interfaces, use‐cases
- data/…                → Data layer: RemoteDataSource, Retrofit API definitions, repository implementations, mappers
- di/…                  → Hilt modules (AppModule) for wiring up dependencies
- utils/…, dispatcher   → Utility classes & custom Coroutine dispatchers
- Tests mirror layers for unit tests (FakeRemoteDataSource, ViewModel tests, etc.)
- Config files: build.gradle, proguard, gradle.properties (API key), network interceptor rules

##### README for additional insights
- Confirms “Offline first” via Retrofit cache.
- Emphasizes MVVM clean architecture and Kotlin Flow for UI state.
- Lists major libraries: Retrofit, Hilt, Coroutine, Coil (image loader), Timber, LeakCanary.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        SIS["SearchImageScreen"]:::presentation
        IDS["ImageDetailsScreen"]:::presentation
        NAG["MyNavGraph"]:::presentation
        VM["SearchImagesViewModel"]:::presentation
    end

    %% Domain Layer
    subgraph "Domain Layer"
        direction TB
        UC["SearchImageUseCase"]:::domain
        RI["SearchRepository"]:::domain
        EI["ImageInfoEntity"]:::domain
        UE["UserEntity"]:::domain
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        RPI["SearchRepositoryImpl"]:::data
        RDS["RemoteDataSource"]:::data
        RDI["RemoteDataSourceImpl"]:::data
        API["MyApi"]:::data
        RIc["RequestInterceptor"]:::data
        SAR["SearchAPIResponse"]:::data
        DM["DataMapper"]:::data
        UDM["UIDataMapper"]:::data
    end

    %% Infrastructure Layer
    subgraph "Infrastructure"
        direction TB
        AM["AppModule"]:::infra
        MD["MyDispatchers"]:::infra
        MDI["MyDispatchersImpl"]:::infra
        AC["AppConstants"]:::infra
        NU["NetworkUtils"]:::infra
        UU["UIUtils"]:::infra
        MA["MyApplication"]:::infra
    end

    %% External
    subgraph "External Services"
        direction TB
        PX["Pixabay REST API"]:::external
    end

    %% Relationships - Calls
    SIS -->|"observes"| VM
    IDS -->|"observes"| VM
    NAG -->|"navigates to screens"| SIS
    NAG -->|"navigates to screens"| IDS
    VM -->|"invokes"| UC
    UC -->|"calls"| RI
    RI -->|"implemented by"| RPI
    RPI -->|"uses"| RDS
    RDS -->|"implemented by"| RDI
    RDI -->|"executes"| API
    API -->|"uses interceptor"| RIc
    API -->|"calls"| PX

    %% Data return (dotted)
    PX -.->|"response"| API
    API -.->|"raw data"| RDI
    RDI -.->|"maps to data model"| DM
    RPI -.->|"maps to domain"| UC
    UC -.->|"returns domain entities"| VM
    VM -.->|"UI models via"| UDM
    VM -.->|"updates stateflow"| SIS

    %% Cross-cutting
    VM -->|"injects dispatchers"| MD
    UC -->|"uses dispatchers"| MD
    RPI -->|"uses dispatchers"| MD
    AM -->|"provides dependencies"| VM
    AM -->|"provides dependencies"| UC
    AM -->|"provides dependencies"| RPI
    AM -->|"provides dependencies"| API
    MA -->|"initializes Hilt"| AM

    %% Click Events
    click SIS "https://github.com/arjun-6573/pixabay-search/blob/main/app/src/main/java/com/example/pixabayseachimage/ui/searchImages/SearchImageScreen.kt"
    click IDS "https://github.com/arjun-6573/pixabay-search/blob/main/app/src/main/java/com/example/pixabayseachimage/ui/imageDetails/ImageDeailsScreen.kt"
    click NAG "https://github.com/arjun-6573/pixabay-search/blob/main/app/src/main/java/com/example/pixabayseachimage/ui/MyNavGraph.kt"
    click VM "https://github.com/arjun-6573/pixabay-search/blob/main/app/src/main/java/com/example/pixabayseachimage/ui/searchImages/SearchImagesViewModel.kt"
    click UC "https://github.com/arjun-6573/pixabay-search/blob/main/app/src/main/java/com/example/pixabayseachimage/domain/usecases/SearchImageUseCase.kt"
    click RI "https://github.com/arjun-6573/pixabay-search/blob/main/app/src/main/java/com/example/pixabayseachimage/domain/repositories/SearchRepository.kt"
    click EI "https://github.com/arjun-6573/pixabay-search/blob/main/app/src/main/java/com/example/pixabayseachimage/domain/entity/ImageInfoEntity.kt"
    click UE "https://github.com/arjun-6573/pixabay-search/blob/main/app/src/main/java/com/example/pixabayseachimage/domain/entity/UserEntity.kt"
    click RPI "https://github.com/arjun-6573/pixabay-search/blob/main/app/src/main/java/com/example/pixabayseachimage/data/repositories/SearchRepositoryImpl.kt"
    click RDS "https://github.com/arjun-6573/pixabay-search/blob/main/app/src/main/java/com/example/pixabayseachimage/data/datasources/RemoteDataSource.kt"
    click RDI "https://github.com/arjun-6573/pixabay-search/blob/main/app/src/main/java/com/example/pixabayseachimage/data/datasources/RemoteDataSourceImpl.kt"
    click API "https://github.com/arjun-6573/pixabay-search/blob/main/app/src/main/java/com/example/pixabayseachimage/data/remote/MyApi.kt"
    click RIc "https://github.com/arjun-6573/pixabay-search/blob/main/app/src/main/java/com/example/pixabayseachimage/data/remote/RequestInterceptor.kt"
    click SAR "https://github.com/arjun-6573/pixabay-search/blob/main/app/src/main/java/com/example/pixabayseachimage/data/remote/reponse/SearchAPIResponse.kt"
    click DM "https://github.com/arjun-6573/pixabay-search/blob/main/app/src/main/java/com/example/pixabayseachimage/data/mappers/DataMapper.kt"
    click UDM "https://github.com/arjun-6573/pixabay-search/blob/main/app/src/main/java/com/example/pixabayseachimage/ui/mappers/UIDataMapper.kt"
    click AM "https://github.com/arjun-6573/pixabay-search/blob/main/app/src/main/java/com/example/pixabayseachimage/di/AppModule.kt"
    click MD "https://github.com/arjun-6573/pixabay-search/blob/main/app/src/main/java/com/example/pixabayseachimage/utils/dispatcher/MyDispatchers.kt"
    click MDI "https://github.com/arjun-6573/pixabay-search/blob/main/app/src/main/java/com/example/pixabayseachimage/utils/dispatcher/MyDispatchersImpl.kt"
    click AC "https://github.com/arjun-6573/pixabay-search/blob/main/app/src/main/java/com/example/pixabayseachimage/utils/AppConstants.kt"
    click NU "https://github.com/arjun-6573/pixabay-search/blob/main/app/src/main/java/com/example/pixabayseachimage/utils/NetworkUtils.kt"
    click UU "https://github.com/arjun-6573/pixabay-search/blob/main/app/src/main/java/com/example/pixabayseachimage/utils/UIUtils.kt"
    click MA "https://github.com/arjun-6573/pixabay-search/blob/main/app/src/main/java/com/example/pixabayseachimage/MyApplication.kt"

    %% Styles
    classDef presentation fill:lightblue,stroke:#333,stroke-width:1px;
    classDef domain fill:lightgreen,stroke:#333,stroke-width:1px;
    classDef data fill:lightsalmon,stroke:#333,stroke-width:1px;
    classDef infra fill:lightgray,stroke:#333,stroke-width:1px;
    classDef external fill:#f0f0f0,stroke:#333,stroke-width:1px;
```
