Android Jetpack Compose with MVI

mobile
Kotlin
architecture
strict_senior
Remix

Modern Android app using Jetpack Compose with MVI architecture and Kotlin Coroutines.

12/8/2025

Prompt

Build a production-ready Android application using Jetpack Compose with MVI (Model-View-Intent) architecture for the following requirements:

App Overview

  • App Name: [e.g., TaskFlow, NewsReader, FitnessTracker]
  • App Purpose: [What does this app do?]
  • Target Android Version: [API 24+ / API 26+ / API 28+]
  • Tablet Support: [Yes / Phone only]
  • Target Audience: [Who will use this app?]

Core Features

Define 4-8 main features/screens:

Feature 1: [Feature Name]

  • Screen Type: [List screen / Detail screen / Form / Dashboard / Custom]
  • Data Source: [REST API / GraphQL / Room Database / Firebase / Static]
  • User Interactions: [Tap, swipe, pull-to-refresh, search, filter, etc.]
  • Navigation: [Standard / Bottom sheet / Dialog / New activity]
  • State Complexity: [Simple / Medium / Complex with multiple states]

Feature 2: [Feature Name]

  • Screen Type: [Type of screen]
  • Data Source: [Where data comes from]
  • User Interactions: [List interactions]
  • Navigation: [Navigation type]
  • State Complexity: [Complexity level]

[Continue for 4-8 features]

Data Models

Define your main data models:

Model 1: [Name]

  • Properties: [List properties with types: id: Int, name: String, timestamp: Long, etc.]
  • Serialization: [Kotlinx.serialization / Gson / Moshi / None]
  • Room Entity: [Yes / No]
  • Relationships: [Related to other models if any]

Model 2: [Name]

  • Properties: [List properties with types]
  • Serialization: [Serialization library]
  • Room Entity: [Yes / No]
  • Relationships: [Related models]

[Define 3-6 models total]

MVI Architecture Details

State Management

For each feature, define:

  • State Data Class: [Properties that represent UI state]
  • Events (User Actions): [List user-triggered events]
  • Side Effects: [Navigation, toasts, one-time events]
  • State Updates: [How state changes based on events]

ViewModel Structure

  • StateFlow vs LiveData: [StateFlow / LiveData / Both]
  • Initial State: [Default state for each screen]
  • State Reduction: [How events transform state]
  • Coroutine Scopes: [viewModelScope usage patterns]

