Skip to content

Commit 0e5bccc

Browse files
Documentation edits made through Mintlify web editor
1 parent e33ad7a commit 0e5bccc

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

architecture/client-architecture.mdx

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ title: "Client Architecture"
77
From the client-side perspective, there are two data flow paths:
88

99
* Reading data from the server or downloading data (to the SQLite database)
10+
1011
* Writing changes back to the server, or uploading data (from the SQLite database)
1112

1213
#### Reading Data
@@ -18,13 +19,13 @@ A developer configures [Sync Rules](/usage/sync-rules) for their PowerSync insta
1819
The PowerSync Service connects directly to the backend database and uses a change stream to hydrate dynamic data partitions, called [sync buckets](/usage/sync-rules/organize-data-into-buckets). Sync buckets are used to partition data according to the configured Sync Rules. (In most use cases, only a subset of data is required in a client's database and not a copy of the entire backend database.)
1920

2021
<Frame>
21-
<img src="/images/powersync-docs-architecture-diagram-006 (2).png"/>
22+
<img src="/images/powersync-docs-architecture-diagram-006 (2).png" />
2223
</Frame>
2324

2425
The local SQLite database embedded in the PowerSync SDK is automatically kept in sync with the backend database, based on the [Sync Rules](/usage/sync-rules) configured by the developer:
2526

2627
<Frame>
27-
<img src="/images/powersync-docs-architecture-diagram-007 (2).png"/>
28+
<img src="/images/powersync-docs-architecture-diagram-007 (2).png" />
2829
</Frame>
2930

3031
#### Writing Data
@@ -34,25 +35,33 @@ Client-side data modifications, namely updates, deletes and inserts, are persist
3435
Each entry in the queue is processed by writing the entry to your existing backend application API, using a function [defined by you](/installation/client-side-setup/integrating-with-your-backend) (the developer). This is to ensure that existing backend business logic is honored when uploading data changes. For more information, see the section on [integrating with your backend](/installation/client-side-setup/integrating-with-your-backend).
3536

3637
<Frame>
37-
<img src="/images/powersync-docs-architecture-diagram-008 (3).png"/>
38+
<img src="/images/powersync-docs-architecture-diagram-008 (3).png" />
3839
</Frame>
3940

4041
### Schema
42+
4143
On the client, the application [defines a schema](/installation/client-side-setup/define-your-schema) with tables, columns and indexes.
4244

4345
These are then usable as if they were actual SQLite tables, while in reality these are created as SQLite views.
4446

4547
The client SDK maintains the following tables:
4648

4749
1. `ps_data__<table>` This contains the data for `<table>` , in JSON format. This table's schema does not change when columns are added, removed or changed.
50+
4851
2. `ps_data_local__<table>` Same as the above, but for local-only tables.
52+
4953
3. `<table>` (VIEW) - this is a view on the above table, with each defined column extracted from the JSON field. For example, a "description" text column would be `CAST(data ->> '$.description' as TEXT)`.
50-
4. `ps_untyped` \- Any synced table that does is not defined in the client-side schema is placed here. If the table is added to the schema at a later point, the data is then migrated to `ps_data__<table>`.
51-
5. `ps_oplog` \- This is data as received by the [PowerSync Service](/architecture/powersync-service), grouped per bucket.
52-
6. `ps_crud` \- The local upload queue.
53-
7. `ps_buckets` \- A small amount of metadata for each bucket.
54-
8. `ps_migrations` \- Table keeping track of SDK schema migrations.
54+
55+
4. `ps_untyped` - Any synced table that does is not defined in the client-side schema is placed here. If the table is added to the schema at a later point, the data is then migrated to `ps_data__<table>`.
56+
57+
5. `ps_oplog` - This is data as received by the [PowerSync Service](/architecture/powersync-service), grouped per bucket.
58+
59+
6. `ps_crud` - The local upload queue.
60+
61+
7. `ps_buckets` - A small amount of metadata for each bucket.
62+
63+
8. `ps_migrations` - Table keeping track of SDK schema migrations.
5564

5665
Most rows will be present in at least two tables — the `ps_data__<table>` table, and in `ps_oplog`. It may be present multiple times in `ps_oplog`, if it was synced via multiple buckets.
5766

58-
The copy in `ps_oplog` may be newer than the one in `ps_data__<table>`. Only when a full checkpoint has been download, will the data be copied over to the individual tables. If multiple rows with the same table and id has been synced, only one will be preserved (the one with the highest `op_id`).
67+
The copy in `ps_oplog` may be newer than the one in `ps_data__<table>`. Only when a full checkpoint has been downloaded, will the data be copied over to the individual tables. If multiple rows with the same table and id has been synced, only one will be preserved (the one with the highest `op_id`).

0 commit comments

Comments
 (0)