"""
# Summary

The intention of syncing in NAME_1 is to keep a user's data consistent across all of their devices. This includes data such as decks, cards, reviews, words and more.

Syncing is achieved through the use of two SQLite databases - one local database stored on the user's device, and one master database stored in Google Cloud Storage. The master database acts as the single source of truth for a user's data.

When a user makes changes on one device, such as adding a new card, that device will push those changes to the master database on Google Cloud Storage. Other devices can then pull those changes from the master database, updating their local databases and keeping everything in sync.

Most data in the NAME_1 app is synced between devices, with a few exceptions:

- Local-only data that does not need to be shared (e.g. device-specific settings like dark-mode)
- Large datasets like dictionaries that would be inefficient to sync this way

The syncing process utilizes push syncs, where a device pushes its changes to the master database, and pull syncs, where devices pull the latest changes from the master database. To prevent data loss in the event of multiple devices pushing changes at once, the syncing system uses Google Cloud Storage Object Generations to detect and handle update conflicts.

For new devices, an initial "force pull sync" is performed which downloads the entire master database, providing the device with all of the user's latest data to start with. After the initial sync, the device will continue using push and pull syncs to stay up to date.

# How does syncing with the Core work?

There are usually 2 sqlite databases involved with every sync, accessed with the Kotlin Multiplatform library [Sqldelight](https://github.com/NAME_2/sqldelight).

One is used and stored on the client device (in the case of the browser it is compressed and stored in indexeddb) and the other is stored in Google Cloud Storage and accessed by the Sync Server.
On PullSyncs the server downloads the database and passes all changed data to the client.
On PushSyncs the server downloads the database, modifies it and uploads it to Google Cloud Storage again.

With this behaviour changes could get lost if 2 `pushSync`s happened at the same time, so the server uses [Google Cloud Storage Object Generations](https://cloud.google.com/storage/docs/metadata#generation-number) to detect conflicts
On a conflict the server rejects the `pushSync` with [http error code 412](https://github.com/NAME_1-official/NAME_1-SRS-Sync-Server/NAME_3 Give two different versions of responses. Please separate the responses with 6 asterisk symbols: ******.
user