Skip to main content

Kotlin Jetpack Compose Design Patterns

Master Jetpack Compose patterns: state management, navigation, theming, accessibility, and performance optimization for Android.

Fill in the placeholders

Edit the values, then copy your finished prompt.

Your Prompt
prompt.txt
You are an expert Android developer specializing in Jetpack Compose. Help me build a fitness tracking app using modern Compose design patterns.

Step 1: Set up the project architecture following the Clean Architecture with MVI pattern. Create the package structure with layers: presentation (Compose screens and ViewModels), domain (use cases and repository interfaces), and data (repository implementations, data sources, and DTOs). Configure Hilt for dependency injection. Show the module structure for a multi-module project with 5 feature modules.

Step 2: Implement the state management pattern using MVI with StateFlow. Create a BaseViewModel that exposes UI state via StateFlow and handles one-time events via SharedFlow (for navigation, snackbars, etc.). Design the UiState sealed class with Loading, Success, and Error variants. Implement the state hoisting pattern where Compose screens are stateless and receive state + event callbacks from the ViewModel.

Step 3: Build the navigation system using the Compose Navigation library. Define a type-safe navigation graph with 12 screens across 3 nested navigation graphs. Implement bottom navigation with state preservation, deep linking for myapp://feature/{id} URLs, and shared element transitions between list and detail screens. Handle back stack management for nested flows (e.g., onboarding, authentication).

Step 4: Create a Material 3 design system with custom theming. Define a MyApp theme with custom color schemes (light and dark), typography scale using Inter fonts, shape system, and motion tokens. Build reusable composable components: themed Button variants, Card layouts, TopAppBar configurations, and input fields with validation states. Ensure all components support dynamic color (Material You) on Android 12+.

Step 5: Implement accessibility best practices across all composables. Add content descriptions for images and icons, merge semantics for clickable containers, define custom accessibility actions for complex gestures, set minimum touch target sizes of 48dp, and support TalkBack navigation order. Test with the Accessibility Scanner and fix all flagged issues.

Step 6: Optimize Compose performance for smooth scrolling and transitions. Use Layout Inspector + Composition Tracing to identify unnecessary recompositions. Apply remember, derivedStateOf, and key modifiers strategically. Implement lazy loading for images using Coil. Profile the app to achieve under 16ms frame render time for all screen transitions.

What this prompt does

This prompt scaffolds a modern Android app in Jetpack Compose using current design patterns. It moves through six steps: setting up a layered architecture, implementing state management, building type-safe navigation, creating a Material 3 design system, applying accessibility practices, and optimizing recomposition performance. The result is a coherent foundation where screens stay stateless and predictable as the app grows, which is what keeps a multi-module project from drifting into spaghetti.

The variables tailor the scaffold to your project. [architecture_pattern] and [dependency_injection] set the structural backbone, [module_count] defines the multi-module layout, and [state_approach] decides how UI state flows. [screen_count] and [nav_graph_count] shape the navigation graph, [brand_name] and [font_family] drive theming, [touch_target_size] enforces accessibility minimums, and [profiling_tool], [image_library], and [frame_budget] govern the performance pass. Each variable maps to a concrete decision you would otherwise make ad hoc on day one.

When to use it

  • You are starting a native Android app and want a Compose architecture decided up front.
  • You need a stateless-screen, hoisted-state pattern instead of logic scattered in composables.
  • You want type-safe navigation across [screen_count] screens and nested graphs.
  • You are building a Material 3 theme with light, dark, and dynamic color support.
  • You want accessibility handled deliberately rather than retrofitted before launch.
  • You need a concrete plan for hunting unnecessary recompositions and hitting a frame budget.

Example output

Expect a module structure for a multi-module project, a BaseViewModel exposing UI state via StateFlow and one-time events via SharedFlow, and a sealed UiState with Loading/Success/Error variants. From there you get a type-safe navigation graph with bottom navigation and deep linking, a Material 3 theme definition with light/dark color schemes and a typography scale, reusable composable components, accessibility annotations, and a recomposition-optimization checklist. It is a mix of architecture description and Kotlin code spread across the presentation, domain, and data layers, with the state-hoisting pattern applied so that screens receive state plus event callbacks rather than owning logic themselves.

Pro tips

  • Match [architecture_pattern] and [state_approach] to your team's experience; MVI with StateFlow is powerful but adds ceremony for small apps, so weigh the overhead against the size of the project.
  • Set [module_count] to reflect real feature boundaries, not an arbitrary number, so the module graph stays meaningful.
  • Make sure [screen_count] and [nav_graph_count] are consistent with the flows you actually have, including auth and onboarding back-stack handling.
  • Keep [touch_target_size] at the platform minimum or above; accessibility scanners flag anything smaller.
  • Use [profiling_tool] early and feed real findings back into the prompt; recomposition wins come from removing wasted work, not adding code.
  • Pick an [image_library] you already use so lazy loading integrates cleanly with your existing build and caching setup.

Frequently Asked Questions

Does this assume a specific architecture or can I choose?
You choose via `[architecture_pattern]` and `[state_approach]`. The default is Clean Architecture with MVI and `StateFlow`, but you can swap in MVVM or another pattern. The prompt then structures the presentation, domain, and data layers to match your selection.
Will it handle dark mode and Material You dynamic color?
Yes. Step 4 builds a Material 3 theme with light and dark color schemes and ensures components support dynamic color on Android 12 and above. You set `[brand_name]` and `[font_family]` to control the palette and typography scale.
How does it address Compose performance?
Step 6 uses `[profiling_tool]` to find unnecessary recompositions and applies `remember`, `derivedStateOf`, and `key` strategically, plus lazy image loading via `[image_library]`. The target is keeping transitions under your `[frame_budget]`, though real results depend on profiling your own screens.
Is accessibility actually covered or just mentioned?
Step 5 is dedicated to it: content descriptions, merged semantics for clickable containers, custom accessibility actions, a minimum `[touch_target_size]`, and TalkBack navigation order, with a pass through the Accessibility Scanner. It is treated as implementation work, not an afterthought.
Engr Mejba Ahmed

Need this built for real?

Engr Mejba Ahmed

AI Developer · Software Engineer

I'm Mejba — I design and ship production AI systems, automations, and full-stack apps. If you want this turned into a working solution for your team, let's talk.

More in Mobile App Development Prompts

Engr Mejba Ahmed

Engr Mejba Ahmed

AI assistant · trained on my work

👋

Hey there!

Quick Actions

WhatsApp Direct line to me

Chat on WhatsApp

+880 1723 741224 · Replies within the hour on working days

Popular Questions

Engr Mejba Ahmed is connected
Engr Mejba Ahmed is typing...
Engr Mejba Ahmed avatar

✉ Want me to follow up? Drop your email

Engr Mejba Ahmed avatar

📞 Connect Directly

Choose how you'd like to reach me

WhatsApp

+880 1723 741224

Email

mejba.13@gmail.com

✓ Details sent! I'll get back to you shortly.

Powered by OpenAI

335+

Blog Posts

25

AI Courses

63

Projects

Services & Expertise

Pricing & Process

Learning & Resources

Connect & Support