home / skills / pluginagentmarketplace / custom-plugin-android / architecture
This skill helps implement MVVM, Clean Architecture, and SOLID principles in Android apps using repository and dependency injection for robust, testable code.
npx playbooks add skill pluginagentmarketplace/custom-plugin-android --skill architectureReview the files below or copy the command above to add this skill to your agents.
---
name: architecture
description: MVVM pattern, Clean Architecture, Repository pattern, dependency injection, SOLID principles.
version: "2.0.0"
sasmp_version: "1.3.0"
# Agent Binding
bonded_agent: 06-architecture
bond_type: PRIMARY_BOND
# Skill Configuration
atomic: true
single_responsibility: App architecture & design patterns
# Parameter Validation
parameters:
pattern:
type: string
enum: [mvvm, clean_architecture, repository, di]
required: false
complexity:
type: string
enum: [simple, medium, complex]
default: medium
# Retry Configuration
retry:
max_attempts: 2
backoff: exponential
on_failure: suggest_simpler_pattern
# Observability
logging:
level: info
include: [pattern_type, layer, dependencies]
---
# App Architecture Skill
## Quick Start
### MVVM Pattern
```kotlin
@HiltViewModel
class UserViewModel @Inject constructor(
private val repository: UserRepository
) : ViewModel() {
private val _state = MutableLiveData<UiState>()
val state: LiveData<UiState> = _state
fun loadUser(id: Int) {
viewModelScope.launch {
_state.value = repository.getUser(id)
}
}
}
```
### Repository Pattern
```kotlin
interface UserRepository {
suspend fun getUser(id: Int): User
}
class UserRepositoryImpl(
private val dao: UserDao,
private val api: UserApi
) : UserRepository {
override suspend fun getUser(id: Int): User {
return dao.getUser(id) ?: api.fetchUser(id)
}
}
```
### Dependency Injection (Hilt)
```kotlin
@Module
@InstallIn(SingletonComponent::class)
object RepositoryModule {
@Provides
fun provideUserRepository(dao: UserDao, api: UserApi): UserRepository {
return UserRepositoryImpl(dao, api)
}
}
```
## Key Concepts
### MVVM Benefits
- Lifecycle awareness
- Configuration change handling
- Separation of concerns
- Testability
### Clean Architecture Layers
- Domain: Business rules
- Application: Use cases
- Presentation: UI
- Infrastructure: Data sources
### SOLID Principles
- S: Single Responsibility
- O: Open/Closed
- L: Liskov Substitution
- I: Interface Segregation
- D: Dependency Inversion
## Best Practices
✅ Dependency injection
✅ Interface-based design
✅ Layered architecture
✅ Single responsibility
✅ Testable code
## Resources
- [Architecture Guide](https://developer.android.com/jetpack/guide)
- [SOLID Principles](https://en.wikipedia.org/wiki/SOLID)
- [Hilt Documentation](https://developer.android.com/training/dependency-injection/hilt-android)
This skill provides concise guidance and examples for building Android apps using MVVM, Clean Architecture, the Repository pattern, dependency injection, and SOLID principles. It focuses on practical code patterns, module boundaries, and testable abstractions to help teams scale and maintain projects. The content is oriented toward Android developers integrating these patterns with Kotlin and DI frameworks like Hilt.
The skill inspects typical architectural layers and shows how to organize responsibilities across domain, application, presentation, and infrastructure. It demonstrates wiring repositories to ViewModels, defining interfaces for data sources, and providing DI modules to assemble implementations. Example snippets illustrate coroutine usage in ViewModelScope, repository fallbacks between local DAO and remote API, and Hilt provider modules.
How do I choose what goes in domain vs application layers?
Keep pure business rules and entities in domain; put orchestration and app-specific use-cases in the application layer that call domain logic and coordinate repositories.
When should I create a repository interface?
Create an interface when you need to decouple data access from callers, support multiple data sources, or enable test doubles. If data access is trivial and unlikely to change, a direct DAO may suffice.