How lamprosgk/recipes-sample works
Project Type & Purpose
• The project is an Android application utilizing Clean Architecture and MVI. It is modularized into multiple components promoting separation between data handling, business logic, UI, and cross-cutting concerns.
• Key modules include:
• :data – Manages remote/API services, local Room database, dependency injection (e.g., DataModule, DatabaseModule), and repository implementations.
• :domain – Contains the domain models, business rules, and abstract repository definitions (the contract that data module implements).
• :home – Feature-specific module for the recipes list with its own UI layer and use cases (e.g., GetRecipesUseCase).
• :detail – Feature-specific module for the detailed recipe screen including its own use cases and UI (e.g., AddToFavouritesUseCase, RemoveFromFavouritesUseCase).
• :shared – Provides common MVI base classes (MviIntent, MviModel, MviView, MviViewModel) and shared UI components such as error display handling.
Analyzing the File Structure
• The presence of directories like “app”, “data”, “domain”, “detail”, “home”, and “shared” confirms a modular architecture.
• Each module contains its own AndroidManifest, build configurations, source code (under src/main/java), and test directories. This reinforces the structure prescribed by Clean Architecture where each module is responsible for its own layer or feature.
• The “data” module specifically holds network, local, and repository folders, indicating the implementation of both remote and offline-first (Room database) data sources.
• The “shared” module provides the core MVI components, which will be utilized by the presentation layers within the “home” and “detail” feature modules.
a. Main Components:
• Application Bootstrap (App Module): Acts as the entry point including application class (RecipesApplication.kt) and the Android manifest.
• Data Layer (Data Module): Further divided into:
▪ Remote Data Source (e.g., RecipesService, RecipesRemoteDataSource)
▪ Local Data Source (e.g., RecipeDao, RecipesLocalDataSource, RecipesDatabase)
▪ Repository Implementation (e.g., RecipesRepositoryImpl)
▪ Network configuration (NetworkConfig, NetworkModule)
• Domain Layer (Domain Module):
▪ Domain Models (e.g., Recipe)
▪ Abstract Repository Interface (e.g., RecipesRepository)
▪ Business Logic encapsulated within use cases.
• Feature Modules:
▪ Home Module: UI for recipes list; contains use cases like GetRecipesUseCase and ViewModel classes.
▪ Detail Module: UI for recipe details; contains use cases for adding/removing favorites and corresponding ViewModels, navigation, and screen classes.
• Presentation Support (Shared Module):
▪ Contains MVI base interfaces/classes that guide the flow of intents, state models, and views.
▪ Provides common UI components for error handling and other shared concerns.
b. Relationships and Data Flow:
• UI Components in Home and Detail modules communicate with their respective ViewModels adopting the MVI pattern (utilizing MVI classes from the shared module).
• ViewModels dispatch intents and receive updated state (MVI model) from the associated use cases.
• Use cases in Home and Detail interact with the Domain layer’s repository interfaces.
• The Domain layer’s repository interfaces are then implemented in the Data module, which fetches data from the remote API or local Room database (offline-first approach).
• Dependencies such as network calls, database operations, and dependency injection modules (in Data and possibly Domain) are clearly delineated.
c. Architectural Patterns & Design Principles:
• Clean Architecture separates concerns among data, domain, and presentation.
• MVI ensures unidirectional data flow: User Intent → ViewModel → State → UI.
• Modularization improves decoupling, testability, and independent deployment of features.
• Offline-first with Room ensures the app functions without constant network connectivity.
d. Relevant Technologies & Frameworks:
• Android (with an emphasis on Kotlin for implementation).
• Room database for offline storage.
• Retrofit or other networking libraries (implied by remote service implementation).
• Dependency Injection via modules in the Data and possibly Domain layers.
• MVI architecture patterns supported by the shared module’s base classes.