There's this idea called CQRS which is pretty popular among folks following Domain-Driven Design (DDD) and Event Sourcing architecture patterns. It stands for Command Query Responsibility Segregation, which is basically separating your write data model (Commands) form your read data model (Queries).

I've said a few times before that we are doing pretty similar things with Seed, but today I had a few extra realizations that helped me reason about all of it.

Our write model is the signed blobs. Our read model is the APIs and the local indexes we derive from those signed writes. With Unified Hypermedia Resource Architecture we are formalizing our read model, making it closer to being a protocol than a mere implementation detail of the Seed Hypermedia application.

The extra realizations I had today:

    During P2P sync, we want to query the read model, but sync the write model, such that we can apply the writes locally, derive our own local read model (but now verified and with all the provenance), and then serve that read model to the client. This is pretty nuts on its own πŸ˜….

    We have 3 read patterns:

      Desktop client -> local daemon (queries the read model).

      Eric has been advocating for a long time to allow desktop clients to query the read model of a remote server too, in addition to the local daemon. This could help speeding things up in the app, but I was always reluctant about doing that. It feels like a crutch, and "overlaying" the unverified read model of a remote server with the verified read model of a local server looks complicated.

      Probably a more interesting idea would be to make the read model itself syncable, and potentially authenticated too. It could be authenticated by the serving peer, or by the legitimate space writers themselves. This is a huge topic we could explore at some point.

      Web browser -> remote server (queries the read model).

      Desktop peer -> remote peer (P2P sync β€” queries the read model, syncs writes).

    All these read patterns are quite similar in what they want, but these needs sometimes pull in opposite directions. The needs are:

      Expressive queries, returning only the necessary information efficiently, with pagination. Enforcing permissions adds a lot of complexity here.

      Keep the server's runtime overhead (CPU, RAM, I/O), and storage overhead (disk space) low. The server should have enough indexes to cover the expressivity of the queries cheaply, yet indexes are not free and cost disk space and compute.

      Regardless of whether verified or not, the clients want to maintain the queries up to date and live incrementally (or somewhat efficiently at least). The degree of how cool this would work directly adds overhead on the server, and enforcing permissions adds more complexity here as well.

    Probably at some point we'll have to stop pretending we are not a database πŸ˜…. Maybe one day we will have a unified query language that would close the loop and would work the same between browser, daemon, remote servers, web and P2P, all while staying verified, with provenance, and permissions working nicely and accurately.

Do you like what you are reading? Subscribe to receive updates.

Unsubscribe anytime