How ferprieto/spacex-prepare-for-clean-architecture-liftoff works
Main Components
• Presentation Layer: Represented by the "app" module. Here, you have the UI components (screens, navigation components like BottomNavigationScreens, etc.) and view-models (DashboardViewModel, LaunchesViewModel, etc.) that follow the MVVM pattern.
• Domain Layer: Located in the "domain" module. This layer encapsulates business logic, use cases (like GetCompanyInfo and GetLaunches), domain models (such as CompanyInfoDomainModel and LaunchDomainModel), and domain-specific mappers.
• Data Layer: Split into two modules:
• “data”: Contains the repository implementations (e.g., SpaceXRepositoryImpl), data models, and domain-to-data mappers.
• “data-api”: Manages communication with remote services using Retrofit, remote data sources (e.g., SpaceXRemoteSourceImpl), and response mappers.
• Core Modules: “core” (base classes, events, factories) and “core-android-test” (testing utilities), which are used across the project but have strict dependency isolation.
• Testing Components: Unit tests and instrumented tests (using frameworks like Espresso, MockK, and even screenshot testing using Shot).
Relationships and Interactions
• The Presentation Layer interacts with the Domain Layer via use cases to drive business logic. It communicates using view-models that consume domain models.
• The Domain Layer defines the contracts (interfaces) for repository access, which are implemented in the Data Layer.
• The Data Layer handles data sourcing, converting API responses (from data-api) or caching/repository models into domain models via mappers.
• Dependency injection (via Dagger Hilt or Dagger2) ties the components together, wiring up dependencies between the Presentation, Domain, and Data layers.
Architectural Patterns and Technologies
• MVVM Pattern: In the app module, the separation of screens (View) and view-models (logic) should be depicted.
• Dependency Injection: Show that components across layers are provided via DI (Dagger Hilt/Dagger2) and indicate the DI modules (like ActivityScope, ViewModelsModule, PresentationModule, and the modules under data-api and data).
• Use of Kotlin Coroutines and Flows: Indicate asynchronous data flows between layers.