android-clean-architecture
यह क्या करती है
यह skill Android apps और दूसरे platforms के लिए code को व्यवस्थित करने में मदद करती है। यह तय करती है कि program के अलग-अलग हिस्से आपस में कैसे बात करें, ताकि code समझने और संभालने में आसान रहे।
कब इस्तेमाल करें
- ✓कोई नया Android project शुरू करते समय।
- ✓किसी मौजूदा app के अलग-अलग हिस्सों को व्यवस्थित करते समय।
- ✓जब app का code उलझने लगे।
Skill का लिंक
https://github.com/affaan-m/ECC/blob/main/pi/core/skills/android-clean-architecture/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“मैं अपने Android code को Clean Architecture से कैसे व्यवस्थित करूँ?”
हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।
यह कैसे काम करती है
यह code को तार्किक layers में बाँटती है, जैसे 'domain' (business rules) और 'data' (जहाँ जानकारी सेव होती है)। नियम यह पक्का करते हैं कि domain layer कभी दूसरी layers पर निर्भर न रहे, ताकि वह साफ-सुथरा बना रहे।
तकनीकी सामग्री (मूल SKILL.md)
लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।
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 models, navigation
├── design-system/ # Reusable Compose components, theme, typography
└── feature/ # Feature modules (optional, for larger projects)
├── auth/
├── settings/
└── profile/
Dependency Rules
app → presentation, domain, data, core
presentation → domain, design-system, core
data → domain, core
domain → core (or no dependencies)
core → (nothing)
Critical: domain must NEVER depend on data, presentation, or any framework. It contains pure Kotlin only.
Domain Layer
UseCase Pattern
Each UseCase represents one business operation. Use operator fun invoke for clean call sites:
class GetItemsByCategoryUseCase(
private val repository: ItemRepository
) {
suspend operator fun invoke(category: String): Result<List<Item>> {
return repository.getItemsByCategory(category)
}
}
// Flow-based UseCase for reactive streams
class ObserveUserProgressUseCase(
private val repository: UserRepository
) {
operator fun invoke(userId: String): Flow<UserProgress> {
return repository.observeProgress(userId)
}
}
Domain Models
Domain models are plain Kotlin data classes — no framework annotations:
data class Item(
val id: String,
val title: String,
val description: String,
val tags: List<String>,
val status: Status,
val category: String
)
enum class Status { DRAFT, ACTIVE, ARCHIVED }
Repository Interfaces
Defined in domain, implemented in data:
interface ItemRepository {
suspend fun getItemsByCategory(category: String): Result<List<Item>>
suspend fun saveItem(item: Item): Result<Unit>
fun observeItems(): Flow<List<Item>>
}
Data Layer
Repository Implementation
Coordinates between local and remote data sources:
class ItemRepositoryImpl(
private val localDataSource: ItemLocalDataSource,
private val remoteDataSource: ItemRemoteDataSource
) : ItemRepository {
override suspend fun getItemsByCategory(category: String): Result<List<Item>> {
return runCatching {
val remote = remoteDataSource.fetchItems(category)
localDataSource.insertItems(remote.map { it.toEntity() })
localDataSource.getItemsByCategory(category).map { it.toDomain() }
}
}
override suspend fun saveItem(item: Item): Result<Unit> {
return runCatching {
localDataSource.insertItems(listOf(item.toEntity()))
}
}
override fun observeItems(): Flow<List<Item>> {
return localDataSource.observeAll().map { entities ->
entities.map { it.toDomain() }
}
}
}
Mapper Pattern
Keep mappers as extension functions near the data models:
// In data layer
fun ItemEntity.toDomain() = Item(
id = id,
title = title,
description = description,
tags = tags.split("|"),
status = Status.valueOf(status),
category = category
)
fun ItemDto.toEntity() = ItemEntity(
id = id,
title = title,
description = description,
tags = tags.joinToString("|"),
status = status,
category = category
)
Room Database (Android)
@Entity(tableName = "items")
data class ItemEntity(
@PrimaryKey val id: String,
val title: String,
val description: String,
val tags: String,
val status: String,
val category: String
)
@Dao
interface ItemDao {
@Query("SELECT * FROM items WHERE category = :category")
…
अक्सर पूछे जाने वाले सवाल
'domain' क्या है?
यह code का वह हिस्सा है जिसमें app के मुख्य नियम होते हैं, बिना इस चिंता के कि डेटा कहाँ सेव होगा।
'Use Case' क्या है?
यह app का एक खास काम है, जैसे 'items लाना' या 'user सेव करना'।
'domain' 'data' पर निर्भर क्यों नहीं हो सकता?
ताकि business rules बिना बदलाव के अलग-अलग जगह (जैसे Android, web आदि) पर इस्तेमाल हो सकें, और code ज़्यादा व्यवस्थित और testable रहे।
जानकारी
लेखक का मूल विवरण
Clean Architecture patterns for Android and Kotlin Multiplatform projects — module structure, dependency rules, UseCases, Repositories, and data layer patterns. Use when structuring modules, layers, or data flow in an Android or KMP project.
repo: affaan-m/ECC
लोकप्रियता
- GitHub स्टार
- 280k
- रैंकिंग में स्थान
- #135
- लाइसेंस
- MIT
- अपडेट की गई
- 15/10/2026
कमेंट
- …
इस repository की और skills
accessibility
280kयह आपके एजेंट को ऐसे इंटरफ़ेस बनाने में मदद करता है जिन्हें हर कोई इस्तेमाल कर सके। यह पक्का करता है कि वेबसाइट और ऐप दिव्यांग लोगों के लिए भी अच्छे से काम करें, जैसे नेत्रहीन या जिन्हें चलने-फिरने में दिक्कत होती है।
agent-architecture-audit
280kयह आपके एजेंट को जाँचने देता है कि सब कुछ सही से चल रहा है। यह AI सिस्टम में समस्याएँ ढूँढकर ठीक करता है, ताकि वे उम्मीद के मुताबिक काम करें।
agent-eval
280kयह आपके एजेंट को अलग-अलग AI coding tools की तुलना करने में मदद करता है। यह मापता है कि किसी खास काम के लिए कौन सा टूल ज़्यादा तेज़, सस्ता और भरोसेमंद है।
agent-harness-construction
280kयह आपके एजेंट को काम कैसे करना है, यह बेहतर समझने में मदद करता है। यह उन tools और instructions को बेहतर बनाता है जिनका एजेंट इस्तेमाल करता है, ताकि उसकी सफलता की संभावना बढ़े।
मिलती-जुलती skills
flutter-animating-apps
101kएजेंट को Flutter ऐप्स में एनिमेटेड इफ़ेक्ट और ट्रांज़िशन जोड़ने देता है। iOS और Android ऐप्स में मोशन और विज़ुअल डिज़ाइन बनाने के लिए यह उपयोगी है।
agent-spec-mobile-react-native
81kआपके एजेंट को React Native से iPhone और Android के लिए मोबाइल ऐप बनाने में मदद करती है, जिसमें screens, navigation और native modules शामिल हैं।
orientation
75kयह आपके एजेंट को सुनिश्चित करने में मदद करती है कि साइट पोर्ट्रेट और लैंडस्केप दोनों में चले, और ओरिएंटेशन लॉक व डिवाइस घुमाने के संदेश हटाए जाएँ।