Documentation

stateledger docs

What is stateledger?

stateledger is a database-backed finite state machine for Node.js and TypeScript. It persists every transition to your database, guards against concurrent races with Postgres advisory locks, keeps a full audit trail of who moved each entity between states, and lets you query historical state at any past timestamp.

It is intentionally boring | no cryptography, no consensus, no P2P. Just correct, auditable transitions for payments, orders, subscriptions, and any backend where you need to know exactly what happened, in what order.

How the docs are organised

Packages at a glance

stateledger is split into small, focused packages so you install only what you use.

  • @stateledger/core — ORM-agnostic engine and adapter interface. Required.
  • @stateledger/prisma — Prisma storage adapter for Postgres.
  • @stateledger/drizzle — Drizzle storage adapter for Postgres.
  • @stateledger/memory — In-memory adapter for tests and prototypes.
  • @stateledger/outbox — Transactional outbox for atomic side effects (Stripe, email, Kafka): enqueue() inside your transition tx, a background createWorker() delivers with retries + DLQ.

System requirements

  • • Node.js 18 or newer
  • • TypeScript 5.0+ (optional but recommended)
  • • PostgreSQL 12+ (for the Prisma and Drizzle adapters)