android-clean-architecture
Learn to organize Android and KMP projects using Clean Architecture principles, including module boundaries, dependency inversion, and layered data flow. Covers UseCase and Repository patterns, database integration with Room and SQLDelight, network clients with Ktor, and dependency injection setup with Koin or Hilt.
Android Clean Architecture provides patterns for structuring Android and KMP projects with layered modules and clean dependency rules.
AI-generated summary based on this skill's SKILL.md
Install
affaan-m/ECC/android-clean-architecture · repository language: JavaScript
git clone https://github.com/affaan-m/ECC
cp -r ECC/skills/android-clean-architecture ~/.claude/skills/android-clean-architectureFrequently asked questions
AI-generated answers based on this skill's SKILL.md and metadata
What are the main layers in android-clean-architecture?
android-clean-architecture organizes projects into three core layers: Domain (business logic and UseCases), Data (repositories, data sources, and database/network clients), and Presentation (UI, ViewModels, and state management). Each layer has clear responsibilities and communicates through well-defined interfaces, ensuring testability and maintainability.
How do you organize android modules in a clean architecture project?
android-clean-architecture recommends organizing modules by feature or layer. Feature modules contain domain, data, and presentation submodules; layer modules separate concerns vertically. Use gradle convention plugins to enforce dependency rules—presentation depends on domain, data depends on domain, and neither domain nor data depend upward. This prevents circular dependencies and maintains architectural integrity.
What is the usecase repository pattern android approach?
android-clean-architecture implements UseCases as single-responsibility classes that orchestrate business logic by calling repositories. Repositories abstract data sources (local/remote) behind a clean interface. UseCases are invoked from ViewModels or presenters, often using Kotlin Flow or coroutines. This pattern isolates business rules from framework details and makes testing straightforward.
How does android-clean-architecture handle dependency injection?
android-clean-architecture supports both Koin and Hilt for dependency injection. Koin uses module declarations to wire repositories, UseCases, and ViewModels; Hilt uses annotations like @HiltViewModel and @Inject. Both approaches decouple object creation from usage, enable easy testing with mock implementations, and centralize configuration for cleaner code.
How do you integrate Room and SQLDelight in clean architecture?
android-clean-architecture places database setup in the Data layer. Room and SQLDelight implementations are wrapped in repository classes that expose domain models, not database entities. Use mappers to convert between database and domain types. This keeps persistence details isolated and allows swapping database technologies without affecting business logic or UI layers.
What role does Ktor play in android-clean-architecture projects?
android-clean-architecture uses Ktor as a network client in the Data layer. Create a dedicated data source class that handles HTTP requests and response parsing. Repositories call this data source and map responses to domain models. Ktor's multiplatform support makes it ideal for KMP projects, keeping network logic testable and separate from domain and presentation concerns.
SKILL.md
rendered from the published skill — quoted content, verbatim
Android Clean Architecture
Clean Architecture patterns for Android and KMP projects. Covers module boundaries, dependency inversion, UseCase/Repository patterns, and data layer design with Room, SQLDelight, and Ktor.
When to Activate
- Structuring Android or KMP project modules
- Implementing UseCases, Repositories, or DataSources
- Designing data flow between layers (domain, data, presentation)
- Setting up dependency injection with Koin or Hilt
- Working with Room, SQLDelight, or Ktor in a layered architecture
Module Structure
Recommended Layout
``` project/ ├── app/ # Android entry point, DI wiring, Application class ├── core/ # Shared utilities, base classes, error types ├── domain/ # UseCases, domain models, repository interfaces (pure Kotlin) ├── data/ # Repository implementations, DataSources, DB, network ├── presentation/ # Screens, ViewModels, UI
(truncated - see the full file via the links below)
Read as markdown · JSON record · Browse the source repository
File tree — 1 file
skills/android-clean-architecture/SKILL.md