Zef Documentation

website·Indexed 31 days ago

https://zef.zefhub.io/

A library and database system featuring ZefDB for graph-based data management, ZefOps for interactive data exploration, and SimpleGQL for GraphQL schema integration. It provides a declarative approach to data wrangling using Zef Objects, Z-Expressions, and a specialized type system including representation and logic types.

Tokens
76.1K
Snippets
451
Records
592
Agent score
60%

What's inside Zef

  1. Overview of Zef's capabilities

    Zef is a data-oriented tool for Python that unifies databases, real-time streaming data, and managed effects. It is designed to simplify the creation of modern real-time reactive web applications. It can be used in two ways: as a library, where individual parts are incrementally adopted by importing them locally, or as a framework for building end-to-end reactive applications and distributed computation (similar to Elixir).
  2. Overview of Zef-FX Functional Effect System

    Zef-FX is a Python library that implements a functional effect system. Instead of eagerly executing side effects (procedural effects) within functions, Zef-FX allows developers to describe the desired interaction with the outside world using an immutable data structure called a "wish" (typically a dictionary).

    By returning these descriptions rather than executing the effects, developers can:

    • Convert impure functions into pure functions.
    • Give the caller control over whether to execute, discard, or forward the effect.
    • Improve testability by removing the need for mocks and stubs.
    • Move side effects to the "imperative shell" (the outer boundaries of the application), keeping the core logic as a functional core.
  3. Overview of Zef and ZefHub

    Zef is an open-source, data-oriented toolkit for graph data, licensed under Apache 2.0. It is designed for developers who need to work with graph data, versioned graphs, and data streams without managing complex distributed infrastructure. ZefHub is the venture-backed startup that creates and maintains Zef, providing a real-time storage, synchronization, and distribution service for Zef graphs.
  4. Overview of ZefDB Write Model

    ZefDB processes writes transactionally via a queue. Depending on the deployment, writes can be processed from the same process (embedded mode) or remotely.
  5. Overview of the Zef Structural Type System

    The Zef Type System is structural, meaning types obey value semantics and do not have a unique identity. It treats types as 'logic types'—sets of values that fulfill specific constraints—similar to the approach used in languages like Haskell, TypeScript, or modern Python typing.
  6. Understand ZefDB Single Transactor and Strong Consistency

    ZefDB employs a Single Transactor architecture where at most one transactor exists for a given graph at any point in time. The transactor runs on a single thread and manages the committing of transactions. A transaction only closes once data is written and verified, ensuring that transactions are linearizable and maintain a well-defined order.
  7. Understand Zef's low-level graph data layout

    Zef implements its graph as an append-only, consecutive in-memory structure consisting of a sequence of 'blobs'.

    Key concepts include:

    • Blob: The low-level object representing nodes and edges. Unlike the high-level structure, the low-level structure is 'timeless' (reference-less).
    • Chunk: The smallest division of memory, currently 16 bytes. A 'blob index' refers to the index of these chunks.
    • Metagraph: While high-level entities and relations can connect flexibly, the low-level view is a standard graph where edges (integers in edge lists, source/target indices) connect to nodes (blobs), and only nodes contain metadata.
  8. Understand the Zef Graph data model

    Zef uses a "meta-graph" data model where every piece of information is represented associatively as a relation. Unlike property graphs or relational databases, Zef's Relation/Entity/Atomic Entities (RAEs) have no internal structure or attributes. Instead, all attributes are modeled as separate entities connected by relations. This eliminates the need for a fixed schema or hierarchical taxonomy, allowing the domain model to evolve without costly data migrations. Because relations themselves can have relations pointing to them, Zef is categorized as a meta-graph rather than a simple directed graph or a hypergraph.
  9. Understand Zef's set-theoretic type system

    Zef's type system is based on set theory. In this model, a type is viewed as a set of constraints applied to all possible values, resulting in a specific set of valid values. This approach allows types to be used as declarative queries, where specifying a type is equivalent to specifying the conditions for the results you are looking for.
  10. Understand ZefDB event types and state relationship

    ZefDB represents database changes as a set of 'DB Events'. The DB state (a typed meta-graph) and these events are complementary: a minimal set of events can be derived from any two states, and a resulting state can be computed from an initial state and a set of events. Events are used to track changes, while state is used for point-in-time queries and traversals.
  11. Understand Zef logical types for Lists and Tuples

    In Zef, zef.List and zef.Tuple describe the logical form of data rather than its physical representation. This differs from standard Python types where list implies a mutable, contiguous storage of pointers and tuple implies immutability. A value in Zef can satisfy both List and Tuple logical types depending on its structure.