How umairoye/ai-art-generator works
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.