Skip to content

Repository files navigation

Cala

Cala is a robust ledger library developed by Galoy, designed to handle complex financial transactions and accounting operations. It provides a flexible and scalable solution for managing financial records with strong consistency guarantees.

Cala is distributed as a Rust library that you embed in your own service — it does not run as a standalone server.

Features

Core Capabilities

  • Double-Entry Accounting: Built-in support for double-entry bookkeeping principles ensuring accurate financial records
  • SQL-Compatible: Engineered to work with SQL databases (PostgreSQL) for robust data persistence and querying
  • Strong Consistency: Ensures accuracy and reliability of financial records
  • Real-time Processing: Efficient transaction processing suitable for production financial systems

API & Integration

  • Rust Library: Embed the ledger directly in your Rust service via the cala-ledger crate
  • Transaction Templates: Customizable transaction templates for common financial operations, parameterized with CEL expressions
  • Multi-Currency Support: Handle transactions across different currencies
  • Event Sourcing: Persistent outbox for reliably streaming ledger events to downstream consumers

Usage

Add the dependency to your Cargo.toml:

[dependencies]
cala-ledger = "0.20"

Then initialize the ledger with a PostgreSQL connection pool:

use cala_ledger::{CalaLedger, CalaLedgerConfig};

let pool = sqlx::postgres::PgPoolOptions::new()
    .max_connections(20)
    .connect("postgres://user:password@localhost:5432/pg")
    .await?;

let cala_config = CalaLedgerConfig::builder()
    .pool(pool)
    .exec_migrations(true)
    .build()?;
let cala = CalaLedger::init(cala_config).await?;

For a complete working example — including creating accounts, transaction templates, and posting transactions — see examples/rust and run it with:

make reset-deps rust-example

Developing

Dependencies

Nix package manager

direnv >= 2.30.0

Testing

Run unit tests with:

make reset-deps next-watch

About

Resources

Security policy

Stars

37 stars

Watchers

5 watching

Forks

Releases

Packages

Used by

Contributors

Languages