Skip to content

A ledger of what happened, told back in words.

Your applications push machine events — USER_LOGIN, TICKET_CLOSED, CPU_LOAD. memento keeps them as an immutable, tenant-isolated ledger and serves them back per entity, per actor, as a feed or a live stream, each one rendered as a sentence in the reader's language.

docker compose -f docker-compose.yaml up -d
POST /memento/events
{"event_type": "USER_LOGIN",
 "instance_type": "user", "instance_id": 42,
 "actor_id": "igor"}
en
User igor logged in.
sr
Korisnik igor se prijavio.

One event, every way to read it

An application says what happened, once. memento stores it as an immutable row of its tenant and hands it back however the reader asks: as one object's history, as a sentence in the reader's language, through a query, or the moment it happens. Real requests to the stage service; ids shortened.

POST /memento/events the application sends

{
"event_type": "USER_LOGIN",
"instance_type": "user",
"instance_id": 42,
"actor_id": "igor",
"payload": { "method": "password", "client": "web" }
}

201 Created memento stores and renders it

{
"ok": true,
"data": {
"id": "0cba06fc…",
"occurred_at": "2026-11-02T00:41:20.166Z",
"received_at": "2026-11-02T00:41:20.169Z",
"event_type": "USER_LOGIN",
"instance_type": "user",
"instance_id": "42",
"actor_id": "igor",
"payload": { "client": "web", "method": "password" },
"rendered": "User igor logged in.",
"rendered_locale": "en",
"archived_at": null,
"api_key_id": "44cebcf6…"
}
}

GET /memento/entities/user/42/events what happened to user 42

{
"ok": true,
"data": [
{
"id": "0cba06fc…",
"occurred_at": "2026-11-02T00:41:20.166Z",
"received_at": "2026-11-02T00:41:20.169Z",
"event_type": "USER_LOGIN",
"instance_type": "user",
"instance_id": "42",
"actor_id": "igor",
"payload": { "client": "web", "method": "password" },
"rendered": "User igor logged in.",
"rendered_locale": "en",
"archived_at": null,
"api_key_id": "44cebcf6…"
}
],
"meta": {
"limit": 1,
"count": 1,
"next_cursor": "WyIyMDI2LTExLTAyVDAwOjQxOjIwLjE2NloiLCIwY2JhMDZmYy1kM2VhLTQ5ODItYTVlMi02Zjg4ZWM2N2Q0YTIiXQ"
}
}

The examples, live

Real screenshots of the examples site: eight pages over one tenant that a CPU monitor and a ticket desk simulator keep writing to. Every list on them is a UDC collection; every page follows the live stream.

  1. A live table of CPU_LOAD samples of server/stage, with the stream's Live badge

    CPU monitor/examples/cpu-monitor

    The CLI pushes this machine's load every second; the cpu_load UDC collection draws it as a live table and chart.

  2. A feed of rendered sentences: notes, ticket changes and chat messages with avatars

    Activity feed/examples/activity

    Every event of the tenant as the sentence memento rendered, newest on top, in the header's language.

  3. The timeline of one ticket: its notes, modifications, creation and closing, newest on top

    Entity timeline/examples/entity

    What happened to one ticket: its create, modify, note and close story, read through UDC, live.

  4. A chat room with messages in English and Serbian and Seen by markers

    Chat/examples/chat

    The simulator's demo room in MementoChat, seen as one participant, with who has read what.

  5. Raw WebSocket frames, one line per event, under the stream's filter form

    Live tail/examples/tail

    Every frame of /memento/ws as it arrives, with the stream's filters in the URL: memento tail in the browser.

  6. A TICKET_CLOSED event with its English and Serbian templates and the two rendered sentences

    Rendering & translations/examples/rendering

    One event, its bundled EN and SR templates, and the sentence the server renders from each.

  7. A line chart of events per minute per event type over the last hour

    Activity chart/examples/chart

    Events per minute by type, counted by the server (the activity collection), drawn by the chart renderer.

The API: JSON over HTTP, one key

Every answer is an envelope: {ok: true, data, meta} or{ok: false, error} with a code, a message and the details. A bearer API key belongs to one tenant and carries the scopes read andwrite; nothing in a request can name another tenant.

/mementoscope
POST /eventswritepush an event
GET /eventsreadlist, newest first, cursor paging
POST /events/queryreadlist with the Filter DSL
GET /entities/:type/:id/eventsreadone object's history
GET /describereadwhat this server offers the key
GET /wsreadthe live stream (WebSocket)
POST /udc/<action>readUDC collections: events, cpu_load, activity, menu
… /chats…read · writechats: rooms, messages, who has read what
GET /api/health—liveness, no key

Every route, parameter and error code in docs/API.md

POST /memento/udc/list the list side, in the UDC protocol

{
"collection": "cpu_load",
"filter": { "field": "instance_id", "op": "eq", "value": "stage" },
"sort": [{ "field": "occurred_at", "dir": "desc" }],
"page": { "limit": 1 }
}

200 OK a UDC answer: its kind says ok or err

{
"kind": "udc.list.ok",
"id": "",
"payload": {
"rows": [
{
"__meta": { "id": "afc33f2d…", "version": 1 },
"occurred_at": "2026-11-02T00:41:19.588Z",
"instance_type": "server",
"instance_id": "stage",
"load_1min": 6.9,
"load_5min": 7.16,
"load_15min": 7.86,
"rendered": "Server stage — CPU: 6.9, 7.16, 7.86"
}
],
"next_cursor": null,
"total": 95492
}
}

