How hoseinsadonasl/minigallery works
Project Type & Purpose
• The project is an open-source Android application written completely in Kotlin.
• It showcases modern Android development using Jetpack Compose for building responsive UIs and follows Clean Architecture along with the Model-View-Intent (MVI) presentation pattern.
• The modular design is evident from the directory structure which splits functionality (features, core, media, etc.) into separate modules for better separation of concerns and maintainability.
File Structure
• The top-level directories include:
– "app": The entry point of the Android application containing MainActivity, the application class, and primary resources.
– "build-logic": Modules containing Gradle convention plugins and scripts that set consistent build standards.
– "core", "core-feature", "media", and "features": Indicate a modular architecture; for example:
∙ "core-domain", "core-database", and "core-datastore" define business logic, data persistence, and app settings.
∙ "features" folder contains modules like “albums”, “media-library”, “media”, “media-details”, and “onboarding” that represent specific application functionalities.
∙ "core-feature" holds shared design elements (“designsystem”, “navigation”, “ui”) crucial to the UI and user flows.
• There are separate modules for data sources and repositories (e.g., media-data, media-datasource, media-domain) which follow Clean Architecture by segregating data access, domain logic, and presentation concerns.
Main Components
a. Presentation Layer:
– App Module: Contains MainActivity, UI components, and the application class (MiniGalleryApp.kt).
– Feature Modules: Each feature (albums, media-library, media, media-details, onboarding) includes its own screens (with Compose based UI), ViewModels, and state/event classes. The MVI pattern ensures a unidirectional flow of data.
– Core UI and Navigation: Under “core-feature/navigation” and “core-feature/ui”, these components manage screen transitions, shared UI components, and consistent theming/design.
b. Domain Layer:
– Modules under "core/domain" and "media/media-domain" encapsulate business logic and use cases (such as GetAlbumsUseCase, SyncMediaUseCase, FavoriteMediaUseCase) that enforce Clean Architecture principles.
– These interact with the repositories abstracting the data layer.
c. Data Layer:
– Data handling is split mainly between "core/database", "core/datastore", and “media-data”/ “media-datasource”.
∙ The database module manages local persistence with Room (or similar) and provides DAOs.
∙ The datastore module stores user preferences or application settings.
∙ Media data and repository implementations handle network or content provider data with dedicated mappers to transform data between representations.
d. Build & Configuration:
– "build-logic" and Gradle configuration files standardize the build and dependency management.
– These are supportive components that enforce code quality (using Ktlint, Detekt) and modular build conventions.
Representing Relationships & Data Flow
– The Presentation layer (UI, Screens, ViewModels) communicates with the Domain layer through use cases.
– The Domain layer interacts with the Data layer via abstracted repository interfaces.
• That dependency injection (using Hilt) is used across modules to manage dependencies.
• Unidirectional flow inherent in MVI: user events lead to updates in state, which update the UI.
Architectural Patterns & Design Principles
• Modular Design: Show how each module (feature-specific or core shared modules) encapsulates related functionality.
• MVI Pattern: In the presentation modules, annotate state, intents (events), and the view layer, showcasing the unidirectional data flow.