LedgerForge is an open-source double-entry ledger for applications that move money. Use it to record wallet transfers, billing activity, reservations and refunds through an HTTP API, a Go library or a local MCP server.
PostgreSQL stores the financial records. Redis supports queues and background workers. Search and observability services are optional. LedgerForge records money movement; connecting payment rails and defining your accounting model remain application responsibilities.
- Exact amounts: postings and balance arithmetic use integer units. Supply
precise_amountwith an explicitprecisionto avoid floating-point input loss;1250at precision100represents12.50. - Double entry: each applied transfer debits its source and credits its destination by the same amount. Split transfers distribute that amount across their legs.
- Immutable postings: corrections and refunds create linked transactions. Financial postings and accepted execution controls are preserved; customer metadata can be updated.
- Idempotency by reference: reuse the same unique transaction
referenceafter a timeout. Duplicate references are rejected; look up the original outcome instead of retrying with a new reference.
See ledger concepts for amount handling, balance semantics and asynchronous transaction states.
Requires Docker with Compose and Python 3. From a checkout:
git clone https://github.com/devaccuracy/ledgerforge.git
cd ledgerforge
./examples/quickstart/start.sh
./examples/quickstart/transfer.shThis local-only demo builds the current checkout, generates a random master
key, runs migrations and binds the API to 127.0.0.1:5001. It creates two USD
balances and posts 12.50 synchronously using integer units. The source gets a
bounded demo overdraft of 12.50; the result is -1250 and 1250 units, with
equal total debits and credits. A retry with the same reference must leave
those balances unchanged.
source: -1250 units
destination: 1250 units
total debits = total credits = 1250 units
reference retry: balances unchanged
Stop it with docker compose -p ledgerforge-demo -f examples/quickstart/compose.yaml down.
See the example guide for the API payload,
credentials and cleanup. These credentials and database defaults are for local
use. Read the deployment guide before exposing a service.
- Exact money: integer postings and balance counters, preserved decimal request tokens, explicit precision and deterministic split allocation. Invalid monetary inputs are rejected before posting.
- A verifiable ledger: read-only
ledgerforge verifyreplays accounting evidence. Versioned audit chains and exportable checkpoints supportaudit verify --anchoragainst independently retained roots. See the verification guide for coverage and legacy limits. - Agent guardrails: per-key currency/precision limits, balance/ledger allowlists, durable daily reservations and approval holds enforced by the server. Delegated keys inherit restrictions and share ancestor budgets. Bind MCP to an API key and keep independent approver credentials outside the agent's authority. See agent safety and the executable policy example.
- A hardened API: owner-bound key management, constrained delegation, authoritative revocation checks, bounded input and sanitized backend errors. Dedicated webhook signing secrets and destination controls protect outbound integrations. See security operations.
- Tested invariants: exact-amount and allocation fuzz targets, generated PostgreSQL operation sequences, balance conservation checks and race tests for financial lifecycle and spending-capacity transitions.
- Operational workflows: inflight reservations, partial settlement, refunds, split/bulk transfers, reconciliation, lineage, snapshots and optional search, metrics and OpenTelemetry. PostgreSQL retains financial truth while workers handle asynchronous execution and delivery.
- Release binaries: download
ledgerforgeandledgerforge-mcpfor Linux, macOS or Windows from GitHub Releases, then check the archive againstchecksums.txt(sha256sum -c checksums.txt --ignore-missing). - Container image:
docker pull ghcr.io/devaccuracy/ledgerforge:1.0.0. The image contains both binaries; the release lists its digest and SBOMs. - From source:
go install github.com/devaccuracy/ledgerforge/cmd/ledgerforge@v1.0.0(Go 1.26.9 or later).
Run ledgerforge version to confirm what you installed, then follow the
deployment guide and run ledgerforge migrate up before
starting the server.
cp ledgerforge.example.json ledgerforge.json
# Replace server.secret_key with a random secret before starting.
# For example, generate one with: openssl rand -hex 32
docker compose up -dThe config explicitly enables authentication. API requests use the
X-LedgerForge-Key header. Keep ledgerforge.json private and out of version
control. The :main image tracks tested main-branch commits; pin a release tag
or digest in production with LEDGERFORGE_IMAGE.
- Concepts: amounts, balances and transaction states
- Deployment: secrets, TLS, limits and webhook verification
- Integrity upgrade maintenance and historical evidence
- Accounting verification and external audit anchoring
- Agent spending policies and independent approval
- API security, delegation and rotation
- Architecture and trust boundaries
- MCP server
- Metrics and monitoring
- Metadata webhooks
- Contributing and isolated integration tests
- Changelog and security policy
- Online documentation
make verify
make test-integration
make vuln
make coverSee CONTRIBUTING.md for prerequisites and test isolation.
Use GitHub issues for bugs and feature requests. Follow the Code of Conduct. Report vulnerabilities privately to security@ledgerforge.io.
Licensed under Apache 2.0. Required notices are in NOTICE.md.