This project is a Kotlin-based application that demonstrates the implementation of a product management system. It uses modern Android development practices, including dependency injection, coroutines, and reactive programming with Flow
. The project is built using Gradle and follows a clean architecture approach.
- Fetch Products from API: Retrieves a list of products from a remote API.
- Local Database Integration: Stores the fetched products in a local database for offline access.
- Reactive Data Flow: Uses Kotlin
Flow
to observe and react to changes in the local database. - Dependency Injection: Implements dependency injection using
@Inject
annotations for better modularity and testability.
- Models: Contains the
Product
data model. - Repository: Defines the
ProductRepository
interface for data operations. - Use Cases: Implements the
FetchProductsUseCase
to handle business logic for fetching products.
- API Integration: Fetches product data from a remote API.
- Local Database: Stores and retrieves product data using a local database.
- Not implemented in the provided code but can include UI components like Activities, Fragments, or Jetpack Compose.
ProductRepository
: Interface defining methods for fetching and storing product data.FetchProductsUseCase
: Use case that handles fetching products from the API and storing them in the local database if the database is empty.
- Kotlin: Primary programming language.
- Coroutines: For asynchronous programming.
- Flow: For reactive data streams.
- Dependency Injection: Using
@Inject
annotations. - Gradle: Build system.
- The
FetchProductsUseCase
is invoked to fetch products. - It first checks the local database for existing products.
- If the database is empty, it fetches products from the API and stores them in the local database.
- The updated product list is then observed via
Flow
.
- Android Studio Meerkat | 2024.3.1 Patch 2 or later.
- Kotlin 1.8 or later.
- Gradle 8.0 or later.
- Clone the repository.
- Open the project in Android Studio.
- Sync the Gradle files.
- Run the application on an emulator or physical device.