├── .gitignore ├── Android ├── Architecture │ ├── Clean │ │ └── clean_architecture_android.md │ ├── MVC │ │ └── mvc.md │ ├── MVI │ │ └── mvi.md │ ├── MVP │ │ └── mvp.md │ └── MVVM │ │ └── mvvm.md ├── Components │ └── compoents.md ├── Data │ ├── Realm │ │ └── realm.md │ ├── Room │ │ └── room.md │ └── SQLite │ │ └── sqlite.md ├── Dependency Injection │ ├── Dagger │ │ └── dagger.md │ ├── Hilt │ │ └── hild.md │ └── Koin │ │ └── koin.md ├── Gradle │ └── gradle.md ├── Java │ ├── Advanced │ │ └── adcvanced.md │ └── Core │ │ └── core-java.md ├── Jetpack Compose │ └── compose.md ├── Jetpack │ └── jetpack.md ├── Kotlin │ ├── Coroutines │ │ └── coroutines.md │ ├── Flows │ │ └── flows.md │ ├── cheetsheet.md │ └── kotlin.md ├── Libs │ └── libs.md ├── Performance Optimazation │ └── performance.md ├── Playstore │ └── playstore.md ├── RX Java │ └── rx.md ├── UX │ └── ux.md └── Ui │ └── ui.md ├── Assets ├── devcrack.png └── devcrack2.png ├── Backend Basics ├── APIs │ └── apis.md ├── Firebase │ └── firebase.md ├── GraphQL │ └── graph.md └── REST │ └── rest.md ├── CONTRIBUTING.md ├── Cross Platform ├── Flutter │ └── flutter.md ├── KMM │ └── kmm.md └── React Native │ └── react.md ├── Design Patterns └── design.md ├── ISSUE_TEMPLATE.md ├── Interviews └── interview.md ├── License.md ├── PULL_REQUEST_TEMPLATE.md ├── ReadMe.md ├── SECURITY.md ├── System Design for Mobile └── system_design.md ├── Testing ├── Espresso │ └── espresso.md ├── JUnit │ └── junit.md ├── Mockito │ └── mokito.md └── UIAutomator │ └── ui_automater.md ├── Tools ├── CI CD │ ├── ci_cd.md │ └── fatlate.md ├── Charles │ └── charles.md ├── Git │ └── git.md └── Postman │ └── postman.md └── iOS ├── Swift └── swift.md ├── SwiftUI └── swift_ui.md └── UIKit basics └── ui_kit_basics.md /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules/ 3 | *.log 4 | .idea/ 5 | *.iml -------------------------------------------------------------------------------- /Android/Architecture/Clean/clean_architecture_android.md: -------------------------------------------------------------------------------- 1 | # 🧼 Clean Architecture in Android 2 | 3 | ## 📘 Overview 4 | 5 | **Clean Architecture** is a software design pattern introduced by **Robert C. Martin (Uncle Bob)**. It promotes separation of concerns and independence of frameworks, UI, databases, and other external agencies. This makes the application more maintainable, testable, and scalable. 6 | 7 | --- 8 | 9 | ## 🧱 Layered Structure 10 | 11 | ```mermaid 12 | flowchart TD 13 | A[UI Layer] --> B[Presentation Layer] 14 | B --> C[Domain Layer] 15 | C --> D[Data Layer] 16 | D --> E[Framework Layer] 17 | 18 | ``` 19 | 20 | --- 21 | 22 | ## 🧩 Layers Explained 23 | 24 | | Layer | Responsibility | 25 | |---------------|----------------| 26 | | **UI** | Displays data and observes `ViewModel` or `Presenter`. | 27 | | **Presentation** | Handles user actions, communicates with UseCases. ViewModel lives here. | 28 | | **Domain** | Contains business rules. UseCases are defined here. Framework-independent. | 29 | | **Data** | Implements repository interfaces defined in Domain. Talks to network or local DB. | 30 | | **Framework** | Includes actual implementations like Room, Retrofit, Firebase, etc. | 31 | 32 | --- 33 | 34 | ## 📦 Package Structure (Example) 35 | 36 | ``` 37 | com.example.app 38 | ├── presentation 39 | │ └── viewmodel, ui, state 40 | ├── domain 41 | │ └── usecase, model, repository 42 | ├── data 43 | │ └── repository, api, db 44 | ├── di 45 | │ └── modules for Hilt/Koin 46 | └── utils 47 | ``` 48 | 49 | --- 50 | 51 | ## 🔄 Data Flow 52 | 53 | 1. **UI** triggers an action (e.g., button click). 54 | 2. **ViewModel** calls a **UseCase**. 55 | 3. **UseCase** calls a **Repository** interface. 56 | 4. **Repository** is implemented in **Data Layer**. 57 | 5. **Data Source** (API/DB) is called. 58 | 6. Result is passed back to UI via ViewModel state. 59 | 60 | --- 61 | 62 | ## 🔐 Key Principles 63 | 64 | - **Dependency Rule**: Inner layers should never depend on outer layers. 65 | - **Inversion of Control**: Interfaces defined in inner layers and implemented in outer layers. 66 | - **Testability**: Domain and UseCases are easy to test as they are framework-agnostic. 67 | 68 | --- 69 | 70 | ## ✅ Benefits 71 | 72 | - Decoupled and modular architecture 73 | - Easier to test each layer 74 | - High maintainability 75 | - Scales well for large applications 76 | 77 | --- 78 | 79 | ## ⚠️ Challenges 80 | 81 | - May introduce boilerplate 82 | - Learning curve for small teams 83 | - Requires good understanding of abstraction and responsibility segregation 84 | 85 | --- 86 | 87 | ## 📘 Example UseCase 88 | 89 | ```kotlin 90 | class GetUserProfileUseCase(private val repository: UserRepository) { 91 | suspend operator fun invoke(userId: String): UserProfile { 92 | return repository.getUserProfile(userId) 93 | } 94 | } 95 | ``` 96 | 97 | --- 98 | 99 | ## 🧠 Summary 100 | 101 | Clean Architecture enforces **separation of concerns** and makes your app **robust and testable** by following a strict layered structure. It is ideal for large-scale applications and teams working on long-term maintainable Android projects. 102 | 103 | # Comparison: Clean Architecture vs Other Architectures (MVVM, MVP) 104 | 105 | | Aspect | Clean Architecture | MVVM (Model-View-ViewModel) | MVP (Model-View-Presenter) | 106 | |----------------------|-------------------------------------------------|---------------------------------------------------|------------------------------------------------| 107 | | **Main Idea** | Separation of concerns into layers (Domain, Data, Presentation) with clear dependency rules. | Separation of UI (View) and business logic (ViewModel) with LiveData or StateFlow. | Separates View and Presenter, where Presenter handles UI logic and communicates with Model. | 108 | | **Layers** | 1. **Entities (Domain layer)**
2. **Use Cases / Interactors**
3. **Interface Adapters / Presenters**
4. **Framework & Drivers (UI, DB, Network)** | Usually 3 layers:
1. Model
2. View
3. ViewModel | 3 layers:
1. Model
2. View
3. Presenter | 109 | | **Dependency Rule** | Inner layers should never depend on outer layers; dependencies point inward. | View depends on ViewModel; ViewModel depends on Model or Repository. | View depends on Presenter; Presenter depends on Model/Repository. | 110 | | **Testability** | High - business logic is isolated in domain/use case layer. | Moderate to high - ViewModel can be tested separately from View. | Moderate - Presenter can be tested, but View is often harder to isolate. | 111 | | **UI Framework Dependency** | UI frameworks are in the outermost layer; domain and use cases are independent of Android. | ViewModel can contain Android-specific code but often kept Android-agnostic for testability. | Presenter usually contains Android UI logic but aims to be platform-independent. | 112 | | **Code Complexity** | Higher initial complexity due to many layers and interfaces. | Moderate complexity; easier to start with but can grow large. | Moderate complexity but can lead to tight coupling if not careful. | 113 | | **Typical Use Cases** | Large, complex apps where long-term maintenance and testability are important. | Apps with dynamic UI updates and reactive data streams, e.g., using Jetpack libraries. | Apps with simpler UI and logic separation needs, common before MVVM popularity. | 114 | | **Examples in Android** | Using Use Cases + Repositories + Clean separation + Dependency Injection (Hilt/Dagger) | Using Jetpack Compose or XML with ViewModel + LiveData/Flow | Using Activities/Fragments as Views + Presenter classes handling logic | 115 | 116 | --- 117 | 118 | ### Summary 119 | 120 | - **Clean Architecture** focuses on strict layering and separation of concerns with clear rules on dependencies to keep business logic isolated from UI and frameworks. It’s ideal for maintainable, scalable, and testable large apps. 121 | - **MVVM** is simpler, focuses on reactive UI data binding, and fits well with Jetpack Compose and Android Architecture Components. 122 | - **MVP** separates UI and logic but often leads to more boilerplate and can become tightly coupled without careful design. 123 | 124 | --- 125 | 126 | -------------------------------------------------------------------------------- /Android/Architecture/MVC/mvc.md: -------------------------------------------------------------------------------- 1 | # MVC Architecture in Android 2 | 3 | The Model-View-Controller (MVC) architecture is a design pattern commonly used in Android development to organize code in a modular, maintainable, and testable way. 4 | MVC divides an application into three interconnected components: 5 | 6 | ## 1. **Model Layer** 7 | A. This model layer, responsible for managing the business logic and handling network or database API. 8 | B. The Model has no knowledge of the user interface. 9 | C. This component stores the application data. 10 | 1. Data sources (e.g., Room database, SQLite, Firebase, APIs). 11 | 2. Repository classes that handle data operations. 12 | 3. Business logic (e.g., calculations, data transformations). 13 | Example: 14 | A User class or a repository fetching user data from a server. 15 | class TaskRepository { 16 | private val tasks = mutableListOf() 17 | fun addTask(task: Task) { tasks.add(task) } 18 | fun getTasks(): List = tasks 19 | } 20 | 21 | ## 2. **View Layer** 22 | A. Represents the UI layer, responsible for displaying data to the user and capturing user input. 23 | B. In Android this is typically XML layouts, custom Views, ViewGroups, and UI widgets. 24 | C. The View doesn’t handle any complex logic itself. 25 | 1. XML layouts (defining UI components like TextView, RecyclerView). 26 | 2. UI elements in Activities, Fragments, or ViewHolders. 27 | Example: 28 | The View is passive and only displays what the Controller tells it to, without directly interacting with the Model. 29 | An Activity displaying a list of users in a RecyclerView. 30 | 31 | 32 | 33 |