1. Dagger Dependency Injection: Component Dependency & Scoped Orchestration
We will implement a Pure Dagger architecture using Component Dependencies to maintain strict module encapsulation and explicit lifecycle control.
1.1 Multi-Module Component Topology
To preserve the "Clean Architecture" boundaries, we avoid Subcomponents and instead use Component Dependencies.
CoreComponent (in :core:data):
- Scope:
@Singleton.
- Exposure: Explicitly exposes
AuthRepository, SessionManager, and Json infrastructure.
- Responsibility: Houses stateless or global-state services.
UserComponent (in :app or :core:data) [NEW]:
- Scope:
@UserScope.
- Dependency:
CoreComponent.
- Lifetime: Created upon successful login; invalidated immediately upon logout.
- Responsibility: Hosts session-sensitive interactors and transient state for flows like Loan Wizards.
FeatureComponents (in :features:*):
- Dependency:
CoreComponent (and UserComponent for authenticated features).
- Responsibility: Provides feature-specific ViewModels via multibinding.
1.2 Scoped Component Management
We will implement a ComponentManager at the :app level to orchestrate the lifecycle of the UserComponent. This ensures that when a user logs out, the entire session-scoped graph is garbage collected, fulfilling fintech requirements for Secure Session Isolation.
1.3 ViewModel Multibinding & Factory
- Implement a
DaggerViewModelFactory in :core:ui that leverages a Map<Class<? extends ViewModel>, Provider<ViewModel>>.
- Use
@IntoMap and @ViewModelKey in feature modules to decouple the UI from the instantiation of business logic.
Phase 1: Environment & Core DI Infrastructure
- Dependency Injection & Firebase Setup: Update
libs.versions.toml with Dagger 2, Firebase BOM, and DataStore dependencies. Apply plugins and dependencies to all module build.gradle.kts files.
- Annotation Definition: Create
@UserScope and @ViewModelKey in :core:domain or :core:ui.
- Core Data Module: Create
CoreModule and CoreComponent in :core:data to provide Json and basic infrastructure.
- ViewModel Factory: Implement
DaggerViewModelFactory in :core:ui.
Phase 3: Feature & App Layer Integration
- Feature Multibinding: Annotate
LoginViewModel and HomeViewModel with @Inject and register them in their respective Dagger modules using @IntoMap.
- UserComponent Orchestration: Implement the
ComponentManager in :app to manage the lifecycle of the @UserScope graph.
- Application & Activity Wiring: Initialize the Dagger graph in
RhoApplication.kt and trigger injection in MainActivity.kt.
Rho.Studio® - Engineering Department - Contact alexis.tercero@rho.studio
Dagger DI
1. Dagger Dependency Injection: Component Dependency & Scoped Orchestration
We will implement a Pure Dagger architecture using Component Dependencies to maintain strict module encapsulation and explicit lifecycle control.
1.1 Multi-Module Component Topology
To preserve the "Clean Architecture" boundaries, we avoid Subcomponents and instead use Component Dependencies.
CoreComponent(in:core:data):@Singleton.AuthRepository,SessionManager, andJsoninfrastructure.UserComponent(in:appor:core:data) [NEW]:@UserScope.CoreComponent.FeatureComponents (in:features:*):CoreComponent(andUserComponentfor authenticated features).1.2 Scoped Component Management
We will implement a
ComponentManagerat the:applevel to orchestrate the lifecycle of theUserComponent. This ensures that when a user logs out, the entire session-scoped graph is garbage collected, fulfilling fintech requirements for Secure Session Isolation.1.3 ViewModel Multibinding & Factory
DaggerViewModelFactoryin:core:uithat leverages aMap<Class<? extends ViewModel>, Provider<ViewModel>>.@IntoMapand@ViewModelKeyin feature modules to decouple the UI from the instantiation of business logic.Phase 1: Environment & Core DI Infrastructure
libs.versions.tomlwith Dagger 2, Firebase BOM, and DataStore dependencies. Apply plugins and dependencies to all modulebuild.gradle.ktsfiles.@UserScopeand@ViewModelKeyin:core:domainor:core:ui.CoreModuleandCoreComponentin:core:datato provideJsonand basic infrastructure.DaggerViewModelFactoryin:core:ui.Phase 3: Feature & App Layer Integration
LoginViewModelandHomeViewModelwith@Injectand register them in their respective Dagger modules using@IntoMap.ComponentManagerin:appto manage the lifecycle of the@UserScopegraph.RhoApplication.ktand trigger injection inMainActivity.kt.Rho.Studio® - Engineering Department - Contact alexis.tercero@rho.studio