Balancing the Ledger: Rafiki's TigerBeetle Integration

Written by Jason Bruwer

Rafiki is an open-source platform that enables Account Servicing Entities (ASEs) like banks and digital wallet providers to integrate Interledger Protocol (ILP) functionality into their systems.

A critical component of Rafiki’s architecture is its accounting database, which manages financial transactions and account balances. To enhance performance and reliability, Rafiki offers the option to use TigerBeetle, a specialized financial accounting database, as its accounting backend.

Tigerbeetle + Rafiki

What is TigerBeetle?

TigerBeetle is a financial accounting database designed for mission-critical safety and performance, aiming to power the future of financial services. It provides high-throughput transaction processing and ensures data integrity, making it well-suited for handling complex financial operations.

Why Integrate TigerBeetle with Rafiki?

Integrating TigerBeetle into Rafiki brings several advantages:

How Does Rafiki Utilize TigerBeetle?

In Rafiki, the backend service is responsible for handling business logic and external communications, including managing accounts and tracking liquidity.

For the accounting database, Rafiki provides the option to use TigerBeetle instead of PostgreSQL. This setup allows Rafiki to leverage TigerBeetle’s high-performance transaction processing capabilities for managing account balances and financial transactions.

It’s important to note that while TigerBeetle can be used for accounting purposes, Rafiki still requires a PostgreSQL instance for the authentication services and Open Payments resources. Therefore, both databases operate in tandem within Rafiki’s infrastructure.

Double-Entry Accounting: The Backbone of Financial Systems

At the heart of any financial system lies the principle of double-entry accounting.

This system, which dates back to the 15th century, ensures financial accuracy by recording every transaction as two corresponding entries: a debit in one account and a credit in another.

The total debits and credits always balance, providing a clear view of financial transactions and reducing the risk of errors or fraud.

How Double-Entry Accounting Works

In double-entry accounting:

For example, if a customer pays $100 into a digital wallet:

1. The Cash account (an asset) is debited by $100.

2. The Customer Balance account (a liability) is credited by $100.

This systematic approach ensures that the books are always balanced, providing transparency and consistency in financial operations.

Why Double-Entry Accounting Matters in Rafiki and TigerBeetle

Both Rafiki and TigerBeetle embrace double-entry accounting as a fundamental concept, ensuring that all financial transactions are meticulously tracked and balanced.

Here’s how it applies to their integration:

Enhanced Features with TigerBeetle

TigerBeetle elevates double-entry accounting by embedding these principles directly into its architecture:

Real-World Example

Thanks to double-entry accounting, both sides of the transaction are recorded in balance, providing a clear audit trail for reconciliation and compliance.

Double-entry accounting is more than a bookkeeping method, it is the foundation of trust and accuracy in financial systems. By integrating TigerBeetle, which seamlessly implements this principle, Rafiki ensures that its users have a robust, reliable, and high-performing platform to manage financial operations with precision and confidence.

Detailed Example: Sending and Receiving Rafiki instances

Here’s a practical illustration involving sending and receiving connectors within Rafiki, and how the underlying TigerBeetle accounts are affected. In this example, a sending Rafiki (where an outgoing payment is) sends ILP packets to a peer Rafiki over ILP, (paying into an incoming payment). The peering relationship is defined using USD for simplicity in this example.

This process happens for each ILP packet, which can occur at an extremely high frequency, especially during real-time payments. TigerBeetle’s high-performance architecture is critical here, as it ensures accurate and consistent accounting for these high transaction volumes while maintaining financial integrity.

Sending Rafiki

The sender creates an outgoing payment of 100 USD to an incoming payment at a peer’s Rafiki instance. The peering relationship between instances is in USD.

TigerBeetle Ledger Entry #1DebitCredit
USD outgoing payment liquidity acct100
USD peer liquidity acct100
Receiving Rafiki

An incoming payment at the recipient’s end receives 100 USD from the outgoing payment at the peer’s Rafiki instance.

TigerBeetle Ledger Entry #2DebitCredit
USD peer liquidity acct100
USD incoming payment liquidity acct100

Rafiki documentation has more accounting explanations.

Implementing TigerBeetle in Rafiki

To deploy Rafiki with TigerBeetle, you can use Docker Compose or Helm with Kubernetes.

Rafiki documentation provides example configurations for these deployment methods, including how to set up TigerBeetle as the accounting database.

For instance, when using Helm, you can specify the TigerBeetle version by adjusting the respective tag in the values.yaml file. During the deployment process, it’s crucial to ensure that the environment variables are correctly set, especially when preparing for a production environment.

Conclusion

The integration of TigerBeetle into Rafiki significantly enhances the platform’s capacity to process financial transactions with exceptional performance and reliability.

By harnessing TigerBeetle’s advanced features, Rafiki offers Account Servicing Entities (ASEs) a powerful and dependable solution for implementing Interledger functionality, ensuring seamless and secure financial operations.

More than just a bookkeeping method, double-entry accounting is the cornerstone of trust and precision in financial systems.

With TigerBeetle seamlessly incorporating this principle, Rafiki delivers a high-performance platform that empowers its users to manage financial transactions with accuracy, confidence, and efficiency.


As we are open source, you can easily check our work on GitHub. If the work mentioned here inspired you, we welcome your contributions. You can join our community slack or participate in the next community call, which takes place each second Wednesday of the month.

If you want to stay updated with all open opportunities and news from the Interledger Foundation, you can subscribe to our newsletter.