Module Overview
Model
Business objects and domain models
Gateway
Repository interfaces and contracts
Use Case
Business logic and application use cases
Model Module
Module:domain:model
Package: es.mobiledev.domain.model
Defines the core business objects (Business Objects - Bo) used throughout the application.
ArticleBo
File:domain/model/src/main/java/es/mobiledev/domain/model/article/ArticleBo.kt:3
Represents an article in the domain layer.
Unique identifier for the article
Article title
List of article authors with their information
URL to the full article
URL to the article’s featured image
Source news site name
Brief summary or excerpt of the article
ISO 8601 formatted publication timestamp
ISO 8601 formatted last update timestamp
AuthorBo
File:domain/model/src/main/java/es/mobiledev/domain/model/article/AuthorBo.kt:3
Represents an article author.
Author’s full name
Optional social media links for the author
SocialsBo
Represents social media links.ArticleResponseBo
Wrapper for paginated article responses.List of articles in the current page
Total number of articles available
URL for the next page of results, null if last page
URL for the previous page of results, null if first page
The “Bo” suffix stands for “Business Object” and distinguishes domain models from DTOs (Data Transfer Objects) and DBOs (Database Objects).
Gateway Module
Module:domain:gateway
Package: es.mobiledev.domain.gateway
Defines interfaces (gateways) that describe how the domain layer interacts with external systems. These interfaces are implemented by the data layer.
ArticleGateway
File:domain/gateway/src/main/java/es/mobiledev/domain/gateway/article/ArticleGateway.kt:7
Interface defining operations for article data access.
Methods
Retrieves a single article by its IDReturns:
Unique article identifier
Flow<ArticleBo> - Flow emitting the requested articleRetrieves all articles marked as favorites by the userReturns:
Flow<List<ArticleBo>> - Flow emitting list of favorite articlesAdds an article to the user’s favorites
Article to mark as favorite
Removes an article from the user’s favorites
Article to remove from favorites
Checks if an article is in the user’s favoritesReturns:
Article identifier to check
Flow<Boolean> - Flow emitting true if article is favoritedPreferencesGateway
Package:es.mobiledev.domain.gateway.preferences
Interface for user preferences and app settings.
Gateways follow the Gateway pattern (similar to Repository pattern) and define the contract between domain and data layers. This enables dependency inversion and makes the domain layer testable.
UseCase Module
Module:domain:useCase
Package: es.mobiledev.domain.usecase
Encapsulates specific business logic operations. Each use case represents a single business action.
GetArticlesUseCase
File:domain/useCase/src/main/java/es/mobiledev/domain/usecase/article/GetArticlesUseCase.kt:7
Retrieves a paginated list of articles.
Maximum number of articles to retrieve
Pagination offset
Flow<ArticleResponseBo>
GetArticleByIdUseCase
File:domain/useCase/src/main/java/es/mobiledev/domain/usecase/article/GetArticleByIdUseCase.kt:7
Retrieves a specific article by ID.
Unique identifier of the article
Flow<ArticleBo>
GetFavoriteArticlesUseCase
Retrieves all favorite articles.Flow<List<ArticleBo>>
SaveOrRemoveFavoriteArticleUseCase
Toggles an article’s favorite status.The article to toggle
Current favorite status (will be toggled)
IsArticleFavoriteUseCase
Checks if an article is favorited.Article identifier to check
Flow<Boolean>
Preferences Use Cases
Use Case Pattern
- Interface
- Implementation
- Usage
Use cases implement the
operator fun invoke() pattern, allowing them to be called like functions. This provides a clean API: useCase(params) instead of useCase.execute(params).