Lives anywhere.
Hears everything.

One document database for the page, the phone and the server: screens that follow it live, a copy on the device that works offline, search included, and the rules of your data kept in the database itself.

Get started Try it in the browser

State your screens follow

Keep the app's state in the database and give each screen a live query. A write runs again every query that reads what it wrote, and the screen gets the new rows; nothing calls a redraw. It is for state that outlives a keystroke: keep a text box's typing in the component, and write when the user saves.

const open = db.from('orders')
  .where('customer', customer).where('status', 'open')
  .order('placed', 'desc').limit(20);
const stop = db.live(open, draw);   // again after every write it reads
A page of 50 open todos out of 1 000 to 3 000, run again
0.19 ms
A write no live query reads
about 2 µs

Running a query again is the query itself. State in the page and live queries in Swift, Kotlin and Dart

Local and server, one flow

Open the database on the device as a replica of the rows it needs. Reads never wait for the network. A write shows at once and waits in a queue inside the same file until the server can be reached; then it is sent once, under its Idempotency-Key, and reaches every other screen that follows those rows. The server owns the data: a write it refuses is put back, and there is no CRDT and no merging.

Scenarios the browser's sync and the native one in Swift, Kotlin and Dart are both held to
88offline writes, retries, refusals, dropped streams, restarts

Sync and sync on a phone

The rules live with the data

The page, the phone and an agent reach the database directly, so what the data must obey is kept in it, and every client meets the same rules. A replica's write is checked again by the server, and a write it refuses is put back.

set accounts {balance: balance - $3}
  where name = $1 and balance >= $3
  require 1 else 'insufficient funds'

412 · unmet · "reason": "insufficient funds"

  • Each user, their own rowsA token from Auth0, Clerk or Firebase, held to a policy: owner = $jwt.sub decides the rows and fields each user reads and writes.
  • A write that checks itselfMade only where its condition holds, its writer told why when it does not; in a batch, the rest never runs.
  • One call, its own authorityA named statement runs with its own text's authority: a token granted transfer needs no write rule on the accounts.
  • What a write derives, with itA statement bound to set orders adds the ledger line in the same block: a crash, a replica and a subscriber see both or neither.
  • By the clockevery 1m, or a cron line in a time zone: each slot runs once, and a server down for a day runs the latest slot once.
  • Another service's eventsStripe's and GitHub's webhooks, verified by their signature before anything is read, taken once by their key.

Rules down to the rows, writes that must find their rows, named statements, statements bound to writes, scheduled statements and webhooks from Stripe and GitHub

Security, from the sign-in to the disk

Every request passes the same checks, from the login to the disk. The server speaks HTTPS itself: no proxy in front.

  • Sign in safelyA token for the server, a read-only token for a dashboard. Repeated failures slow down.
  • Your sign-in providerTokens from Auth0, Clerk or Firebase work as they are. Keys rotate without a restart.
  • HTTPS itselfThe server and the router speak HTTPS: no proxy in front.
  • A record of who did whatEvery refusal, schema change and admin action is written to a log.
  • Encrypted backupsBackups and archives are sealed with a key you hold, and so are copies kept in the browser.
  • Little borrowedNo third-party code in the engine. The server's only outside code is TLS — rustls and ring — its tree pinned and checked.

Traffic that needs no cache

The operating system keeps the pages of the file in memory, and a read decodes the row straight from them: no buffer pool of its own to warm, evict or keep in step with the database, so a separate cache in front of the server is usually unnecessary while the working set fits in memory. One write runs at a time and holds the lock for microseconds; its fsync runs after the lock is let go, so writers waiting on the disk share one, and readers take a shared lock and run beside them.

A row by id over HTTP
0.022 msmedian, one client
Rows by id, eight clients at once
149 268/s
YCSB C, all reads, 16 clients, buffered
18.4 k ops/sp99 2.9 ms; Redis 14.0 k, p99 4.0 ms; both in Docker
YCSB B over HTTP, 16 clients, durable
18.2 k ops/sRedis 9.25 k, PostgreSQL 13.0 k, both in Docker; every cell
Cells where Redis did more operations a second
none of 33the same durability mode against the same
Durable writes, 1 writer to 16
252 → 516/sSQLite 248 → 258
Rows read beside four writers
701 000/sSQLite 344 000

