How comeran/collectmeta works
Main Components
• Presentation Layer: This is where the UI resides. It includes Activities, Fragments (for home, detail, search, library, settings, etc.), and ViewModels. They orchestrate user interactions and mediate between the UI and domain layers using MVVM.
• Domain Layer: This layer contains the business logic. It includes domain models (like Book, ApiConfig, etc.), repository interfaces, and use cases (e.g., AddBookUseCase, GetBookDetailsUseCase, etc.). The domain layer is completely independent of the data and presentation layers.
• Data Layer: Responsible for data retrieval and storage. It is split into:
• Local Data: Room database components such as entities, DAOs, converters (for example, BookEntity, ApiConfigEntity, AppDatabase, etc.).
• Remote Data: API clients (GoogleBooksApi, NotionDatabaseApi, OpenLibraryApi) that handle external API calls.
• Data Mappers: Converters between data entities and domain models.
• Repository Implementations: Implementations for the repositories defined in the domain layer.
• Dependency Injection: Dagger Hilt is used (with modules like DatabaseModule, NetworkModule, RepositoryModule) to provide dependencies to different parts of the application.
• Application and Configuration: The application entry point (CollectMetaApplication.kt) sets up the overall configuration for the app.
Relationships and Interactions
• The Presentation Layer (UI - Fragments/Activities) communicates with the Domain Layer through ViewModels. ViewModels invoke Use Cases.
• The Domain Layer contains use cases that encapsulate business logic and invoke repository interfaces.
• The Data Layer contains repository implementations that fetch data from local (Room-based DB operations) or remote sources (API calls). Data mappers convert data model objects to domain models.
• Dependency Injection orchestrates the wiring of these components, ensuring that UI components, use cases, repositories, and network/database elements are properly provided.
Architectural Patterns & Design Principles
• Clean Architecture: Separation of concerns between Presentation, Domain, and Data layers.
• MVVM: Used in the presentation layer to manage UI state and handle user interactions.
• Repository Pattern: Abstracts data access so that the domain layer is independent of data sources.
• Dependency Injection (using Dagger Hilt): Ensures modularity and testability.
• Separation of local (Room database) and remote (API) data handling.