# umairoye/ai-art-generator architecture

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

- Interactive diagram: https://gitdiagram.com/umairoye/ai-art-generator
- Repository: https://github.com/umairoye/ai-art-generator

## Overview

##### Project Type and Purpose
- This is an Android mobile client (“AI Art Generator App”) that follows Clean Architecture and MVVM.
- It uses Retrofit to call an external Stable Diffusion API, Kotlin Flows for state management, Glide for image loading, and Dagger-Hilt for dependency injection.

##### Main Components
- Presentation Layer
– UI Components: Activity (MainActivity) + Fragments (Home, Downloader) + RecyclerView Adapter (ModelsAdapter)
– ViewModel (ArtViewModel)
– Application Subclass (ArtApplication) for Hilt setup
- Domain Layer
– Models (DreamBoothRequest, DreamBoothResponse, MetaData, RequestState)
– Repository Interface (ArtRepository)
- Data Layer
– Remote API Service (ApiService via Retrofit)
– Repository Implementation (ArtRepositoryImplementation)
– DI Modules (RetrofitInjection, RepositoryInjection)
- External Service
– Stable Diffusion API endpoint (BASE_URL + END_POINT)
- Third-Party Libraries & Frameworks
– Retrofit, Gson
– Kotlin Coroutines & Flow
– Glide
– Dagger-Hilt
– Android Jetpack (ViewModel, LiveData optional)

##### Relationships and Data Flows
- UI Action → ViewModel.invoke()
- ViewModel calls ArtRepository.makeApiRequest()
- ArtRepositoryImplementation uses ApiService.enqueue()
- Response mapped to RequestState<MetaData> via Kotlin Flow
- Flow emits Loading → Success or Error
- ViewModel collects Flow → updates UI state
- UI observes state → updates Fragments, loads image with Glide

##### Architectural Patterns & Design Principles
- Clean Architecture Layers: Presentation → Domain → Data
- MVVM: separates UI from business logic
- Dependency Injection with Hilt: modules for Retrofit & Repository
- Repository Pattern: hides network details behind interface
- Reactive Streams: Flows for asynchronous state handling

##### Detailed Elements
- Components: Activity/Fragments, ViewModel, Repository Interface, Repository Impl, Retrofit Client, ApiService, DI Modules, External API.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "UI Layer"
        UI["MainActivity/Fragments\n(Home, Downloader)"]:::ui
        Adapter["ModelsAdapter"]:::ui
        Glide["Glide"]:::ui
    end

    subgraph "Presentation Layer"
        App["ArtApplication"]:::presentation
        VM["ArtViewModel"]:::presentation
    end

    subgraph "Domain Layer"
        RepoI["ArtRepository"]:::domain
        Req["DreamBoothRequest"]:::domain
        Res["DreamBoothResponse"]:::domain
        MD["MetaData"]:::domain
        State["RequestState"]:::domain
        DM["DreamBoothModel"]:::domain
    end

    subgraph "Data Layer"
        RI["RetrofitInjection"]:::data
        API["ApiService"]:::data
        RepoImpl["ArtRepositoryImplementation"]:::data
        RInj["RepositoryInjection"]:::data
    end

    External["Stable Diffusion API"]:::external

    %% Data Flow
    UI -->|"user action"| VM
    VM -->|"makeApiRequest()"| RepoI
    RepoI -.->|"implements"| RepoImpl
    RepoImpl -->|"enqueue(DreamBoothRequest)"| API
    API -->|"HTTP request"| External
    External -->|"DreamBoothResponse"| API
    API -->|"map response"| RepoImpl
    RepoImpl -->|"Flow<RequestState<MetaData>>"| VM
    VM -->|"collect Flow"| UI
    UI -->|"loadUrl with Glide"| Glide

    %% Dependency Injection
    App --> RI
    App --> RInj
    RI --> API
    RInj --> RepoImpl

    %% Click Events
    click App "https://github.com/umairoye/ai-art-generator/blob/main/app/src/main/java/com/example/imageartgenerator/presentation/artApp/ArtApplication.kt"
    click VM "https://github.com/umairoye/ai-art-generator/blob/main/app/src/main/java/com/example/imageartgenerator/presentation/viewModels/ArtViewModel.kt"
    click Adapter "https://github.com/umairoye/ai-art-generator/blob/main/app/src/main/java/com/example/imageartgenerator/presentation/adapters/ModelsAdapter.kt"
    click API "https://github.com/umairoye/ai-art-generator/blob/main/app/src/main/java/com/example/imageartgenerator/data/remote/api/ApiService.kt"
    click RI "https://github.com/umairoye/ai-art-generator/blob/main/app/src/main/java/com/example/imageartgenerator/data/remote/api/RetrofitInjection.kt"
    click RepoImpl "https://github.com/umairoye/ai-art-generator/blob/main/app/src/main/java/com/example/imageartgenerator/data/remote/repo/ArtRepositoryImplementation.kt"
    click RInj "https://github.com/umairoye/ai-art-generator/blob/main/app/src/main/java/com/example/imageartgenerator/data/remote/repo/RepositoryInjection.kt"
    click RepoI "https://github.com/umairoye/ai-art-generator/blob/main/app/src/main/java/com/example/imageartgenerator/domain/repository/ArtRepository.kt"
    click Req "https://github.com/umairoye/ai-art-generator/blob/main/app/src/main/java/com/example/imageartgenerator/domain/models/DreamBoothRequest.kt"
    click Res "https://github.com/umairoye/ai-art-generator/blob/main/app/src/main/java/com/example/imageartgenerator/domain/models/DreamBoothResponse.kt"
    click MD "https://github.com/umairoye/ai-art-generator/blob/main/app/src/main/java/com/example/imageartgenerator/domain/models/MetaData.kt"
    click State "https://github.com/umairoye/ai-art-generator/blob/main/app/src/main/java/com/example/imageartgenerator/domain/models/RequestState.kt"
    click DM "https://github.com/umairoye/ai-art-generator/blob/main/app/src/main/java/com/example/imageartgenerator/domain/models/DreamBoothModel.kt"

    %% Styles
    classDef ui fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef presentation fill:#C6EFCE,stroke:#000,stroke-width:1px
    classDef domain fill:#90EE90,stroke:#000,stroke-width:1px
    classDef data fill:#FFA500,stroke:#000,stroke-width:1px
    classDef external fill:#DDA0DD,stroke:#000,stroke-width:1px
```
