Part of PatternKit, a side-by-side reference codebase where the same small Tasks CRUD app is implemented once per architecture pattern across iOS and Android. Every module ships identical behaviour — the same domain model, the same three screens, the same mock data layer — so the only thing that varies is the architecture itself.
This module is the MVVM + Clean Architecture flavour on Jetpack Compose — the production sweet spot Google demonstrates in Now in Android. It interposes a domain layer of use cases between the ViewModels and the repository: ViewModels depend on use cases, use cases depend on the repository contract, and the data layer is the only place that knows about the concrete implementation.
- Language: Kotlin
- UI: Jetpack Compose + Material 3
- Architecture: MVVM + Clean (Data / Domain / UI layers)
- DI: Dagger 2 (KSP) — plain Dagger, no Hilt
- Navigation: Navigation Compose
- Min SDK: 28 · Target/Compile SDK: 36
- Package:
com.preetanshumishra.patternkit.android.mvvmcleancompose
A single-user task list. One entity (TaskItem: title, optional notes, optional due date, priority, completion). Three screens:
- List — filter chips (All / Active / Completed), sort by due date or priority, swipe-to-delete, FAB to create.
- Detail — read-only fields, toggle completion, edit, delete.
- Form — create or edit (mode-driven), title validation (≤ 80 chars), due-date validation (not in the past), 600 ms mock async save.
Data comes from MockTaskRepository — an in-memory store seeded with ~12 tasks, with configurable artificial latency and failure rate. No real network, no local persistence — intentionally, so the architecture stays the focus.
Five single-responsibility use cases sit between the UI and the data layer:
GetTasksUseCase,CreateTaskUseCase,UpdateTaskUseCase,DeleteTaskUseCase,ToggleTaskCompletionUseCase
Each is @Inject constructor-built and depends only on the TaskRepository contract (which lives in domain/, not data/). ViewModels never touch the repository directly — they compose use cases. This is the one structural difference from the plain-MVVM module.
Plain Dagger 2, wired by hand:
AppComponent(@Singleton) exposes the five use cases;RepositoryModule@BindsTaskRepository→MockTaskRepository.- Use cases and the repository are constructor-injected, so Dagger builds them with no
@Providesboilerplate. PatternKitAppcreates and holds the component; a hand-rolledViewModelFactorypulls use cases out of the graph and constructs each ViewModel.
app/src/main/kotlin/.../mvvmclean/
├── data/ # MockTaskRepository, seed data
├── domain/ # TaskItem, Priority, TaskRepository (contract), UseCases
├── di/ # AppComponent, RepositoryModule
├── ui/
│ ├── list/ # TaskListScreen + TaskListViewModel
│ ├── detail/ # TaskDetailScreen
│ ├── form/ # TaskFormScreen + TaskFormViewModel
│ ├── nav/ # NavHost + Routes
│ ├── theme/ # Material 3 theme
│ └── ViewModelFactory.kt
└── PatternKitApp.kt
./gradlew assembleDebug # build the debug APK
./gradlew installDebug # install on a connected device/emulator
./gradlew test # unit testsOr open the project in Android Studio and run the app configuration.