Barrel

July 13, 2026 ยท View on GitHub

Barrel is an embeddable edge-AI database for Erlang: documents, their attachments (blobs), and their vectors under one id, with local vector and keyword search, encryption at rest, branching/PITR, replication, and an agent layer. This umbrella groups the applications so they develop and release together, while each stays a standalone OTP application with its own public API.

Applications

AppPathResponsibility
barrelapps/barrelThe embeddable database. Composes docdb + vectordb + crypto so a document, its blobs, and its vector share one id. Record mode, timeline (branch/PITR/merge), BQL. Pulls no transports.
barrel_docdbapps/barrel_docdbThe document layer. HLC version-vector MVCC, changes feed, replication, attachments (blobs), TTL, retained history, BQL query. Standalone embedded document database.
barrel_vectordbapps/barrel_vectordbThe vector layer. Local ANN indexes (HNSW, DiskANN, FAISS), BM25, hybrid search, quantization. Standalone embedded vector database.
barrel_embedapps/barrel_embedEmbedding generation across providers (local Python, Ollama, OpenAI, and more). Used by barrel_vectordb for text and hybrid search.
barrel_rerankapps/barrel_rerankCross-encoder reranking. Optional, used by barrel_vectordb.
barrel_cryptoapps/barrel_cryptoEncryption-at-rest primitives: AES-256-GCM envelope, offset-addressable CTR, HKDF key derivation, key providers.
barrel_spacesapps/barrel_spacesThe agent layer: spaces (shared context databases), capability tokens, sessions with TTL, and handoffs.
barrel_serverapps/barrel_serverThe network server. Exposes barrel over HTTP (REST/JSON) and MCP using livery. Opt-in behind the server profile.
barrel_faissapps/barrel_faissErlang NIF bindings for FAISS. Optional; needs the FAISS C++ library, so it is excluded from the default build.

Dependency direction (no cycles): barrel_server -> {barrel, barrel_spaces}; barrel_spaces -> {barrel, barrel_docdb, barrel_crypto}; barrel -> {barrel_docdb, barrel_vectordb, barrel_crypto}; barrel_vectordb -> {barrel_embed, barrel_crypto} (optionally barrel_faiss, barrel_rerank); barrel_docdb -> barrel_crypto. Leaves: barrel_crypto, barrel_embed, barrel_rerank, barrel_faiss.

Build

You need Erlang/OTP, rebar3, CMake, and a C/C++ compiler (the barrel_vectordb NIF is built with CMake).

rebar3 compile

This builds the default app set (barrel_crypto, barrel_docdb, barrel_vectordb, barrel_embed, barrel_rerank, barrel, barrel_spaces). barrel_faiss and barrel_server are opt-in:

rebar3 as faiss compile      # add the FAISS NIF app
rebar3 as server compile     # add the HTTP/MCP server

Test

rebar3 eunit             # unit tests
rebar3 ct                # Common Test suites
rebar3 as server ct      # the HTTP/MCP server (opt-in profile)

Development shell

rebar3 shell             # starts the embeddable stack
rebar3 as server shell   # starts barrel_server

Standalone use

Each application stays a valid OTP application usable on its own. You can embed barrel (the full database) directly with no transports, or use barrel_docdb and barrel_vectordb as standalone embedded databases, without a server, remote replication, or any cluster fabric.

Documentation

License

Apache-2.0. See the LICENSE file at the repository root and in each app directory.