422 a push memento refuses

{
"ok": false,
"error": {
"code": "validation_error",
"message": "invalid event",
"details": [
{
"origin": "string",
"code": "invalid_format",
"format": "regex",
"pattern": "/^[A-Z][A-Z0-9_]*$/",
"path": ["event_type"],
"message": "event_type must be SCREAMING_SNAKE_CASE (e.g. USER_LOGIN)"
}
]
},
"request_id": "048b0b5e…"
}

Start where you are

Run your own memento in Docker or on one SQLite file, borrow ours with a key, put it inside the Fastify app you already have, or draw a tenant's events in React. Every command here has been run as written.

Terminal
git clone https://github.com/digital-cube/jsmemento.git && cd jsmemento
# .env next to docker-compose.yaml: a database password, and the release to run
# (:latest is the newest release, :main the newest commit)
cat > .env <<'ENV'
POSTGRES_PASSWORD=change-me
MEMENTO_IMAGE=ghcr.io/digital-cube/jsmemento:1.1.0
ENV
# memento with PostgreSQL 18 and Redis 7; --wait returns once their health checks pass
docker compose -f docker-compose.yaml up -d --wait memento
curl localhost:3000/memento/api/health
# a tenant, and an API key of it with both scopes: the mk_… secret is printed this once
docker compose -f docker-compose.yaml exec memento memento create-tenant acme --name "Acme Inc"
docker compose -f docker-compose.yaml exec memento \
memento create-key --tenant acme --scopes read,write --name backend
export MEMENTO_API_KEY=mk_… # what create-key printed
curl -X POST localhost:3000/memento/events -H "Authorization: Bearer $MEMENTO_API_KEY" \
-H 'content-type: application/json' \
-d '{"event_type":"USER_LOGIN","instance_type":"user","instance_id":42,"actor_id":"igor"}'
curl "localhost:3000/memento/entities/user/42/events?locale=sr" \
-H "Authorization: Bearer $MEMENTO_API_KEY"
What it prints
Container jsmemento-redis-1 Healthy
Container jsmemento-postgres-1 Healthy
Container jsmemento-memento-1 Healthy
{"ok":true,"data":{"status":"ok"}}
created tenant acme (Acme Inc) id=40c1b5bc-0c20-40e2-b00a-b88dc9e3b4e5
created key "backend" for acme [read,write]
prefix: 27lho6hx
key: mk_27lho6hx_…
Store it now: it cannot be shown again.
{"ok":true,"data":{"id":"ee41fd55-c7f5-4dfa-991e-b486e6591a4d","occurred_at":"2026-11-02T00:27:43.402Z","received_at":"2026-11-02T00:27:43.430Z","event_type":"USER_LOGIN","instance_type":"user","instance_id":"42","actor_id":"igor","payload":{},"rendered":"User igor logged in.","rendered_locale":"en","archived_at":null}}
{"ok":true,"data":[{"id":"ee41fd55-c7f5-4dfa-991e-b486e6591a4d","occurred_at":"2026-11-02T00:27:43.402Z","received_at":"2026-11-02T00:27:43.430Z","event_type":"USER_LOGIN","instance_type":"user","instance_id":"42","actor_id":"igor","payload":{},"rendered":"Korisnik igor se prijavio.","rendered_locale":"sr","archived_at":null}],"meta":{"limit":50,"count":1,"next_cursor":null}}
  1. Docker with Compose. The stack is docker-compose.yaml: memento, PostgreSQL 18, Redis 7, named volumes and health checks.
  2. The server applies its migrations when it starts; the CLI is in the image (memento …).
  3. The examples site is served at localhost:3000/, the API under /memento.
The whole way, step by step, on Get started

Five packages, one image, eight clients

One monorepo, one version line. Every release tag puts the packages on npm and the image on GitHub's registry, which also carries the image of every commit of main; the source isthe repository.

  • @jsmemento/core

    The protocol: the event and envelope schemas, the Filter DSL, the HTTP client and MementoStream.

    1.1.0on npm
  • @jsmemento/server

    The Fastify app and plugin: storage on PostgreSQL or one SQLite file, tenants and keys, templates, /ws, UDC collections, accounts.

    1.1.0on npm
  • @jsmemento/cli

    memento: migrations, tenants, keys, templates, chats, lookups, a live tail, the CPU monitor and the simulator.

    1.1.0on npm
  • @jsmemento/react

    MementoProvider, the live MementoDataView, MementoChat and MementoSearch.

    1.1.0on npm
  • @jsmemento/lookups

    The vocabulary of lookups.yaml: event, instance and actor types, translations, candidates, codegen.

    1.1.0on npm

ghcr.io/digital-cube/jsmementov1.1.0 released

Multi-arch (amd64, arm64), with a build provenance attestation. The server, the CLI, the examples site and the service site in one image.

1.1.0, 1.1, 1, latestthe release tag v1.1.0 (latest: the newest tag)
main, edgethe newest commit on main
sha-<short>that commit

Client programs

One complete program per language, plain HTTP and a WebSocket, no SDK:JavaScript, TypeScript, Python, PHP, Java, Rust, Go, C++.

MIT licence.

v1.1.0released built 663143e