title: How to implement Koin dependency injection in Room MVVM Architecture
body: <p>I'm following <a href="https://insert-koin.io/docs/quickstart/android-viewmodel/" rel="nofollow noreferrer">this</a> documentation to implement koin dependency injection but it couldn't help me. I'm stuck in <code>Modules.kt</code> file I don't know how to pass DAO interface of Database to <code>Repository</code> constructor in <code>module</code> of koin.</p>
  <p><strong>UserEntity.kt</strong></p>
  <pre><code>@Entity(tableName = &quot;user_table&quot;)
  data class UserEntity(...)
  </code></pre>
  <p><strong>UserDao.kt</strong></p>
  <pre><code>@Dao
  interface UserDao { ... }
  </code></pre>
  <p><strong>UserRepository.kt</strong></p>
  <pre><code>class UserRepository(private val userDao: UserDao) {...}
  </code></pre>
  <p><strong>UserViewModel.kt</strong></p>
  <pre><code>class UserViewModel(private val repository: UserRepository) : ViewModel() {...}
  </code></pre>
  <p><strong>UserDatabase.kt</strong></p>
  <pre><code>@Database(
      entities = [UserEntity::class],
      version = 1,
      exportSchema = false
  )
  abstract class UserDatabase : RoomDatabase() {
      abstract fun userDao(): UserDao
  
      companion object {
  
          @Volatile
          private var INSTANCE: UserDatabase? = null
          fun getDatabase(context: Context, scope: CoroutineScope): UserDatabase {
              return INSTANCE ?: synchronized(this) {
                  val instance = Room.databaseBuilder(
                      context.applicationContext,
                      UserDatabase::class.java,
                      &quot;user_data_database&quot;
                  ).build()
                  INSTANCE = instance
                  instance
              }
          }
      }
  }
  </code></pre>
  <p><strong>Modules.kt</strong> Here is Koin Modules</p>
  <pre><code>val appModule = module{
  
      single { UserRepository(get()) }
  
      viewModel { UserViewModel(get()) }
  
  }
  </code></pre>