r/Clojure • u/andriosr • Sep 04 '20
Open-sourcing a financial ledger written in Clojure
Hi everyone,
I have been iterating a startup since the start of the year. And I'm using Clojure for everything I do.
The first product was a ledger service, but it ended up not fitting well as a managed service. We pivoted to a different idea and decided to open-source the ledger project.
It brings years of fintech experience, with the most common problems faced at scale for a ledger solved into the design.
I hope this will be helpful to some of the companies that are struggling with this kind of system.
https://github.com/decimals/sequence
Let me know if there is anything I can help with :)
3
u/801ffb67 Sep 04 '20
I wanted to work on something like this. My main idea was to entirely remove the pain of programming with emoney platforms because they are critical to companies and tend to absorb the time of the most knowledgeable and skilled individuals in startups; they are complex and tangled with the rest of the code base. My second idea was to stand as a meta payment provider, providing an unified interface to the existent APIs on the market: it takes times to connect to an emoney service and choosing one is a matter of business strategy. It takes months while it should be one checkbox away.
- It should be a local service owned by the customer, both as code and data. If startups use ledgers it is to mirror the ledgers on the other side of the payment API and to measure how much the company is messed up (and to panic accordingly). Or to have something to hang onto when the payment service comes asking for missing money. This is a matter of trust and this is why the customer needs to have full control and full agility on these matters.
- Ledger evolve through time in accordance with the state of payment objects and this is another great source of pain and despair when handling a payment API since they are in fact objects whose state must be replicated between the two sides of a payment API. With this requirement comes all the woes associated to network communications. Server overload, timeouts, race conditions, receiving messages in the wrong order. This is mainly why payment services are a permanent maintenance burden.
- The service must not feel as another service. You don't want to deal with 3 services. 2 are enough. What I wanted to do was to implement "abstraction transparency" by carrying the SQL relational model up to the web API. Just query the API using SQL. Trigger real world side effects with "INSERT" statement. To implement a client in a given language for this service, just use the local ORM. It must feel and be as convenient as local resources.
2
u/andriosr Sep 04 '20
This is really interesting!
I thought a lot about this abstraction on top of existing payments APIs. But payment providers are already this layer, but for legacy banks infrastructure. This is my main concern about this.
I love the reflection: "objects whose state must be replicated between the two sides of a payment"
3
u/petemak Sep 05 '20
Your concept of hash chains for implementing scallable immutable writes with No-Sql seems to be similar to what's already available in Datomic 's concept of accretion facts. Am I right to assume that you could have used Datomic (or Datahike for that matter) instead?
1
u/andriosr Sep 05 '20
Yes! Actually, the goal is to add support to multiple databases in the future, Datomic being at the top of the list. It’s the exact same principle of relying on conditional puts, any No-sql based database works
2
u/mac Sep 15 '20
Thanks for the write-up. I for one would be very interested in a piece on how consistency is implemented in the application via conditional puts.
2
3
Sep 05 '20
Super! I loved the article https://decimals.substack.com/p/things-i-wish-i-knew-before-building! Congrats
1
3
1
8
u/xela314159 Sep 04 '20
This is very interesting, thanks. Could this be used to create a GnuCash style database? Could you use securities instead of currencies ?