12 releases (4 breaking)

new 0.5.0 Jan 10, 2025
0.4.1 Dec 28, 2024
0.4.0-alpha.3 Nov 29, 2024
0.1.2 Dec 31, 2020
0.1.1 Nov 24, 2020

#1 in #knowledge-graph

Download history 57/week @ 2024-09-18 13/week @ 2024-09-25 6/week @ 2024-10-02 127/week @ 2024-10-16 319/week @ 2024-10-23 73/week @ 2024-10-30 55/week @ 2024-11-06 125/week @ 2024-11-20 431/week @ 2024-11-27 532/week @ 2024-12-04 923/week @ 2024-12-11 251/week @ 2024-12-18 271/week @ 2024-12-25 156/week @ 2025-01-01

1,621 downloads per month

MIT license

470KB
8K SLoC

Crates.io Version docs.rs Discord Shield

🚧🚧🚧 Please note that this is work in progress, so while a lot of things have settled by now, we still favour breaking backwards compatiblity for seeminly minor improvements. 🚧🚧🚧

The mascot of the trible.space a cute fluffy trible with three eyes.

About

“Insufficient facts always invite danger.”
Mr. Spock

Trible Space is a data space and knowledge graph standard. It offers metadata management capabilities similar to file- and version-control systems, combined with the queryability and convenience of an embedded database, tailored towards use with simple blob storage. It is designed to be a holistic yet lightweight data storage solution that can be used in a variety of contexts, from embedded systems to distributed cloud services.

Our goal is to re-invent data storage from first principles and overcome the shortcomings of prior "Semantic Web"/triple-store technologies. By focusing on simplicity, canonical data formats, cryptographic identifiers, and clean distributed semantics, we aim to provide a lean, lightweight yet powerful toolkit for knowledge representation, database management, and data exchange use cases.

Features

  • Lean, Lightweight & Flexible: Data storage seamlessly scales from in-memory data organization to large-scale blob and metadata storage on S3 like services.
  • Distributed: Eventually consistent CRDT semantics (based on the CALM principle), compressed zero-copy archives (WIP), and built-in version control.
  • Predictable Performance: An optimizer-free design using novel algorithms and data structures removes the need for manual query-tuning and enables single-digit microsecond latency.
  • Fast In-Memory Datasets: Enjoy cheap copy-on-write (COW) semantics and speedy set operations, allowing you to treat entire datasets as values.
  • Compile-Time Typed Queries: Safer data handling, plus handy features like query diffs.
  • Low Overall Complexity: We aim for a design that feels obvious (in the best way) and makes good use of existing language facilities. A serverless design makes it completely self-sufficient for local use and requires only an S3-compatible service for distribution.
  • Easy Implementation: The spec is designed to be friendly to high- and low-level languages, or even hardware implementations.

Community

If you have any questions or want to chat about graph databases hop into our discord.

Example

use tribles::prelude::*;
use tribles::prelude::valueschemas::*;
use tribles::prelude::blobschemas::*;

NS! {
    pub namespace literature {
        "8F180883F9FD5F787E9E0AF0DF5866B9" as author: GenId;
        "0DBB530B37B966D137C50B943700EDB2" as firstname: ShortString;
        "6BAA463FD4EAF45F6A103DB9433E4545" as lastname: ShortString;
        "A74AA63539354CDA47F387A4C3A8D54C" as title: ShortString;
        "76AE5012877E09FF0EE0868FE9AA0343" as height: R256;
        "6A03BAF6CFB822F04DA164ADAAEB53F6" as quote: Handle<Blake3, LongString>;
    }
}

fn main() -> std::io::Result<()> {
    let mut blobs = BlobSet::new();
    let mut set = TribleSet::new();

    let author_id = ufoid();

    // Note how the entity macro returns TribleSets that can be cheaply merged
    // into our existing dataset.
    set += literature::entity!(&author_id, {
                firstname: "Frank",
                lastname: "Herbert",
            });

    set += literature::entity!({
                title: "Dune",
                author: &author_id,
                quote: blobs.insert("Deep in the human unconscious is a \
                pervasive need for a logical universe that makes sense. \
                But the real universe is always one step beyond logic."),
                quote: blobs.insert("I must not fear. Fear is the \
                mind-killer. Fear is the little-death that brings total \
                obliteration. I will face my fear. I will permit it to \
                pass over me and through me. And when it has gone past I \
                will turn the inner eye to see its path. Where the fear \
                has gone there will be nothing. Only I will remain.")
            });

    let title = "Dune";

    // We can then find all entities matching a certain pattern in our dataset.
    for (_, f, l, q) in find!(
        (author: (), first: String, last: Value<_>, quote),
        literature::pattern!(&set, [
            { author @
                firstname: first,
                lastname: last
            },
            {
                title: (title),
                author: author,
                quote: quote
            }])) {
        let q: &str = blobs.get(q).unwrap();

        println!("'{q}'\n - from {title} by {f} {}.", l.from_value::<&str>())
    }
    Ok(())
}

Getting Started

The best way to get started is to read the module documentation of the tribles crate. The following links provide an overview of the most important modules, in an order where you can start with the most basic concepts and work your way up to more advanced topics:

  1. Prelude
  2. Identifiers
  3. Values
  4. Blobs
  5. Tribles
  6. Namespaces
  7. Queries
  8. Remotes
  9. Predefined Value Schemas
  10. Predefined Blob Schemas

Dependencies

~83MB
~1M SLoC