Skip to content

Decouple domain data models from proto models#473

Closed
Kimblebee wants to merge 8 commits intomainfrom
kim/refactor/datastore
Closed

Decouple domain data models from proto models#473
Kimblebee wants to merge 8 commits intomainfrom
kim/refactor/datastore

Conversation

@Kimblebee
Copy link
Collaborator

This PR introduces a new data:settings-datastore module to centralize DataStore and Protobuf-related logic, improving
modularity and clarifying dependencies.

Key Changes:

  • New Module: Created :data:settings-datastore to house DataStoreModule.kt, JcaSettingsSerializer.kt, and
    LocalSettingsRepository.kt, along with their associated tests and jca_settings.proto. This streamlines the
    :data:settings module, which now focuses solely on the SettingsRepository interface.
  • Proto Conversion Fix: Corrected the default LensFacing proto conversion in ProtoMappers.kt to LensFacing.BACK for
    unrecognized values, aligning with test expectations.
  • Enhanced Test Coverage: Added comprehensive unit tests for DebugSettings proto conversions in ProtoConversionTest.kt, ensuring correct serialization and deserialization.

  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.
@gemini-code-assist
Copy link
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@Kimblebee Kimblebee closed this Feb 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant