Skip to content
Fact logo

Open source · Elixir

Fact

v0.4.1

A file-system event-sourcing database engine for Elixir.

Events are files. Inspect them with grep, jq, sed — no black boxes, no proprietary format.

01 / Install

Add one line to mix.exs.

defp deps do
  [
    {:fact, "~> 0.4.1"}
  ]
end

Requirements

Elixir 1.13+ · OTP 25+

Or grab it from hex.pm/packages/fact.

02 / Quickstart

Five steps to a running event store.

Step 01

Create a database

A Fact database is a directory on disk. Create one with the included Mix task.

$ mix fact.create -p tmp/factdb

Step 02

Open

Open the database by path. You get back a handle you'll use for every subsequent call.

{:ok, db} = Fact.open("tmp/factdb")

Step 03

Append an event to a stream

Events carry a :type and an optional :data payload. append_stream/5 writes one or many into a named stream.

{:ok, _pos} =
  Fact.append_stream(
    db,
    %{type: "Registered", data: %{email: "ada@example.com"}},
    "user-123"
  )

Step 04

Read

Read events back. See the Fact module for stream-scoped reads, filters, and subscribing.

Fact.read(db, :all)

Step 05

Supervise it

In production, put Fact under your application's supervision tree.

children = [
  {Fact.Supervisor, databases: ["tmp/factdb"]}
]

Supervisor.start_link(children, strategy: :one_for_one)

03 / Features

What's in the box.

Append-only streams & global ledger

Per-stream event logs plus a global ledger for cross-stream ordering. Writes are immutable by design.

Built-in indexing

Query by stream, event type, tags, and data fields. Bring your own custom indexer when the defaults aren't enough.

Crash-safe writes

A write-ahead log keeps the database consistent across unexpected shutdowns and partial writes.

Tamper detection

Merkle Mountain Range over the event log makes silent corruption and after-the-fact edits detectable.

Transparent storage

Events live on disk as plain files in a deterministic layout. Inspect them with the tools you already use.

DCB compliant

Dynamic Consistency Boundary support with data-field query extensions — model aggregates the way your business thinks.

Encryption at rest

Optional AES-256-GCM encryption for events stored on disk, for workloads that require it.

Subscribe & project

Stream events into your own projections, read models, and integrations with a straightforward subscription API.

04 / Links

Dig in.