Android
AuraScore 79/100

Jetpack Compose Multimodal Sketch to Generative Asset Pipeline

Construct a reactive Jetpack Compose and coroutine pipeline for interactive sketch-to-image multimodal generation.

Implement this template when building reactive user interfaces in Android that turn real-time user sketches and text prompts into generated visual assets. It ensures efficient rendering, progressive decoding, and memory caching.

Template

Role: Lead Android UI/UX & Generative Media Architect

Context

  • Compose drawing canvas mutable state handle: {{compose_canvas_state}}
  • Multimodal visual style conditioning weights: {{style_preset_vector}}
  • Generated bitmap dimension aspect ratio: {{target_aspect_ratio}}
  • Remote or local diffusion service endpoint: {{diffusion_api_endpoint}}
  • Frame interval for progressive preview updates: {{progressive_render_chunk_ms}}
  • Memory and disk cache retention policy: {{cache_eviction_strategy}}

Task

Build a resilient Jetpack Compose orchestration script and StateFlow pipeline that extracts user sketch paths, combines them with multimodal text prompts, streams progressive generation previews, and caches rendered visual outputs.

Method

  1. Capture vector path primitives from {{compose_canvas_state}} and rasterize them into an in-memory alpha mask bitmap.
  2. Combine rasterized sketch data with text input and {{style_preset_vector}} into a multipart multimodal payload.
  3. Calculate canvas dimensions satisfying {{target_aspect_ratio}} while enforcing 64-pixel alignment constraints.
  4. Initiate an asynchronous streaming RPC/WebSocket session with {{diffusion_api_endpoint}} using Ktor Client.
  5. Consume incoming chunked byte streams every {{progressive_render_chunk_ms}} to reconstruct intermediate JPEG latents.
  6. Render intermediate previews smoothly in Compose using ImageBitmap with non-blocking hardware bitmap decoders.
  7. Store finalized high-resolution bitmaps according to {{cache_eviction_strategy}} using Okio and Android LRU cache.
  8. Expose an immutable GenerationUiState StateFlow providing progress percentage, thermal warnings, and error fallbacks.

Constraints

  • The composable pipeline MUST NOT trigger recomposition outside the dedicated canvas preview container during streaming.
  • Network image streaming MUST handle connection drops with exponential backoff and resume from the latest seed step.
  • Ensure all Bitmap allocations are recycled or managed using Android 10+ HardwareBitmap pools.
  • Respect system low-memory trims (onTrimMemory) by clearing memory caches according to {{cache_eviction_strategy}}.

Output format

Provide a cohesive, modular Kotlin Jetpack Compose implementation:

  1. State Management & Model Classes (GenerativeCanvasState.kt)
  2. Compose UI Component (GenerativeCanvasScreen.kt)
  3. Streaming Client & Cache Repository (MultimodalGenerationRepository.kt)

Self-review

  • Are recomposition counts minimized during high-frequency preview streaming?
  • Does the repository gracefully handle network timeouts without leaking coroutine scopes?
  • Is the sketch rasterization optimized to run on IO or Default dispatchers?
AuraScore breakdown
79/100Provisional
Instruction clarity15/15 · Strong

Explicit role, a named task, and discrete steps the model can follow.

Context architecture12/12 · Strong

Background, inputs and variables the model needs before it starts.

Constraint engineering8/12 · Adequate

Hard boundaries — what the model must and must not do.

Output specification6/14 · Thin

A named, field-level shape for the response.

Reasoning structure10/10 · Strong

Ordered work items that force analysis before an answer.

Model compatibility10/10 · Strong

Length and structure that travel across frontier models.

Token efficiency5/10 · Thin

Signal density — instruction weight without padding.

Reusability7/7 · Strong

Documented variables so the scaffold adapts to new inputs.

Robustness5/5 · Strong

Quality bar, assumptions and behaviour when inputs are thin.

Observed performance1/5 · Thin

How much real usage the template has behind it.

developers
developers-android
image-multimodal-prompting
android
jetpack-compose
image-generation