This is a sample Android application that demonstrates the principles of Clean Architecture. The app follows a modular approach to ensure separation of concerns, maintainability, and scalability.
The Clean Architecture pattern helps to create Android applications that are easy to maintain, test, and scale. It follows a structured approach where:
- Business logic is separated from UI and data handling.
- Dependencies flow inwards, meaning that external libraries and data sources are isolated from core logic.
- The app uses MVVM (Model-View-ViewModel) architecture with Jetpack Compose for UI components.
In this project, we implement Clean Architecture with multiple layers:
- Presentation Layer (UI)
- Domain Layer (Business logic)
- Data Layer (API and database)
This project follows Clean Architecture, which consists of the following layers:
-
Presentation Layer:
- Handles UI-related logic and interacts with ViewModel.
- UI is built using Jetpack Compose.
-
Domain Layer:
- Contains business logic, UseCases, and repository interfaces.
- Manages the flow of data between the presentation layer and data layer.
-
Data Layer:
- Responsible for data fetching and management.
- Uses Retrofit for networking and Room for local data storage (if applicable).
- Handles API calls and data manipulation.
The dependencies flow inwards:
- The presentation layer depends on the domain layer, but not vice versa.
- The domain layer depends on the data layer but not vice versa.
- Kotlin: Programming language used for Android development.
- Jetpack Compose: Modern UI toolkit for building native UIs.
- Clean Architecture: Structured app design for better maintainability and testability.
- ViewModel: Manages UI-related data lifecycle-consciously.
- LiveData / StateFlow: For handling UI-related state changes.
- Retrofit: A type-safe HTTP client for making API calls.
- Coil : An image loading library for Android and Compose Multiplatform.
- Kotlin Coroutines: For asynchronous operations and handling background tasks.
- Hilt: Dependency injection library (if used for managing dependencies).
To get started with this project locally, follow these steps:
- Android Studio (latest version)
- JDK 11 or higher
-
Clone the repository:
git clone https://github.com/javaman97/CleanArchitecture.git
-
Open the project in Android Studio.
-
Wait for the dependencies to be synced.
-
Run the app on an emulator or a physical device.
Once the app is up and running, you can:
- Search for GitHub users and view their repositories.
- The app will display user details, including the name, description, and number of stars of each repository.
- Error handling is implemented for invalid usernames or network failures.
- Loading states are shown while fetching data from the API.
The app follows modern Android development practices such as MVVM, StateFlow, Kotlin Coroutines, and Jetpack Compose.
Contributions are welcome! If you want to improve or extend this project, follow these steps:
- Fork the repository.
- Create a new branch (
git checkout -b feature/your-feature
). - Make your changes.
- Commit your changes (
git commit -am 'Add new feature'
). - Push to the branch (
git push origin feature/your-feature
). - Create a new Pull Request.
- Follow the standard Kotlin coding conventions.
- Ensure code is well-documented and easy to read.
This project is licensed under the MIT License - see the LICENSE file for details.
Feel free to modify the README as needed, depending on the specific features and technologies you’ve used in your project!