mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
1.9 KiB
1.9 KiB
Specification - Extract DatabaseManager to KMP
Overview
Meshtastic-Android is designed to support per-node databases (e.g., db_!1234abcd.db). Currently, the logic for managing these databases (switching, LRU caching, eviction) is trapped in core:database/androidMain. The Desktop implementation stubs this out, forcing all nodes to share a single database, which is a major architectural regression and leads to data pollution across different devices.
This track will move the core DatabaseManager logic to commonMain, enabling full feature parity for database management on Android, Desktop, and iOS.
Functional Requirements
- Per-Node Databases: Desktop and iOS must support creating and switching between separate databases based on the connected device's address.
- LRU Eviction: Implement an LRU (Least Recently Used) cache for database instances on all platforms.
- Cache Limits: The database cache limit must be configurable and respected across all platforms.
- Legacy Cleanup: Maintain logic for cleaning up legacy databases where applicable.
Non-Functional Requirements
- KMP Purity: Use only Kotlin Multiplatform-ready libraries (
kotlinx-coroutines,okio,androidx-datastore). - Dependency Injection: Use Koin to wire the shared
DatabaseManagerinto all app targets. - Platform Specifics: Isolate platform-specific path resolution (e.g., Android
getDatabasePathvs. JVMuser.home) using theexpect/actualpattern.
Acceptance Criteria
DatabaseManagerresides incore:database/commonMain.DesktopDatabaseManager(the stub) is deleted.- Desktop creates unique database files when connecting to different nodes.
- Unit tests in
commonTestverify the LRU eviction logic using an Okio in-memory filesystem (or temporary test directory). - No
android.*orjava.*imports remain in the shared database management logic.