Very interesting!

I think the biggest weak points of firebase are a. a weak query engine (as soon as you reach non-trivial complexity you end up having to de-normalize data) and b. a weak rule engine (relying on a bunch of boolean logic is not going to scale as your app grows. you need more abstraction power)

Looks like your library addresses both -- crux has datalog queryability, and the rule dsl you wrote seems pretty powerful.

Good work Jacob!

Thanks! I'm also looking forward to finishing the Materialize[1] integration I've been working on (currently blocked while I wait for them to release some features). Although Crux has datalog, you can't subscribe to datalog queries. But with Materialize, you can basically subscribe to arbitrary SQL queries. I have a branch that lets you define the SQL queries on the backend and then subscribe to the results via Biff's existing subscription system.

[1] https://materialize.io

Cool! Two noob qs:

1. Would love to learn a bit more about how the rule engine works.

From what I understand crux in essence only gives you key->blob semantics. How do you know that one `doc` is a `user`, and another doc is an `game`, etc

2. re: datalog subscriptions -- do you know if this is something inherently very difficult, or is it that crux hasn't implemented this yet?

1. You have to register specs for each kind of document. For example, from the frontend you can subscribe to a user document of a given ID with `{:table :users :id #uuid "some-uuid"}`. The backend will: (1) look up the document with the given ID, (2) verify that you've registered a spec for the `:users` "table" and verify that the document meets that spec, (3) run the authorization rule to make sure the client has access to that user document.

2. It is inherently difficult. The closest thing like this that exists for datalog is I believe clj-3df[1]. Hence I was very excited when Materialize was launched publicly a few months ago. A version for datalog would be cool too, but SQL is good enough I think.

[1] https://github.com/sixthnormal/clj-3df