MCPcopy Index your code
hub / github.com/comnik/declarative-dataflow

github.com/comnik/declarative-dataflow @v0.2.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.2.0 ↗ · + Follow
398 symbols 865 edges 54 files 131 documented · 33%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Declarative Dataflow

A reactive query engine built on differential dataflow.

crates

Documentation

Features

Interactive use: Declarative accepts queries expressed in a Datalog-inspired binding language and turns them into differential dataflows dynamically and at runtime. This works equally well as a library embedded into a specific application or as a standalone service (e.g. via the included WebSocket server).

Reactive relational queries: Declarative provides a relational query language, with full support for traditional binary joins, worst-case optimal n-way joins, antijoins, various aggregates, predicates, unions, and projections. Queries are made up of rules, which can depend on each other (or recursively on themselves). Query results are updated incrementally as inputs change.

[WIP] Reactive GraphQL queries: Declarative also comes with built-in support for GraphQL-like queries, for a more document-oriented usage model.

Pluggable sinks and sources: Declarative can be extended to read data from and write results back to external systems, such as Kafka or Datomic, as well as static sources such as csv files.

Pluggable frontends: Languages such as Datalog and SQL can be easily implemented on top of Declarative. Well, maybe not easily, but easier than without. A Datalog frontend is provided in Clojure(Script).

Thanks to Differential Dataflow, all these capabilities are provided within the dataflow model and can thus be scaled out to multiple independent workers. Declarative is less efficient and much more opinionated than hand-written Differential Dataflow. In particular, it enforces a fully-normalized, RDF-like data model heavily inspired by systems like Datomic or LogicBlox. Other than that, Declarative is just Differential Dataflow under the hood and can happily co-exist and interact with static, handwritten dataflows.

Included in this repository is the library itself, a server, and a cli.

Build

The library is built using cargo. A sufficiently up-to-date Rust toolchain is enforced via the rust-toolchain file included in this repository.

Declarative Dataflow makes use of the log crate. Logging at a specific level can be enabled by setting the RUST_LOG environment variable to RUST_LOG=declarative_dataflow=<level>.

Documentation

Crate documentation available on crates.io.

Important architectural decisions are documented in the docs/adr/ sub-directory.

Documentation for this package can be built via cargo doc --no-deps and viewed in a browser via cargo doc --no-deps --open. Please refer to declarative_dataflow::plan::Plan for documentation on the available operators. The tests/ directory contains usage examples.

Clients

Declarative Dataflow servers accept a lower-level relational query plan representation, that is meant to be somewhat frontend agnosti. However query plans are rather cumbersome to write manually and do not map to any interesting, higher-level semantics. Currently we therefore provide a Datalog front end written in Clojure.

Please refer to the documentation for an overview of the supported query plans.

Further Reading / Watching

A post on the high-level motivation for this project.

[video] Reactive Datalog For Datomic, recorded at Clojure/conj 2018.

[video] 3DF: Reactive Datalog For Datomic, recorded at :clojureD 2019.

The Clockworks blog has a number of posts on Declarative.

Extension points exported contracts — how you extend this code

Sourceable (Interface)
An external data source that can provide Datoms. [7 implementers]
src/sources/mod.rs
Implementable (Interface)
A type that can be implemented as a simple relation. [14 implementers]
src/plan/mod.rs
AsBinding (Interface)
A thing that can act as a binding of values to variables. [8 implementers]
src/binding/mod.rs
Relation (Interface)
A relation between a set of variables. Relations can be backed by a collection of records of type `Vec `, each of [3 implementers]
src/lib.rs
Rewind (Interface)
Extension trait for timestamp types that can be safely re-wound to an earlier time. This is required for automatically a [3 …
src/timestamp/mod.rs
Sinkable (Interface)
An external system that wants to receive result diffs. [3 implementers]
src/sinks/mod.rs
CardinalityOne (Interface)
Provides the `cardinality_one` method. [1 implementers]
src/operators/mod.rs
Run (Interface)
(no doc) [2 implementers]
tests/cardinality_one.rs

Core symbols most depended-on inside this repo

into
called by 45
server/src/main.rs
index
called by 28
src/plan/hector.rs
merge_with
called by 25
src/lib.rs
binds
called by 23
src/binding/mod.rs
advance_domain
called by 17
src/server/mod.rs
create_transactable_attribute
called by 15
src/domain/mod.rs
is_any_outdated
called by 15
src/server/mod.rs
forward_propose
called by 14
src/server/mod.rs

Shape

Method 214
Function 82
Class 64
Enum 21
Interface 17

Languages

Rust100%

Modules by API surface

src/lib.rs49 symbols
src/server/mod.rs36 symbols
src/plan/hector.rs23 symbols
src/server/scheduler.rs18 symbols
src/plan/mod.rs17 symbols
src/binding/mod.rs17 symbols
src/domain/mod.rs15 symbols
src/timestamp/pair.rs13 symbols
src/timestamp/altneu.rs12 symbols
src/plan/graphql_v2.rs12 symbols
tests/aggregation_test.rs11 symbols
src/plan/graphql.rs10 symbols

For agents

$ claude mcp add declarative-dataflow \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact