Screen Architecture
One command, eleven files, one architecture — MVI, every time, for every feature.
One command, eleven files, one architecture always
This kit generates exactly one architecture — MVI — every time, for every feature, with zero exceptions. There's no "assisted" mode to fall back to for a different shape. A screen has exactly one way in (a UiEvent) and one way out (a StateFlow<UiState>); a Composable never calls a ViewModel function directly.
Composable UI
│ UiEvent
▼
ViewModel ── StateFlow<UiState> flows back up
│ calls
▼
UseCase (pure Kotlin)
│
▼
Repository (interface + impl)
│ │
▼ ▼
Remote Local (aspirational — no Room yet)
./scripts/new_feature.sh user_settings "email:String,notificationsEnabled:Boolean" produces eleven files:
| File | Its job |
|---|---|
domain/model/UserSettings | The data type |
domain/repository/UserSettingsRepository | The interface a ViewModel depends on — not the real thing |
domain/usecase/GetUserSettingsUseCase | One operation, pure Kotlin, no Android/Hilt/Retrofit imports |
data/remote/UserSettingsApiService | The Retrofit interface |
data/remote/UserSettingsApiModule | Hilt module providing that service from the shared Retrofit instance |
data/repository/UserSettingsRepositoryImpl | The one real implementation |
data/repository/UserSettingsModule | Hilt binding: interface → impl |
presentation/UserSettingsUiState | The UiState data class and the UiEvent sealed interface, together |
presentation/UserSettingsViewModel | onEvent() dispatch, StateFlow<UiState> out |
presentation/UserSettingsScreen | Stateless Screen + a thin Route, two @Previews, error-retry wired back through the same onEvent |
UserSettingsViewModelTest | Three real, passing tests: success, failure, and retry-after-failure recovers |
The dispatch shape it generates every time, concretely:
sealed interface UserSettingsUiEvent {
data object Load : UserSettingsUiEvent
}
fun onEvent(event: UserSettingsUiEvent) {
when (event) {
is UserSettingsUiEvent.Load -> load()
}
}
private fun load() {
viewModelScope.launch {
_uiState.value = _uiState.value.copy(isLoading = true, error = null)
getUserSettingsUseCase()
.onSuccess { result -> _uiState.value = _uiState.value.copy(isLoading = false, userSettings = result) }
.onFailure { throwable -> _uiState.value = _uiState.value.copy(isLoading = false, error = throwable.message) }
}
}
Every combination here is templated. There's no fixed-template-vs-assisted split, because there's only one pattern. Every field type gets a sensible fake value in the generated test (String → "test", a nullable type → null); an unrecognized custom type still compiles — via TODO(), a Nothing that type-checks against anything — but fails loudly at test runtime until you fill in a real value, never silently wrong.