This is a modern sample project that demonstrates how to build scalable and maintainable Android applications by leveraging Jetpack Compose and Kotlin's latest features. It integrates Compose with the MVI architecture and highlights the use of key Android tools like Kotlin Flow, Hilt for dependency injection, and Room for local data caching.
-
UI Components
- Built entirely with Jetpack Compose, Android's native declarative UI toolkit.
- Styled with Material Design guidelines for consistent and engaging user interfaces.
-
Technologies
- Kotlin used across the project, ensuring concise and expressive code.
- Asynchronous data handling with Coroutines and Flow.
- Hilt for streamlined dependency injection.
- Retrofit for network calls.
- Image loading with Coil.
- Room for efficient local database caching and offline-first functionality.
- Paging 3 for handling large data sets.
-
Unit tests.
-
UI compose tests.
-
Architecture
- Single Activity design utilizing Jetpack Navigation.
- MVI (Model-View-Intent) architecture for unidirectional data flow and clear separation of concerns.
- Android Architecture Components (ViewModel, LiveData) to handle state and lifecycle-aware components.
- KTX Extensions for simplified Kotlin code in Jetpack.
-
Caching
- Integrated Room database for offline-first functionality and persistent data storage.
- Fetches and caches data locally from the Room database, reducing unnecessary network calls.
-
Real-Time Updates
- Fetches new data from the remote service every 2 minutes.
- Compares the new data with the current news list and sends notifications to the user about the number of new articles added.
The app follows the MVI architectural pattern, separating concerns into distinct layers for better maintainability and scalability. Each screen is driven by states, actions, and effects.
Architecture layers:
- View: Compose-based UI that listens for state updates and user events.
- ViewModel: Handles logic, processes user actions, and updates the view state.
- Model: Responsible for fetching and providing data, encapsulating business logic in repositories. Room handles local caching.
- State - A data class representing the UI's state (e.g., loading status, data to display).
- Event - A user-triggered action passed from the UI to the ViewModel (e.g., button clicks).
- Effect - One-off events like navigation actions, displaying a SnackBar, or showing a Toast.
These components work together to implement a clear, unidirectional data flow. The ViewModel mediates between the view and model, ensuring separation of concerns and predictable behavior.