Network Layer

  • API Type: [REST / GraphQL / WebSocket / None]
  • Base URL: [Provide URL or placeholder: https://api.example.com]
  • HTTP Client: [Retrofit / Ktor / OkHttp / None]
  • Authentication: [Bearer token / API key / OAuth / None]
  • API Endpoints: [List endpoints: GET /users, POST /items, etc.]
  • Response Format: [JSON / XML / Protobuf]
  • Error Handling: [Custom error types / Standard / Simple]
  • Interceptors: [Logging / Auth / Retry / None]

Local Database (Room)

  • Database Required: [Yes / No]
  • Entities: [List Room entities]
  • DAOs: [Data Access Objects needed]
  • Migrations: [Auto-migration / Manual / Not needed]
  • Type Converters: [For complex types: Date, List, etc.]
  • Caching Strategy: [Cache-first / Network-first / Offline-first]

Dependency Injection (Hilt)

  • Modules Needed:
    • NetworkModule: [Yes / No]
    • DatabaseModule: [Yes / No]
    • RepositoryModule: [Yes / No]
    • UseCaseModule: [Yes / No]
  • Scopes: [Singleton / ActivityRetained / ViewModelScoped]
  • Qualifiers: [Named dependencies if needed]

UI/UX Requirements

Material Design 3

  • Color Scheme: [Dynamic colors / Custom palette / Material default]
  • Custom Colors: [Primary, Secondary, Tertiary if custom]
  • Theme: [Light/Dark mode support / Light only / Dark only]
  • Typography: [Custom font families or Material default]

Navigation

  • Navigation Component: [Jetpack Navigation Compose / Custom]
  • Navigation Pattern: [Bottom nav / Nav drawer / Top tabs / Custom]
  • Deep Links: [Required / Not needed]
  • Back Stack Handling: [Standard / Custom behavior]

UI States

  • Loading States: [CircularProgressIndicator / Shimmer / Skeleton / Custom]
  • Error States: [Full screen error / Snackbar / Dialog / Custom]
  • Empty States: [Custom illustrations / Simple message / None]
  • Success Feedback: [Snackbar / Toast / Animation / None]

Animations

  • Screen Transitions: [Slide / Fade / Scale / None]
  • List Animations: [AnimatedVisibility / Crossfade / None]
  • Custom Animations: [Specify any special animations]

Repository Pattern

  • Repository Structure: [One per feature / One per entity / Combined]
  • Data Sources: [Remote + Local / Remote only / Local only]
  • Cache Strategy: [Time-based / Manual / None]
  • Offline Support: [Full offline mode / Read-only / Not needed]
  • Result Wrapper: [Result<T> / Resource<T> / Custom / None]

Additional Features

  • Search: [Required with scope: [SPECIFY] / Not needed]
  • Filtering/Sorting: [Yes with options: [LIST] / No]
  • Pull-to-Refresh: [Yes / No]
  • Pagination: [Paging 3 library / Manual / Not needed]
  • Image Loading: [Coil / Glide / Custom / Not needed]
  • Notifications: [Local / Push (FCM) / Both / None]
  • Analytics: [Firebase Analytics / Custom / None]
  • Crash Reporting: [Firebase Crashlytics / Custom / None]
  • Biometric Auth: [Required / Not needed]
  • Camera/Gallery: [Required / Not needed]
  • File Downloads: [Required / Not needed]

Testing Requirements

  • Unit Tests: [ViewModels / Repositories / UseCases / None]
  • UI Tests: [Compose UI tests / Espresso / None]
  • Test Coverage: [High / Medium / Basic / None]
  • Mock Framework: [MockK / Mockito / None]

Project Structure

  • Package Organization: [Feature-based / Layer-based / Clean Architecture]
  • Module Structure: [Single module / Multi-module / Dynamic feature modules]
  • Naming Conventions: [Standard Android / Custom]

Build Configuration

  • Min SDK: [24 / 26 / 28 / Other]
  • Target SDK: [34 / 33 / Latest]
  • Kotlin Version: [Latest stable / Specific version]
  • Gradle: [Kotlin DSL / Groovy]
  • Build Variants: [Debug/Release only / Custom flavors]

Code Generation Requirements

Generate a complete Android Jetpack Compose app with MVI architecture including:

  1. Project Setup:

    • build.gradle.kts (project and app level) with all dependencies
    • Version catalog (libs.versions.toml) for dependency management
    • Hilt setup with @HiltAndroidApp
    • Proguard rules if needed
  2. Data Layer:

    • Data models with proper serialization
    • Room database entities, DAOs, and database class (if needed)
    • API service interfaces with Retrofit (if needed)
    • Repository implementations with proper error handling
  3. Domain Layer (if Clean Architecture):

    • Use case classes for business logic
    • Domain models separate from data models
    • Repository interfaces
  4. Presentation Layer (MVI):

    • State data classes for each screen
    • Event sealed classes for user actions
    • Side effect sealed classes for one-time events
    • ViewModels with StateFlow and event handling
    • Proper state reduction logic
  5. UI Layer (Jetpack Compose):

    • All screen composables with state hoisting
    • Reusable UI components
    • Material 3 theming (Color, Typography, Theme)
    • Navigation graph with all routes
    • Loading, error, and empty state composables
  6. Dependency Injection:

    • Hilt modules for all dependencies
    • Proper scoping (@Singleton, @ViewModelScoped)
    • Network, database, and repository provision
  7. Utilities:

    • Extension functions for common operations
    • Resource wrapper for API responses
    • Constants and configuration
    • Date/time formatters if needed
  8. Configuration Files:

    • AndroidManifest.xml with permissions and activities
    • strings.xml with all text resources
    • colors.xml and themes.xml (if using XML themes)

Output production-ready Kotlin code following Android best practices with:

  • Unidirectional data flow (MVI pattern)
  • Immutable state with data classes
  • Proper coroutine usage with structured concurrency
  • Type-safe navigation
  • Material Design 3 guidelines
  • Accessibility support
  • Proper error handling and logging
  • Clean separation of concerns
  • Comprehensive null safety

Tags

android
jetpack-compose
mvi
kotlin

Tested Models

gpt-4
claude-3-5-sonnet

Comments (0)

Sign in to leave a comment

Sign In