The first two figures are over 10 000 rows on loopback, an M1, one POST /query a request on a kept-alive connection (method). The YCSB figures are one node, 1 000 000 records of 1 KB, fennec-server and Redis 7.4 in Docker (every cell). The writes are durable, an fsync each, and four reading threads, in one process on an M1 (method and the rest of the table).

In Docker a read by key spends 0.023 ms inside the server of a 0.288 ms round trip and the rest is the network, so over the same network a cache in front can take off at most the time spent inside the server, and brings an invalidation to keep right. A cache nearer the app than the database is not measured. This holds while the working set fits in memory: past it a read waits for the disk, as in any database (before the file outgrows the page cache). It is about the database’s reads, not an HTTP or CDN response cache. The figures and their conditions and why there is no buffer pool of its own

And the jobs Redis is added for

  • rows that expire, @ttl
  • job queues with leases
  • rate limits
  • locks with fencing tokens
  • counters and leaderboards
  • streams and pub/sub

Each a statement or two a test runs; no LRU eviction, no Lua. Instead of Redis and job queues

Start beside your PostgreSQL

Keep PostgreSQL as the record. fennec-server follows a table over logical replication and serves it: its search, the subscriptions that keep screens live and the replicas on devices. Nothing moves until you want it to.

  • Copied with COPY, then streamed: no psql, no pg_dump.
  • Over TLS, checked as libpq's sslmode says, verify-full by default across a network; signed in by SCRAM bound to the session.
  • The mirror is read-only to clients; writes stay in PostgreSQL.
  • Stopped, the same command resumes where it left off.
$ fennec-server --file articles.fennec --http 0.0.0.0:8080 \
    --http-token "$TOKEN" \
    --follow postgres://app@db:5432/app \
    --follow-table docs --follow-into articles \
    --follow-index "title@text" --follow-index "category@hash"
From a commit in PostgreSQL to a subscriber
0.09 msat the median
From a commit to visible in the file
0.16 msat the median

Import and follow and fennecdb beside PostgreSQL

A file for each tenant, in every region

Give each tenant a file of its own. Nodes hold the files, a router sends each request to its tenant's node, and each tenant has a copy that follows it on another node. With leases the router fails a node over by itself: the node stops writing before its tenants are promoted, so no tenant has two primaries. The limit is plain: one tenant lives whole on one machine.

A 58.7 MB tenant moved
under 0.3 s
Tenants failed over onto a standby
20 in 63.5–79 msthe medians of three rounds
A tenant's copy behind its primary
0.089 msmedian, p99 0.448
Failed over inside a region cut off
1.41–1.70 s10 tenants, a lease of 1 s

Across regions a tenant lives in one, its copy in another datacenter of it, and a region that keeps its own directory fails its nodes over by itself while cut off from the rest. One URL reaches every region, and a read replica near a far client answers its reads, never from before its own write. Tenants and sharding, failover on a lease, regions, one URL for every region, read replicas near the client, replication and a kit to deploy them

Your language, and the SQL you know

Every language reaches the server over plain HTTP and JSON, described by an OpenAPI document any generator reads, which only grows, and Swift, Kotlin and Dart can also keep the database in the app. Your data from SQLite or PostgreSQL — a managed one over TLS — and your AI framework come with it. Each session is the same flow against fennec-server: make a collection, write two rows, read them back by a filter and an order.

