How ujizin/leafy works
Primary Modules/Components
• App Module: This is the main Android entry point (with MainActivity and the Application class) that bootstraps the app. It ties together the UI layer and orchestrates the high-level configuration.
• Domain Layer: Encapsulated within the “domain” module, this layer includes:
– Business models (e.g., Alarm, Plant, User, Ringtone)
– Repository interfaces and use cases (for adding, updating, deleting, or loading plants, alarms, files, etc.)
• Data/Local Modules: These are found in “core/local” and “core/repository”, where:
– Room’s DAOs and database implementations are provided
– Local data sources, mappers, and conversion logic connect the persistent storage to domain models
• Core Modules: Such as “core/navigation”, “core/themes”, and “core/ui” that supply common infrastructure:
– Navigation definitions (using Navigation Compose)
– Reusable UI components, including animated buttons, card components, and scaffold structures
• Features Modules: Each feature (alarm, camera, home, plant, preferences, publish, search, tasks, etc.) is implemented in its own module:
– They encapsulate UI screens, view models, and feature-specific logic
– They interact with the domain layer (via use cases) as well as with the UI components and navigation modules
Interactions and Data Flow
• The App Module (or “driving adapters”) calls into the UI built with Jetpack Compose.
• UI Components in the Core and Features modules use ViewModels that in turn call Use Cases provided by the Domain module.
• Use Cases (domain logic) rely on repositories (injected via Hilt) provided by the Repository module to access data from the Local (Room) layer.
• The Navigation and Themes modules provide additional cross-cutting concerns (routing and styling) to ensure consistency across the user interfaces.
• Hilt is used for Dependency Injection, binding modules and enabling loose coupling between layers.
• The hexagonal design is evident in the separation of “inward” adapters (UI, features) and “outward” adapters (data persistence, local repositories) where the core domain logic sits in the center.