Reason:
The solution based on a copy of the server database is too large, which entails a significant size of application and wasted time on first launch for database instantiation. In addition, such a solution makes it difficult to update the application when business logic changes (database migration is required on the user's devices) and requires duplication of code and/or SQL queries on the server and client.
Implementation:
The data source can be alternative implemented based on calls to the server API. It is proposed to use the open API of the current server version, with further updates as the server code develops. API specification is available in server's GitHub repositiory.
Implement interface ru.z8.louttsev.cheaptripmobile.shared.model.DataSource based on Ktor multi-platform client. Package ru.z8.louttsev.cheaptripmobile.shared.infrastructure.datasource is suitable place for this implementation. Don't worry about proper threads and coroutine scopes: DataSource called in background thread on view model scope.
Change DataSource implementation in DI container (such as class ru.z8.louttsev.cheaptripmobile.androidApp.App for Android). Use BACKUP strategy for route repository.
Mark deprecate and/or remove classes FullDbDataSource, LocationDataSourceFullDb, RouteDataSourceFullDbfrom ru.z8.louttsev.cheaptripmobile.shared.infrastructure.datasource package. If fullDB implementation was removed, also remove directory sqldelightFullDb wirh subdirectories.
Mark deprecate and/or remove method getDriver in expected/actual class DatabaseDriverFactory (located in files Database.kt in commonMain, androidMain and iosMain modules).
IMPORTANT !!! Necessarily delete file fullDb.sqlite3 from resources/MR/files directory in commonMain module. This is pre-populated DB included in the application resources and occupies the bulk of apk.
Reason: The solution based on a copy of the server database is too large, which entails a significant size of application and wasted time on first launch for database instantiation. In addition, such a solution makes it difficult to update the application when business logic changes (database migration is required on the user's devices) and requires duplication of code and/or SQL queries on the server and client.
Implementation: The data source can be alternative implemented based on calls to the server API. It is proposed to use the open API of the current server version, with further updates as the server code develops. API specification is available in server's GitHub repositiory.
ru.z8.louttsev.cheaptripmobile.shared.model.DataSource
based on Ktor multi-platform client. Packageru.z8.louttsev.cheaptripmobile.shared.infrastructure.datasource
is suitable place for this implementation. Don't worry about proper threads and coroutine scopes: DataSource called in background thread on view model scope.ru.z8.louttsev.cheaptripmobile.androidApp.App
for Android). Use BACKUP strategy for route repository.FullDbDataSource
,LocationDataSourceFullDb
,RouteDataSourceFullDb
fromru.z8.louttsev.cheaptripmobile.shared.infrastructure.datasource
package. If fullDB implementation was removed, also remove directory sqldelightFullDb wirh subdirectories.getDriver
in expected/actual classDatabaseDriverFactory
(located in files Database.kt in commonMain, androidMain and iosMain modules).