android-compose-architect
Architect-level Android design with Jetpack Compose — unidirectional state, ViewModel and state holders, process death and saved state, Navigation Compose, coroutines and Flow, and the platform integration points that decide app quality. Use when building or restructuring an Android app.
- License 许可
- MIT
- 最近更新
- 2026-11-13
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- android-compose-architect
- license
- MIT
- metadata
- { "crusor-path": "mobile-architect/platforms-architect/android-compose-architect", "crusor-domain": "mobile-architect", "crusor-origin": "original", "crusor-sources": "developer.android.com/develop/ui/compose; developer.android.com/topic/architecture; developer.android.com/kotlin/coroutines", "crusor-triggers": "jetpack compose, composable, viewmodel, android app, kotlin coroutines, stateflow, navigation compose, process death, hilt", "crusor-verified-on": "2026-10-30" }
- description
- Architect-level Android design with Jetpack Compose — unidirectional state, ViewModel and state holders, process death and saved state, Navigation Compose, coroutines and Flow, and the platform integration points that decide app quality. Use when building or restructuring an Android app.
- compatibility
- Android 8+, Jetpack Compose, Kotlin coroutines, Hilt, Room
03 SKILL.md 正文
Android / Compose Architect
Compose is a function of state, recomposed on change. The architecture is where that state lives, who survives process death, and where the effects run.
When to use
- New Android app, or a Views-to-Compose migration.
- Recomposition, state, or lifecycle bugs.
- Structuring modules and dependency injection.
When NOT to use
- Cross-platform UI work →
react-native-architect/flutter-architect. - The issue is a backend contract or authentication flow.
Decision 1 — State and events
- Unidirectional: UI emits events up, state flows down. No composable mutates a shared model directly.
ViewModelexposes one immutableUiStateviaStateFlow; the screen collects with lifecycle awareness (collectAsStateWithLifecycle).- Model states as explicit types:
Loading | Content | Empty | Error, not three booleans. - Hoist state only as high as needed; local UI state stays in the composable with
rememberSaveable. derivedStateOffor costly derivations; avoid state writes during composition.
Decision 2 — Lifecycle and process death
- Any state the user would notice losing must be in
SavedStateHandleor persisted — Android kills backgrounded processes without warning. - Effects:
LaunchedEffect(key)for suspend work,DisposableEffectfor teardown; never launch work directly in a composable body. - Coroutines in
viewModelScope; cancellation on clear is automatic. - Collect flows with the lifecycle, or background collection leaks and burns battery.
Decision 3 — Navigation
- Navigation Compose with typed routes (serialisable route classes), single
NavHost. - Arguments are validated at the destination; a bad deep link must not crash.
- Back behaviour defined for nested flows and bottom sheets.
- Shared element and multi-pane (window size classes) designed, not discovered on tablets.
Decision 4 — Structure and injection
app/ wiring, navigation, DI graph
feature/ screen + ViewModel + UI state (one module per feature as it grows)
core/ design system, network, database, analytics
- Hilt (or Koin) from the start; constructor injection into ViewModels and repositories, no service locator reach-ins from composables.
- Interfaces at module boundaries; the repository hides Room/Retrofit from the UI.
- Modules for build speed and ownership, not for purity.
Decision 5 — Platform integration
- Permissions requested in context; handle denial and "don't ask again".
- Background work via WorkManager with constraints and retry policy — not a foreground service for periodic sync.
- Compose previews with fake state for every screen; no preview touching the network.
- Material 3 theming with dynamic colour plus a brand fallback; dark mode from day one.
- Predictive back, per-app language, and large-screen resizability are platform expectations, not extras.
Decision 6 — Quality bar
- Unit tests for ViewModels (coroutine test dispatcher), Compose UI tests for core flows, macrobenchmark for startup and list scrolling.
- Baseline profiles for release builds; without them Compose startup is slow.
- R8 with keep rules verified; test the minified build, not just debug.
Failure modes at scale
- Screen state in
rememberand lost on rotation or process death. - Flow collected outside the lifecycle, updating a destroyed screen.
- A composable that calls the repository directly in the body.
- Recomposition storms from unstable parameters (lists, lambdas created inline).
- Debug build is fine, minified release crashes on a missing keep rule.
Verification receipts
- UiState type per screen with all four states handled.
- Process-death test: kill from background, state restored.
- Macrobenchmark numbers for startup and the heaviest list.
- Release (minified) build exercised through core flows.
- Compose previews and tests covering loading, empty and error.
04 同仓库更多 Skills
interaction-patterns-architect
Architect-level interaction design in code — choosing established patterns over invented ones, feedback and latency behaviour, destructive-action safeguards, navigation and overlay conventions, and the state model behind every interactive surface. Use when a screen has to behave, not just look.
design-system-ops-architect
Architect-level operation of a design system in code — token pipelines and versioning, component API and variant policy, the catalogue as the contract, adoption metrics, and the governance that stops a system from forking into three. Use when a component library must survive several teams.
design-handoff-architect
Architect-level design handoff — what must be specified before implementation starts, tokens over raw values, responsive and content-limit contracts, state matrices, and the review loop that catches drift between design and code. Use when a design is about to become code.
content-microcopy-architect
Architect-level UI content — where strings live, voice and terminology consistency, error and empty-state copy as part of the interface, translation-ready authoring, and the content model a product needs before it multiplies screens. Use when the words in the interface matter as much as the pixels.
ui-ux-implementation-architect
Architect-level direction for turning a design into working UI — the handoff contract, component ownership versus screen-level layout, interaction and state conventions, design QA gates, and the review habits that keep an implementation faithful without frozen pixels. Use before any specific UI implementation skill.
test-strategy-architect
Architect-level test strategy — allocating assertions across unit, integration, contract and end-to-end layers, designing for testability through dependency boundaries, fixture and data strategy, and the flake and coverage policies that keep a suite trustworthy. Use when defining how a codebase is tested.