Packages

Embedded Relate graph databases for Elixir/OTP applications

Current section

Files

Jump to
relatex docs api elixir description.md
Raw

docs/api/elixir/description.md

# Embedding Relate in Elixir

An application can keep a graph next to the process that consumes it. For example, an agent host can store a tool invocation, its arguments and its observation as connected records. A later session can query the original evidence by session ID. The Elixir process owns the database lifecycle and the engine runs in its BEAM node.

Start an owner for `":memory:"` to get an isolated graph per owner, or pass a directory to retain the graph across restarts. A supervisor can start the owner with `{Relatex, database: path, name: MyApp.Graph}`. Other processes send statements to this name. A batch transaction lets related writes commit together.

Many agents can share a store through this owner. For a bursty workload, configure `max_in_flight: 16` to admit up to sixteen outstanding operations, including the executing query or batch. The owner can reject excess work while the connection is busy. The host chooses whether to shed work, wait and retry, or route an independent workspace to a different database. Relatex continues to submit one operation at a time on the store’s single connection.

Use `mix run docs/api/elixir/examples/observations.exs` for a deterministic example. The repository also includes a live Lemieux example in which two separate agent sessions produce and retrieve tool evidence. [API contract](spec.md) · [Runnable example](https://github.com/houllette/relatex/blob/main/docs/api/elixir/examples/observations.exs) · [Live agent example](https://github.com/houllette/relatex/blob/main/examples/lemieux_memory.exs)