Restaurants App is a modern Android application designed to explore and manage a list of restaurants. The project follows Android development best practices, applying Clean Architecture, Dagger Hilt, Jetpack Compose, and a reactive, locally cached data strategy.
- Local Caching: Restaurant data fetched from Firebase is persisted in Room, which provides the local data source used by the UI.
- Paginated Restaurant List: Paging 3 loads restaurants from Room and exposes refresh, append, retry, loading, and error states to the Compose UI.
- Details and Deep Links: Restaurant details are loaded from Room through the repository and a dedicated use case. Specific restaurants can also be opened directly via URL (e.g.,
https://www.restaurantsapp.details.com/2). - Favorites Management: Ability to mark restaurants as favorites with state persistence across app restarts.
- Lifecycle-Aware State: ViewModels expose immutable
StateFlowstate, collected in Compose withcollectAsStateWithLifecycle(). - Automated Testing: Compose UI, ViewModel, use case, and repository behavior is verified with focused tests and custom fakes.
- UI: Jetpack Compose for a modern, declarative UI.
- Dependency Injection: Dagger Hilt with KSP for compile-time dependency injection.
- Networking: Retrofit 3.0 with GSON Converter for Firebase Realtime Database integration.
- Local Database: Room for robust local persistence and offline support.
- Concurrency: Kotlin Coroutines & Flow for non-blocking asynchronous operations.
- Pagination: Paging 3 with Room-backed
PagingSourceintegration. - Navigation: Navigation Compose with
hiltViewModel()integration and deep link support. - Testing: JUnit 4, Kotlinx Coroutines Test (
runTest,StandardTestDispatcher, and a customMainDispatcherRule), Compose UI Test JUnit4, and custom fakes. - Dependency Management: Gradle Version Catalog (
libs.versions.toml) for centralized library management.
The app follows Clean Architecture principles combined with MVVM and Unidirectional Data Flow (UDF), organized in a package-by-feature structure:
-
Presentation Layer:
- View: Declarative UI screens built with Compose, decoupled from ViewModels for testability and Preview support.
- ViewModel: Coordinates use cases and exposes immutable UI state using the Backing Property pattern (
MutableStateFlowinternally andStateFlowpublicly). Compose collects this state in a lifecycle-aware manner.
-
Domain Layer:
- Use Cases: Represent focused application operations (
GetInitialRestaurantsUseCase,GetPagedRestaurantsUseCase,GetRestaurantByIdUseCase, andToggleRestaurantUseCase). - Domain Model: Pure Kotlin model (
Restaurant) representing app domain logic.
- Use Cases: Represent focused application operations (
-
Data Layer:
- Repository Pattern:
RestaurantsRepositorycoordinates remote network calls through Retrofit and local persistence through Room while keeping data-source details out of the presentation layer. - Model Separation: Clean mapping between Remote DTOs (
RemoteRestaurant), Room Local Entities (LocalRestaurant), and Domain Models (Restaurant).
- Repository Pattern:
- UI Tests (
androidTest):RestaurantsScreenTestverifies initial loading states, content rendering, error states, and semantics descriptions. - ViewModel Tests (
test):RestaurantsViewModelTestverifies initial loading, success, failure, and retry behavior.RestaurantDetailsViewModelTestcovers successful loading, unknown restaurant IDs, and missing navigation arguments. - Coroutine Testing:
MainDispatcherRulereplacesDispatchers.Mainduring local JVM tests, whilerunTestandStandardTestDispatcherprovide deterministic coroutine execution. - Domain Tests (
test): Focused use case tests verify restaurant and favorite-related behavior. - Data Tests (
test):RestaurantsRepositoryTestverifies repository behavior and persisted favorite updates usingFakeApiServiceandFakeRoomDao.
Project created for educational purposes to explore modern Android development.