SQL is one of them. FennecQL reads SQL's everyday spellings with the same parser — CREATE TABLE, INSERT, SELECT, joins on a key, ON CONFLICT, pgvector's <=> — and what it would answer otherwise than SQL does, it refuses, saying what to write instead. From SQL


      
  1. from fennecdb import Client
    
    db = Client("http://127.0.0.1:8080", token="secret")
    db.query("create collection if not exists docs (title text @text, year int @sorted)")
    db.query("put docs {title: $1, year: $2}", ["Dunes", 2021])
    db.query("put docs {title: $1, year: $2}", ["Night at the oasis", 2024])
    rows = db.query("get docs select title, year where year >= $1 order year desc limit $2", [2020, 5])
  2. import { connect } from '@fennecdb/web';
    
    const db = connect('http://127.0.0.1:8080', { token: 'secret' });
    await db.run('create collection if not exists docs (title text @text, year int @sorted)');
    await db.from('docs').insert({ title: 'Dunes', year: 2021 });
    await db.from('docs').insert({ title: 'Night at the oasis', year: 2024 });
    const rows = await db.from('docs').select('title', 'year').where('year', '>=', 2020).order('year', 'desc').limit(5).rows();
  3. $ fennec app.fennec
    fennecdb 0.2.0 — app.fennec
    `.help` for help, `.quit` to exit
    fennec> CREATE TABLE docs (id serial PRIMARY KEY, title text, year integer);
    collection `docs` created
    fennec> CREATE INDEX docs_year ON docs (year);
    index built on `docs.year`
    fennec> INSERT INTO docs (title, year) VALUES ('Dunes', 2021), ('Night at the oasis', 2024);
    2 records (172.29µs)
    fennec> SELECT title, year FROM docs WHERE year >= 2020 ORDER BY year DESC LIMIT 5;
    title               year
    ------------------  ----
    Night at the oasis  2024
    Dunes               2021
    (2 rows, 300.33µs)
    fennec> SELECT d.title FROM docs d RIGHT JOIN docs e ON e.id = d.id;
    error: query error: position 27: a join is an inner JOIN or a LEFT JOIN, a RIGHT JOIN a LEFT JOIN with its tables the other way round
  4. import fennecdb "github.com/fennec-db/fennecdb/integrations/go"
    
    db := fennecdb.New("http://127.0.0.1:8080", fennecdb.WithToken("secret"))
    db.Exec(ctx, "create collection if not exists docs (title text @text, year int @sorted)")
    db.Exec(ctx, "put docs {title: $1, year: $2}", "Dunes", 2021)
    db.Exec(ctx, "put docs {title: $1, year: $2}", "Night at the oasis", 2024)
    rows, err := db.Query(ctx, "get docs select title, year where year >= $1 order year desc limit $2", 2020, 5)
  5. using FennecDb;
    
    using var db = new FennecClient("http://127.0.0.1:8080", new() { Token = "secret" });
    await db.ExecAsync("create collection if not exists docs (title text @text, year int @sorted)");
    await db.ExecAsync("put docs {title: $1, year: $2}", ["Dunes", 2021]);
    await db.ExecAsync("put docs {title: $1, year: $2}", ["Night at the oasis", 2024]);
    var rows = await db.QueryAsync("get docs select title, year where year >= $1 order year desc limit $2", [2020, 5]);
  6. use serde_json::{json, Value};
    
    fn query(q: &str, params: Value) -> Result<Value, ureq::Error> {
        Ok(ureq::post("http://127.0.0.1:8080/query")
            .set("Authorization", "Bearer secret")
            .send_json(json!({"query": q, "params": params}))?
            .into_json()?)
    }
    query("create collection if not exists docs (title text @text, year int @sorted)", json!([]))?;
    query("put docs {title: $1, year: $2}", json!(["Dunes", 2021]))?;
    query("put docs {title: $1, year: $2}", json!(["Night at the oasis", 2024]))?;
    let rows = query("get docs select title, year where year >= $1 order year desc limit $2", json!([2020, 5]))?;
  7. static HttpResponse<String> query(String json) throws Exception {
        var req = HttpRequest.newBuilder(URI.create("http://127.0.0.1:8080/query"))
            .header("Content-Type", "application/json")
            .header("Authorization", "Bearer secret")
            .POST(HttpRequest.BodyPublishers.ofString(json))
            .build();
        return HTTP.send(req, HttpResponse.BodyHandlers.ofString());
    }
    query("""
        {"query": "create collection if not exists docs (title text @text, year int @sorted)"}""");
    query("""
        {"query": "put docs {title: $1, year: $2}", "params": ["Dunes", 2021]}""");
    query("""
        {"query": "put docs {title: $1, year: $2}", "params": ["Night at the oasis", 2024]}""");
    String rows = query("""
        {"query": "get docs select title, year where year >= $1 order year desc limit $2", "params": [2020, 5]}""").body();
  8. function query(string $q, array $params = []) {
        $ch = curl_init('http://127.0.0.1:8080/query');
        curl_setopt_array($ch, [
            CURLOPT_POST => true,
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_HTTPHEADER => ['Content-Type: application/json', 'Authorization: Bearer secret'],
            CURLOPT_POSTFIELDS => json_encode(['query' => $q, 'params' => $params]),
        ]);
        $body = json_decode(curl_exec($ch), true);
        $status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
        if ($status >= 300) {
            throw new RuntimeException($body['error'], $status);
        }
        return $body;
    }
    query('create collection if not exists docs (title text @text, year int @sorted)');
    query('put docs {title: $1, year: $2}', ['Dunes', 2021]);
    query('put docs {title: $1, year: $2}', ['Night at the oasis', 2024]);
    $rows = query('get docs select title, year where year >= $1 order year desc limit $2', [2020, 5]);
  9. def query(q, params = [])
      req = Net::HTTP::Post.new(URI.join(URL, "/query"), "Content-Type" => "application/json")
      req["Authorization"] = "Bearer secret"
      req.body = JSON.generate(query: q, params: params)
      res = Net::HTTP.start(URL.host, URL.port) { |http| http.request(req) }
      body = JSON.parse(res.body)
      raise "#{res.code}: #{body["error"]}" unless res.is_a?(Net::HTTPSuccess)
      body
    end
    query("create collection if not exists docs (title text @text, year int @sorted)")
    query("put docs {title: $1, year: $2}", ["Dunes", 2021])
    query("put docs {title: $1, year: $2}", ["Night at the oasis", 2024])
    rows = query("get docs select title, year where year >= $1 order year desc limit $2", [2020, 5])
  10. import FennecDB
    
    // Or Fennec.open(path: path): the database in a file the app holds.
    let db = Fennec.connect(url: "http://127.0.0.1:8080", token: "secret")
    try await db.execute("create collection if not exists docs (title text @text, year int @sorted)")
    try await db.execute("put docs {title: $1, year: $2}", "Dunes", 2021)
    try await db.execute("put docs {title: $1, year: $2}", "Night at the oasis", 2024)
    let rows = try await db.query("get docs select title, year where year >= $1 order year desc limit $2", 2020, 5)
  11. import com.fennecdb.*
    
    // Or Fennec.openAsync(path): the database in a file the app holds.
    val db = Fennec.connect("http://127.0.0.1:8080", token = "secret")
    db.execute("create collection if not exists docs (title text @text, year int @sorted)")
    db.execute("put docs {title: \$1, year: \$2}", "Dunes", 2021)
    db.execute("put docs {title: \$1, year: \$2}", "Night at the oasis", 2024)
    val rows = db.query("get docs select title, year where year >= \$1 order year desc limit \$2", 2020, 5)
  12. import 'package:fennecdb/fennecdb.dart';
    
    // Or Fennec.open(path): the database in a file the app holds.
    final db = Fennec.connect('http://127.0.0.1:8080', token: 'secret');
    await db.execute('create collection if not exists docs (title text @text, year int @sorted)');
    await db.execute(r'put docs {title: $1, year: $2}', ['Dunes', 2021]);
    await db.execute(r'put docs {title: $1, year: $2}', ['Night at the oasis', 2024]);
    final rows = await db.query(r'get docs select title, year where year >= $1 order year desc limit $2', [2020, 5]);
  13. $ fennec-server --file app.fennec --http 127.0.0.1:8080 --http-token secret
    $ curl -X POST localhost:8080/query -H 'authorization: Bearer secret' \
      -d '{"query":"create collection docs (title text @text, year int @sorted)"}'
    {"message":"collection `docs` created"}
    $ curl -X POST localhost:8080/query -H 'authorization: Bearer secret' \
      -d '{"query":"put docs {title: $1, year: $2}","params":["Dunes",2021]}'
    {"affected":1}
    $ curl -X POST localhost:8080/query -H 'authorization: Bearer secret' \
      -d '{"query":"put docs {title: $1, year: $2}","params":["Night at the oasis",2024]}'
    {"affected":1}
    $ curl -X POST localhost:8080/query -H 'authorization: Bearer secret' \
      -d '{"query":"get docs select title, year where year >= $1 order year desc limit $2","params":[2020,5]}'
    [{"title":"Night at the oasis","year":2024},{"title":"Dunes","year":2021}]
  14. $ fennec import data.sqlite --table docs --into articles --index "category@hash" --dry-run
    source   data.sqlite -> docs
    target   articles.fennec -> articles
    
    create collection articles (
      title      text           <- text
      category   text           <- text
      score      int            <- int
      published  timestamp      <- datetime
    )
      id  <- id (INTEGER PRIMARY KEY)
    create index on articles (category) @hash
    
    nothing was written (--dry-run); use --count for the row count
  15. $ fennec import postgres://app@db:5432/app --table docs --into articles \
        --index "category@hash" --follow
    source   app@db:5432/app -> docs
    target   articles.fennec -> articles
    follow   slot fennec_articles (created), publication fennec_articles (created)
    note     the slot keeps the server's WAL until this follower confirms it; to stop following for good: select pg_drop_replication_slot('fennec_articles')
    copying  there is none yet
    100000 records, articles.fennec (339.37ms)
    following docs: ctrl-c stops, and the same command resumes
    42 transactions, 57 changes, at 0/2BEA458
  16. from fennecdb.langchain import FennecVectorStore
    store = FennecVectorStore(
        embeddings, "handbook",
        url="http://127.0.0.1:8080", token="...",
        metadata_fields={"source": "text", "year": "int"},
    )
    store.add_documents(documents)
    store.similarity_search("how do I compact", k=4, filter={"source": "ops"})
  17. from fennecdb.llama_index import FennecVectorStore
    from llama_index.core import StorageContext, VectorStoreIndex
    store = FennecVectorStore("handbook", url="http://127.0.0.1:8080", token="...",
                             metadata_fields={"author": "text", "year": "int"})
    index = VectorStoreIndex.from_documents(
        documents, storage_context=StorageContext.from_defaults(vector_store=store)
    )
    index.as_retriever(similarity_top_k=4).retrieve("how do I compact")
  18. import { connect } from '@fennecdb/web';
    import { FennecVectorStore } from '@fennecdb/langchain';
    const db = connect('http://127.0.0.1:8080');
    const store = new FennecVectorStore(embeddings, {
      client: db,
      collection: 'handbook',
      metadataFields: { source: 'text' },
      fullText: true,
    });
    await store.addDocuments(documents);
    await store.search('compact', 4, { mode: 'hybrid' });
  19. import { generateText, stepCountIs } from 'ai';
    import { openai } from '@ai-sdk/openai';
    import { connect } from '@fennecdb/web';
    import { index, searchTool } from './rag.js';   // integrations/ai-sdk/rag.js
    const db = connect('http://127.0.0.1:8080', { token: 'secret' });
    const model = openai.textEmbeddingModel('text-embedding-3-small');
    await index(db, { collection: 'docs', model, documents });
    
    const { text } = await generateText({
      model: openai('gpt-4.1'),
      tools: { search: searchTool(db, { collection: 'docs', model }) },
      stopWhen: stepCountIs(4),
      prompt: 'How do I compact the database?',
    });

Each language's example runs against a real server on every change, and Python, JavaScript, Go and .NET have official clients. An agent reaches the same server over MCP, each tool held to the token's rules, and fennec studio shows the rows, the schema and the live numbers in a browser, or in its app for Mac, Windows and Linux. Examples in your language, from SQL, MCP, fennec studio, the database in an app, every integration and import

A first query in a few commands

Open it in a web page from npm, keep it in an app's file, or start the server from the Docker image or a release — for Linux, macOS or Windows — and send it a request from the language you already use. Or clone one small app, the same in every language, and run it.

Get started Download Read the docs See the examples