The full database

Barrel

One embeddable edge-AI database. A document, its attachments, and its vector live under one id, so an agent's memory is a single write and a single read.

One record, three shapes

No glue code between a document store and a separate vector index. It is one record.

Document

Schemaless JSON with version-vector MVCC, BQL queries, and a changes feed.

Blobs

Attachments streamed and content-addressed, replicated on their own feed.

Vector

Auto-embedded or bring your own, searchable with vector, BM25, and hybrid.

Record mode

Write text, get an embedding. A policy embeds documents automatically on write.

BQL queries

A PartiQL dialect over documents, vectors, and keyword search, with live subscriptions.

Timeline

Branch a database, restore to a point in time, and merge branches back together.

Encryption at rest

AES-256-GCM, per-database keys, and a pluggable key provider.

Sync and replication

HLC version vectors converge without a coordinator, one-shot or continuous.

Agent layer

Spaces, capability tokens, sessions, and handoffs over REST and MCP.

Run it your way

Embedded

A library in your Erlang or Elixir app. No separate process.

Server

barrel_server exposes REST/JSON and MCP over the same database.

Browser

barrel-lite syncs an offline-first copy into the browser.

Quick Start

%% Open a database; text is auto-embedded into a vector
{ok, _} = barrel:open(<<"notes">>, #{embedding => #{provider => openai}}).

%% One write stores the document, its vector, and its blobs under one id
{ok, _} = barrel:put_doc(<<"notes">>, #{
    <<"id">>    => <<"n1">>,
    <<"title">> => <<"Design review">>,
    <<"text">>  => <<"Ship the edge sync protocol">>
}).

%% Query with BQL
{ok, Rows, _} = barrel:query(<<"notes">>,
    <<"SELECT id, title FROM db WHERE title LIKE 'Design%'">>).

%% Vector search over the same records
{ok, Hits, _} = barrel:query(<<"notes">>,
    <<"SELECT id, _score FROM vector_top_k('edge sync', k => 5) AS v">>).
# barrel_server puts the same database behind REST and MCP.
$ curl -X PUT localhost:8080/db/notes
{"ok":true,"db":"notes"}

$ curl -X PUT localhost:8080/db/notes/doc/n1 \
    -H 'content-type: application/json' \
    -d '{"title":"Design review","text":"Ship the edge sync protocol"}'
{"id":"n1","ok":true,"rev":"0000019f46b4c08900000000@8c0010c983917d4b"}

$ curl localhost:8080/db/notes/doc/n1
{"_rev":"0000019f46b4c08900000000@8c0010c983917d4b","id":"n1","title":"Design review",...}

# Vector search over the very same records.
$ curl -X POST localhost:8080/db/notes/search/vector \
    -H 'content-type: application/json' -d '{"vector":[0.1,0.2,0.3],"k":5}'

When to Use

Use Barrel when:

  • + You want documents, blobs, and vectors under one id
  • + You build agents that need memory and search
  • + You need offline-first or edge deployment
  • + You want to embed the database, not run a cluster

Consider alternatives when:

  • + You need a large distributed cluster
  • + You are committed to a single existing SQL engine
  • + You only need one layer (then use just that library)