# 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.

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)
