Skip to content

Latest commit

 

History

History
133 lines (124 loc) · 5.48 KB

MODULARIZATION.md

File metadata and controls

133 lines (124 loc) · 5.48 KB

Modularization

Here you will explore the modularization strategy of the Android Template app.

Why Multi-Module?

  • Developers can work on specific sections of the application without slowing down other developers.
  • Maintainability: All files are organized in their respective modules, making it easier to locate what we're looking for.
  • Incremental Compilation: Modifying a file allows modularized apps to compile faster compared to monolithic apps.
  • CI/CD processes run faster.

Modules in Android Template App

Diagram showing basic modules

  • The app module serves as the foundation for the application, encompassing app-level and scaffolding components that connect the rest of the codebase. It has dependencies on all feature modules and necessary core modules.
  • Feature modules are designed to manage specific responsibilities within the app and are scoped accordingly. These modules remain distinct and self-contained. Classes that are only relevant to a single feature module should remain within it, whereas shared functionality should be moved to the appropriate core module. Feature modules are independent and do not rely on other feature modules, but only on the core modules they require.
  • Core modules are shared library modules that house auxiliary code and specific dependencies meant to be utilized across various parts of the app. These modules may depend on other core modules but should not have dependencies on feature or app modules. Additionally, some core modules are designed to implement specific layers of the Clean Architecture framework, ensuring clear separation of concerns and promoting reusability throughout the codebase.
  • Miscellaneous modules, such as :architecture and :utils, serve specific purposes and can be utilized by any other module.
Name Responsibilities Key classes and good examples
app Integrates all the essential components required for the app to function seamlessly. MyApplication, MainActivity
feature:movie-catalog,
feature:2
...
Handles functionality related to a specific feature or user journey, typically encompassing UI components and ViewModels that retrieve data from other modules.
MovieListScreen
MovieListViewModel
core:bridge-di A necessary module to support dependency injection and prevent cyclic Gradle dependencies. CoreModule
core:data Retrieving application data from various sources, utilized across different features. MoviesRepositoryImpl
core:database A package that includes database-related modules provides both an API and concrete implementations. This approach ensures that other modules interact only with the API, without direct access to specific implementations such as the Room database. DatabaseDataSource, RoomDataSource
core:domain Contains the app’s business logic in the form of use case classes, along with repository interfaces only, keeping the implementation details abstracted. GetMoviesUseCase, MoviesRepository
core:model Contains the app’s domain or business objects. Movie, ErrorModel
core:navigation A package that includes navigation-related modules provides both an API and concrete implementations. This setup ensures that the rest of the app interacts with a navigation API, while the actual implementation leverages a navigation library (such as Compose Navigation). This abstraction makes it easier to switch to a different navigation library in the future if needed. Navigator, AndroidComposeNavigator
core:network A package that includes network-related modules provides both an API and concrete implementation. This approach ensures that other modules interact only with the API, without direct access to specific implementations such as the Retrofit library. NetworkDataSource, RetrofitNetworkDataSource
core:presentation A package that includes presentation-related module like MVI implementation, theme and common UI components. MviViewModel, Theme.kt
architecture A package that includes architecture-related modules provides base classes that are utilized consistently throughout the app, promoting a uniform structure and reducing redundancy. ApiToDomainMapper
utils A package that includes utility-related modules provides classes that are used throughout the app. random/Utils