Hey everyone, I have a question about multiplatfor...
# multiplatform
a
Hey everyone, I have a question about multiplatform architecture and dependency injection. Is it recommended to have a dedicated module for DI/common dependencies? Here’s my setup: • I have two modules that depend on
shared
. • I want these modules to live in a common place and be accessible without wiring everything through
MainApplication
. • The DI setup currently lives inside
shared
. • I don’t want those modules to depend directly on
shared
, since that would create a circular dependency. What’s the best way to structure this? Would creating a separate DI/core module be the right approach? Something like this
Copy code
app
 └── depends on di

di
 ├── depends on shared
 ├── depends on featureA
 └── depends on featureB

featureA
 └── depends on shared

featureB
 └── depends on shared
d
Do you have any your dependencies from shared module injected into feature modules components?
m
If by
shared
you mean the usual umbrella module of KMP, you need to review your current structure The code these modules depend on should be extracted to a new module in the bottom of the hierarchy e.g.,
:data
or
:core
module. If the code depends on something like Android context, you can use DI to provide them. As a last resort, you can use interfaces in the new module and implement them in shared, yet it is usually not needed. For DI module, each Gradle module should provide its part of the graph (e.g. Koin Module), then compose them in the
shared
module. No need for a separate one