Dependency Injection

In Mobile Jazz, we defined our own dependency injection pattern. We use it in all the language that we are currently supporting and allows us to have a standarize way. It has three main concepts: Provider, Component and Module.


A provider is a file that contains a component and a module. For example, it can be a feature or a topic that it's part of your application.


A component is an interface that expose the public contract of your module.


A module is a class that implements a component and specify how we are going to supply each component. A module has a constructor to provide every dependency that it needs. Also, inside the module we can build every other dependency that we need in order to supply the component.

Find an example in Kotlin:

All this code is inside a Provider named BikeProvider.
interface BikeComponent {
fun getBikeInteractor(): GetBikeInteractor
fun getBikesInteractor(): GetBikesInteractor
class BikeDefaultModule(private val coroutineScope: CoroutineScope,
private val networkConfiguration: NetworkConfiguration,
private val oauthComponent: OAuthComponent,
private val cacheDatabase: CacheDatabase,
private val otp: OTP) : BikeComponent {
override fun getBikesInteractor(): GetBikesInteractor =
GetBikesInteractor(coroutineScope, getBikes, oauthComponent.getPasswordTokenInteractor(), getSelectedBikeID)
override fun getBikeInteractor(): GetBikeInteractor =
GetBikeInteractor(coroutineScope, GetInteractor(coroutineScope, bikeRepository), oauthComponent.getPasswordTokenInteractor(), getSelectedBikeID, getBikeAdapterInteractor)
private val bikeRepository: RepositoryMapper<BikeEntity, Bike> by lazy {
val getNetworkDataSource = GetNetworkDataSource(
val putNetworkDataSource = PutNetworkDataSource(
networkConfiguration.bikesURL, networkConfiguration.httpClient, BikeEntity.serializer(),
val deleteNetworkDataSource = DeleteNetworkDataSource(
val singleDataSourceRepository = SingleDataSourceRepository(getNetworkDataSource, putNetworkDataSource, deleteNetworkDataSource)
return@lazy RepositoryMapper(singleDataSourceRepository, singleDataSourceRepository, singleDataSourceRepository, BikeEntityToBikeMapper,