Quickstart

Run mimicd and PostgreSQL on your machine with Docker Compose, and create a first database, collection and database key.

This page runs mimicd and a PostgreSQL 18 on your machine with Docker Compose, and creates a database, a collection and a database key. For anything you intend to keep, read Requirements and Topologies first.

You need Docker Engine 25 or later with Compose 2.24.1 or later, git, curl and openssl. To run the binary without Docker, see Running mimicd.

Get the repository

git clone https://github.com/voidhashcom/mimic-db
cd mimic-db

The commands below run from the repository's root, which holds the mimicd/ directory.

Make the two passwords

The Compose file has no default passwords. Make them in mimicd/.env, readable by you alone: the superuser's (MIMIC_BOOTSTRAP_PASSWORD) and the one mimicd signs in to PostgreSQL with (MIMIC_POSTGRES_PASSWORD):

(umask 077 && set -C && printf 'MIMIC_BOOTSTRAP_PASSWORD=%s\nMIMIC_POSTGRES_PASSWORD=%s\n' \
  "$(openssl rand -base64 32)" "$(openssl rand -hex 24)" > mimicd/.env)

Keep this file: it holds the only copy of the superuser's password, and set -C refuses to overwrite one that exists.

Start it

docker compose -f mimicd/compose.yaml up -d --build
docker compose -f mimicd/compose.yaml ps

The first build compiles the document core in Rust and takes several minutes; later builds reuse it. PostgreSQL starts first, then mimicd, which applies its schema, founds the deployment and creates the superuser admin. Both services read healthy once they serve. The API is plain HTTP on 127.0.0.1:7700.

Create a database

Databases, collections and keys are created through the administration API (/v1/admin) as a superuser. This helper hands the password to curl on its standard input, never on its command line:

password=$(sed -n 's/^MIMIC_BOOTSTRAP_PASSWORD=//p' mimicd/.env)
admin() { printf 'user = "admin:%s"\n' "$password" | curl -fsS -K - "$@"; }

The server gives a database no name: you draw its id, 32 lowercase hexadecimal digits, and name its budget group and its number of partitions, which is fixed for its life:

DB=$(openssl rand -hex 16)
admin -X PUT -H 'Content-Type: application/json' \
  -d '{"budget_group": "default", "partitions": 2}' \
  "http://127.0.0.1:7700/v1/admin/databases/$DB"
admin "http://127.0.0.1:7700/v1/admin/databases/$DB"
{
  "id": "0f3c2a9e8b7d4c1a9e2f3b4c5d6e7f80",
  "budget_group": "default",
  "partitions": 2,
  "ready": true
}

Sending the same PUT again changes nothing, so a call whose answer was lost can be retried as it was.

Create a collection

A collection also has an id you draw, a name and a schema:

COLLECTION=$(openssl rand -hex 16)
admin -X PUT -H 'Content-Type: application/json' \
  -d '{"name": "notes", "schema": {"kind": "object", "fields": {"title": {"kind": "string"}}}}' \
  "http://127.0.0.1:7700/v1/admin/databases/$DB/collections/$COLLECTION"

The schema is the serialized form of a mimic-core schema. Applications make it from their primitives with serializeSchema(primitive.schema), as the application quickstart does; see Schemas.

Create a database key for your backend

An application's backend should not use the superuser. Give it a database key limited to the one database:

admin -X POST -H 'Content-Type: application/json' \
  -d '{"name": "backend", "permission": "write"}' \
  "http://127.0.0.1:7700/v1/admin/databases/$DB/keys"
{ "id": "bd489947470611d1d01919c3df5a3c4a", "key": "mk_…" }

key is returned this once: the server keeps only a digest of it. A backend sends it as Authorization: Bearer mk_….

Use it

The deployment is now ready for the application quickstart. A page served from another origin may call the API only if the deployment allows that origin. Allow it with the setting cors_origins, which every process follows within a second, without a restart:

docker compose -f mimicd/compose.yaml exec mimicd \
  mimicd admin settings set cors_origins=http://localhost:5173

Operator commands run in the running container, which has the store's URL in its environment. docker compose run would start a second server instead.

docker compose -f mimicd/compose.yaml down stops both containers and keeps the data, in the postgres volume; up -d starts them on it again. down -v deletes the data.

Keep it

  • TLS. Never publish the plain HTTP port beyond the loopback. Put a proxy that terminates TLS in front of it, or let mimicd serve TLS itself with a certificate it orders by ACME. See Network and TLS.
  • Backups. Nothing is backed up until you name a destination: mimicd admin settings set backup_destination=s3://acme-backups/mimic, with the bucket's credentials in the server's environment. PostgreSQL's own backups are yours too. See Backups and restores.
  • PostgreSQL. For a deployment you keep, run PostgreSQL with a standby and point-in-time recovery, or use a managed one: see PostgreSQL stores.

Next