Decouple domain data models from proto models#473
Closed
Conversation
This pull request introduces a significant architectural refactoring focused on improving the internal modularity and
maintainability of the codebase. The primary goal was to decouple the core data models from any specific data persistence
implementation (namely Protobuf and DataStore).
This change ensures that core application components can utilize fundamental data types and settings interfaces without
inheriting dependencies on Protobuf or DataStore, thus promoting cleaner module boundaries and increased flexibility for
internal system evolution.
Key Changes:
1. Creation of `:data:settings` (API Module):
* A new, lightweight module was created to define the public API for settings within the application.
* It contains the SettingsRepository interface and pure data models for settings (JcaSettings).
* This module depends only on :core:model, ensuring it has no knowledge of persistence details.
2. Creation of `:data:settings-datastore` (Implementation Module):
* The original :data:settings module was renamed and repurposed to become the concrete implementation of the new API
module.
* It now contains the LocalSettingsRepository implementation, the DataStoreModule for Hilt, and all Protobuf-related
logic.
3. Purification of `:core:model`:
* All Protobuf dependencies, imports, and conversion functions (toProto/fromProto) have been completely removed from
this module.
* :core:model is now a pure-Kotlin module, containing only the fundamental data classes and enums. This makes it a
lightweight and universal dependency within the application.
4. Centralized Proto Mappers:
* All toProto/fromProto logic has been migrated into the :data:settings-datastore module under a new mappers
package.
* The conversion logic is now implemented as idiomatic Kotlin extension functions (toDomain()/toProto()) in
dedicated files (e.g., AspectRatioMapper.kt). This co-locates mapping logic while maintaining a clean separation
of concerns.
5. Decoupling Navigation from Persistence:
* The DebugSettingsNavType was refactored to remove its dependency on Protobuf serialization.
* The DebugSettings data class now contains self-sufficient toNavString() and fromNavString() methods for
navigation-specific serialization, ensuring the UI/navigation layer is completely independent of the data storage
layer.
…the data/settings and data/settings-datastore modules.
spotless
Contributor
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR introduces a new data:settings-datastore module to centralize DataStore and Protobuf-related logic, improving
modularity and clarifying dependencies.
Key Changes:
:data:settings-datastoreto houseDataStoreModule.kt,JcaSettingsSerializer.kt, andLocalSettingsRepository.kt, along with their associated tests andjca_settings.proto. This streamlines the:data:settings module, which now focuses solely on theSettingsRepositoryinterface.unrecognized values, aligning with test expectations.