Document Storage
This page explains how CoCube stores data locally, how sync and collaboration features work, and how CoCube keeps your data secure.
Why Local‑First?
Web apps typically store your data on remote servers and send it to you when you request it. Local‑first software instead keeps your data on the device you are using, under your control. CoCube only contacts its servers when you explicitly opt in on a per‑document basis for sync and collaboration features. This lets you keep your work private and secure, without limiting who you can work with.
What Is a Document?
Documents are the building blocks of reactive and collaborative tools.
A document stores a single literal value, for example, some text, a number, or even a component definition. Like a cell, a document can contain any literal value or expression. Documents may be referenced from any other expression.
Updates to a document are immediately reflected in every expression that references it. This allows a single change to potentially affect many different elements and behaviors of the components you build. On top of this, documents can be shared and collaborated on in real time, allowing you to create collaborative components and tools.
In a sense, this means CoCube is a local first collaborative database. Combining collaborative editing with CoCube’s spreadsheet‑like cell and expression system is what makes building both tools that work both collaboratively or locally so simple.
Example: Component Set
As an example, imagine you are creating multiple custom components. You want the color of the buttons to match across these components. You can do this by creating a color document, then setting the color of each button to the document you created. When you change the value of the color document, your components will change as well.
Example: Collaborative Text
For another example, imagine creating a document that you want to work on with collaborators. By turning the text into a document, you can then edit that text in real time with others. Updates merge correctly, even if you go offline and make changes—and your updates sync to collaborators when you log in again.
Browser Storage
To enable offline work, logging in is only necessary to sync documents with peers. If you are offline you may continue to work on any documents you had access to while logged in. After working offline, logging in again results in your changes seamlessly syncing with collaborators.
CoCube uses the browsers storage to keep a copy of every accessible document. Access to this data is kept behind your browsers "user" mechanism. This means that you must be careful when using a device that does not belong to you to when you log in, as all of your synced documents will be stored on that device. If someone else accesses the same device and browser user, they will see the local copies of all the documents you had access to, even without logging in to your account. They would be able to view and make local changes to these documents, they would not be able to sync those changes unless you log back in on the device.
All users on the local device can access and modify all local documents. This feature lets you use CoCube without even creating an account. You may sign in and take ownership of a local unowned document—making that document accessible only to you and allowing you to sync or collaborate on it.
Sharing a document
Documents may be shared publicly, or collaborated on in private with specific users.
There are three document states:Local: The document is stored locally, and updates are not shared.Synced: The document is synced with CoCubes servers, allowing you to access the document on multiple devices. Additionally, you may add collaborators. These collaborators will receive the latest copy of the document on each device they sign in on. Any changes they make to the document are shared in real time with all other collaborators.Public: The document is synced and viewable/usable by anyone who knows the document id.
When you are looking at a document in the Documents explorer, you will see where each document is synced.
(DocumentName [S(P)][L] Owner Type)S means the document is synced with the Server.P means the document is marked as public.Owner is the documents owner - this will be the user that shared the document with you if you are a collaborator.L means the document is persisted Locally (Persisted).
CoCubes server manages document permissions. By creating a local document then changing its status to synced, a user takes ownership of that document on CoCubes server. Once a user owns a document, they are the only one who can add or remove collaborators. If another user who has access to the document tries to take ownership, their request will fail.
Example: Sharing a note.
You have a note document that you would like to collaborate on with someone else. After signing in to your account, open the note locally. Add a collaborator using the top-menu.
Remote Storage
All communication with CoCube servers to/from clients is encrypted. CoCube servers do not yet implement encryption-at-rest / E2E encryption.