Skip to content

Commit 338824e

Browse files
authored
Merge pull request #106 from interledger/jb/3179/tb-blog
feature(3179): rafiki tigerbeetle blog
2 parents 0e0e584 + 0c16dfc commit 338824e

File tree

4 files changed

+128
-0
lines changed

4 files changed

+128
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,6 @@ pnpm-debug.log*
2424
bun.lockb
2525
pnpm-lock.yaml
2626
package-lock.json
27+
28+
# webstorm
29+
.idea/

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
lts/iron
521 KB
Loading
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
---
2+
title: "Balancing the Ledger: Rafiki's TigerBeetle Integration"
3+
description: "How TigerBeetle Supercharges Rafiki’s Financial Core."
4+
date: 2024-12-17
5+
slug: rafiki-tigerbeetle-integration
6+
authors:
7+
- Jason Bruwer
8+
author_urls:
9+
- https://github.com/koekiebox
10+
- https://www.linkedin.com/in/jason-bruwer-8110766/
11+
tags:
12+
- Interledger
13+
- Interledger Protocol
14+
- Interledger Stack
15+
- Interledger Foundation
16+
- Open Payments
17+
- Rafiki
18+
- TigerBeetle
19+
---
20+
21+
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.
22+
23+
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.
24+
25+
![Tigerbeetle + Rafiki](/developers/img/blog/2024-12-17/tigerbeetle.png)
26+
27+
28+
## What is TigerBeetle?
29+
[TigerBeetle](https://tigerbeetle.com/) 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.
30+
31+
#### Why Integrate TigerBeetle with Rafiki?
32+
Integrating TigerBeetle into Rafiki brings several advantages:
33+
- **High Performance:** TigerBeetle is optimized for online transaction processing (OLTP) workloads, offering significantly higher performance compared to general-purpose databases.
34+
- **Financial Consistency:** With its built-in debit/credit schema, TigerBeetle enforces financial consistency at the database level, reducing the risk of errors in transaction processing.
35+
- **Fault Tolerance:** TigerBeetle is designed for faults and ensures data durability, which is crucial for financial applications.
36+
37+
38+
## How Does Rafiki Utilize TigerBeetle?
39+
In Rafiki, the backend service is responsible for handling business logic and external communications, including managing accounts and tracking liquidity.
40+
41+
For the accounting database, Rafiki provides the option to use TigerBeetle instead of PostgreSQL.
42+
This setup allows Rafiki to leverage TigerBeetle’s high-performance transaction processing capabilities for managing account balances and financial transactions.
43+
44+
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.
45+
Therefore, both databases operate in tandem within Rafiki’s infrastructure.
46+
47+
## Double-Entry Accounting: The Backbone of Financial Systems
48+
At the heart of any financial system lies the principle of **double-entry accounting**.
49+
50+
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.
51+
52+
The total debits and credits always balance, providing a clear view of financial transactions and reducing the risk of errors or fraud.
53+
54+
### How Double-Entry Accounting Works
55+
In double-entry accounting:
56+
- **Debit** entries represent increases in assets or expenses and decreases in liabilities, equity, or revenue.
57+
- **Credit** entries represent increases in liabilities, equity, or revenue and decreases in assets or expenses.
58+
59+
__For example, if a customer pays $100 into a digital wallet__:
60+
61+
**1.** The Cash account (an asset) is debited by $100.
62+
63+
**2.** The Customer Balance account (a liability) is credited by $100.
64+
65+
This systematic approach ensures that the books are always balanced, providing transparency and consistency in financial operations.
66+
67+
### Why Double-Entry Accounting Matters in Rafiki and TigerBeetle
68+
Both Rafiki and TigerBeetle embrace double-entry accounting as a fundamental concept, ensuring that all financial transactions are meticulously tracked and balanced.
69+
70+
Here’s how it applies to their integration:
71+
- **Financial Integrity at Scale:** TigerBeetle is built with a native debit/credit schema, ensuring that every transaction adheres to double-entry accounting principles. This guarantees that the accounting records are always accurate and consistent, even under high-throughput conditions.
72+
- **Error Detection:** By requiring every transaction to balance debits and credits, double-entry accounting makes it easier to identify discrepancies or anomalies, enhancing the overall reliability of the system.
73+
- **Operational Transparency:** For Account Serving Entities (ASEs) using Rafiki, double-entry accounting provides clear insights into financial flows, helping operators manage liquidity, track balances, and ensure compliance with financial regulations.
74+
75+
### Enhanced Features with TigerBeetle
76+
TigerBeetle elevates double-entry accounting by embedding these principles directly into its architecture:
77+
78+
- **Atomic Transactions:** TigerBeetle ensures that transactions are either fully completed or not executed at all, preventing partial updates that could lead to discrepancies.
79+
- **Performance and Consistency:** By using double-entry accounting, TigerBeetle can process an exceptionally high volume of transactions per second while ensuring financial accuracy.
80+
81+
### Real-World Example
82+
Thanks to double-entry accounting, both sides of the transaction are recorded in balance, providing a clear audit trail for reconciliation and compliance.
83+
84+
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.
85+
86+
#### Detailed Example: Sending and Receiving Rafiki instances
87+
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.
88+
89+
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.
90+
91+
##### Sending Rafiki
92+
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.
93+
94+
| TigerBeetle Ledger Entry #1 | Debit | Credit |
95+
|-------------------------------------|----------|---------|
96+
| USD outgoing payment liquidity acct | `100` | |
97+
| USD peer liquidity acct | | `100` |
98+
99+
##### Receiving Rafiki
100+
An incoming payment at the recipient’s end receives `100 USD` from the outgoing payment at the peer’s Rafiki instance.
101+
102+
| TigerBeetle Ledger Entry #2 | Debit | Credit |
103+
|-------------------------------------|----------|---------|
104+
| USD peer liquidity acct | `100` | |
105+
| USD incoming payment liquidity acct | | `100` |
106+
107+
Rafiki documentation has more [accounting explanations](https://rafiki.dev/overview/concepts/accounting).
108+
109+
## Implementing TigerBeetle in Rafiki
110+
To deploy Rafiki with TigerBeetle, you can use Docker Compose or Helm with Kubernetes.
111+
112+
[Rafiki documentation](https://rafiki.dev/) provides example configurations for these deployment methods, including how to set up TigerBeetle as the accounting database.
113+
114+
For instance, when using Helm, you can specify the TigerBeetle version by adjusting the respective tag in the `values.yaml` file.
115+
During the deployment process, it’s crucial to ensure that the environment variables are correctly set, especially when preparing for a production environment.
116+
117+
## Conclusion
118+
The integration of TigerBeetle into Rafiki significantly enhances the platform’s capacity to process financial transactions with exceptional performance and reliability.
119+
120+
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.
121+
122+
More than just a bookkeeping method, double-entry accounting is the cornerstone of trust and precision in financial systems.
123+
124+
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.

0 commit comments

Comments
 (0)