9 ms·
Show HN: An API to store balances and transactions
Hey everyone!
I'm Rob and I want to share what I've built - a solid ledger behind simple API: https://decimals.app https://decimals.app
The ledger is a key piece of any financial system and is easy to get the design wrong, resulting in troubles for making sure money movements are adding up.
I took a lot of inspiration from good designs from Square, Uber, and others for the scalability and security aspects. And on the usability side, I applied many concepts from the Ledger CLI, making it very easy to use.
I'm really happy I get to show this to you all, thank you for reading about it! Please let me know your thoughts and questions in the comments (The sample code on the landing page is not working, I'm fixing it).
[1] https://www.ledger-cli.org/ https://www.ledger-cli.org/
[2] https://www.youtube.com/watch?v=iN6mhI5hFt4 https://www.youtube.com/watch?v=iN6mhI5hFt4
[3] https://developer.squareup.com/blog/books-an-immutable-double-entry-accounting-database-service/ https://developer.squareup.com/blog/books-an-immutable-doubl...
[5] https://docs.decimals.app https://docs.decimals.app
- collinglass 6y agoHi, I've signed up for early access and tried replying to your emails but I am unable to reply to your decimals app email address, I get mail failut. Please reach out with another email, could really use this. collin at waystocap
- seancoleman 6y agoI can’t count how many times I’ve individually solved this problem for various companies, and fixed broken ledger systems. I’m currently dealing with the terrible legacy decisions of single-precision float database columns leading to floating-point precision loss on a multi-million $$ eCommerce platform. What a schlep. I’m curious, do you store currency values as decimal dollars or integral cents?
- zomglings 6y agoThe code sample on the website indicates integral cents: // Transfer $10 from Alice to Bob decimals.transactions.create({ from_account: 'Alice', to_account: 'Bob', currency: 'usd', amount: 1000 })
- deleted 6y ago[deleted]
- andriosr 6y agoYep, as @zomglings and @vangale noted, always an integer. Thanks, guys. They can represent anything you want, cents, mils, and so on.
- pbreit 6y agoIronic that the app name is "Decimals". Personally, never liked the apps that used integers for what in the real/human world are decimals. I understand (sort of) why they are used from a tech perspective. But ultimately, tech is used by humans.
- WrtCdEvrydy 6y agoIt's an issue with floating point accuracy usually... 2 point decimals can usually be accurate but given enough operations, you can sometimes get a weird floating error and rounding / clamping is discouraged in banking.
- ajnin 6y agoHe's talking about fixed point, not floating point. The decimal type in SQL is an exact, fixed point numeric type. It can avoid loss of precision, like integer, but without the scale conversion step.
- mortin 6y agoThat's what we call "an abstraction" and that's what they were invented for. At some point, in tech you are going to have to create an abstraction at some layer. The upper the layer, the more the abstraction should resemble what humans see as "normal". Did you know all numbers are stored in "registries" in the computer memory. Is a registry a number? NO! It's just bits. At what point can you actually treat a "variable" as an actual "decimal"? How does a storage system actually save a decimal number? Not sure, and up to some point I don't care, as long as I know the accuracy and trade-offs I'm getting. I guess my point is, using integers sets to represent a decimal number is okay if it is coping with the lower layers' limits. If a lower layer already provides a proper solution, then there is no need to provide the same. But ultimately, abstractions are what matter and what has allowed us to progress. All you need to know about an abstraction is its limits and compromises.
- rgbrgb 6y agoThis is pretty cool, I'd wonder how it compares to an open source accounting library like double_entry. I guess I'd be hesitant to integrate with an external service if I could accomplish the same thing with a library. Have no idea if there's a market for this (I'm certainly not a customer), but something none of these libraries are set up to do is convert these balances to erc-20 tokens. The combo of a SaaS with a simple API like this and a trusted mint to sync balances to erc-20 tokens could be interesting. [0]: https://github.com/envato/double_entry https://github.com/envato/double_entry
- theturtletalks 6y agoI would check out https://frappebooks.com/ https://frappebooks.com/. They are building an open-source accounting system like Freshbooks. It can also be used for personal accounting like Mint.
- andriosr 6y agoInteresting, thanks!! I know Frappe, it's from the creators of ERPNext. They are more like a full-suite accounting tool, like Mint, as you mentioned. Decimals.app is a general-purpose API, it can be used for accounting and other use cases if you need to build them and can't use Mint and others.
- andriosr 6y agoVery interesting, thanks for the feedback! I found a couple of similar projects, but not this one, I will definitely check them out. Thanks!
- chrischen 6y agoI'm also interested in these systems as opposed to implementing accounting systems internally myself. How do all of these compare to https://hledger.org/1.2/hledger-api.html https://hledger.org/1.2/hledger-api.html?
- zomglings 6y agoHaving gone through the pain of writing code like this in the past, this looks amazing. How are you planning to charge for decimals? In your code sample, you use from: 'Alice' but list transactions for some kind of complicated balance ID. Where did that ID come from?
- zomglings 6y agoAlso, your RunKit sample is not working since they don't have the decimals package available (assuming it's published on npm already).
- andriosr 6y agoI'll add a note to the post, thanks! Working on that now.
- andriosr 6y agoGreat question, each Account holds a list of balances, one for each currency. When you first use a given currency on an Account, a Balance is created along with its id. The ID comes from the list of balances of the Alice Account.
- zomglings 6y agoIs there a way to access that balance ID programatically? Right now, it is a magic string and it isn't clear to me how I would get access to it in my program. Perhaps from a return value on decimals.transactions.create? Also, shouldn't decimals.transactions.create be asynchronous?
- andriosr 6y agoPricing is similar to the Segment.io model, you pay for the number of accounts, in chunks of 10k. You get the most value when you do more transactions, so that's why we don't charge for that, we don't want companies limiting what they to with Decimals to save money. Also important to note is that this is not one more layer in the payment cake taking a percentage of your revenue, the pricing is based on API usage, with no relation to your revenue.
- Ap0c 6y agoWhy would you not use an accounting package like Xero to manage this?
- andriosr 6y agoXero is an accounting app, and it has a ton of features. This is a simple API to validate money movements, it can be used as one of the pieces to build a dedicated accounting, billing, and other systems if existing solutions like Xero doesn't work for you. It's general-purpose, where Xero is more a dedicated app for accounting.
- Ap0c 6y agoThanks for the insight. Appreciate it.
- howmayiannoyyou 6y agoXero user here. Would leave in a second if I could. Why: - Next to nothing in terms of expense graphs. - Terrible API for polling for alerts based on reports. - Saving custom reports not really a thing. - Mobile app is hot garbage. - Bank feeds drop a lot. - My accounting firm not a fan. - One light blue skin forever, like being relegated to a blue hell. - Integrates with things like Zapier & Integromat, but not deeply. - Parsing JSON reporting via Integromat is pure pain.
- andriosr 6y agoThis is interesting! I heard a lot of complaints about the Xero API, it has low rate-limits and you need some workarounds to push data in at a fast enough pace. Definitely not the system to be used at scale. One thing that is in the roadmap is to bring data from Xero so that you can interact with it in Decimals. It should give you a much better API, and we make sure it's going to get synced in the background. Let me know if this is something you might be interested in getting early access.
- joshuakelly 6y agoI actually pitched this exact idea to YC and was part of W20 - but I very quickly pivoted away from it. If anyone is wondering about this, the basic business challenge you have to solve is being in the right place at the right time. This kind of thing is very sticky once its in place, and most startups don't realize the complexity in the domain early enough for a stand-alone service to make sense to them. I think as far as startups in this space go, the best path forward would be to nurture an open source project in the long term. I ended up open sourcing my work after the pivot here: https://github.com/affiga/scaledger https://github.com/affiga/scaledger
- andriosr 6y agoInteresting! I would love to talk to you about the experience, can we have have a quick chat?
- joshuakelly 6y agoYep, email in profile
- vangale 6y agoAnd it looks like a similar effort that was abandoned at subledger.com. It think there can be a market for something like this and hopefully this one works out.
- andriosr 6y agoThanks so much! Didn't know them, I will reach out. Do you know if they completely shut it down?
- canterburry 6y agoWe pretty much use a private blockchain for the very same purpose. Its internal, only our systems have access, each user/customer is auto created an account on signup, we hold the private keys encrypted with the user's password so we can't access the key itself, keeps track of everything with 100% consistency. 1s block mining and raft consensus settings so pretty much instant and low resource utilization...and massively scalable. Sorry to say but if I am in any type of fintech, I would never ever outsource keeping track of my customer's account balances and source of truth.
- andriosr 6y agoCompletely understand. This is a normal concern for new technology, not every company is an early adopter. The same way Lyft would not even consider using Stripe in its first two years, considering how critical credit card data is for them. I really like the design you have internally! I would love to hear more about it, can we talk?
- Nextgrid 6y agoCurious, why is card data important to Lyft? How does card data benefit a transportation business in any way beyond just taking money from the cards?
- andriosr 6y agoIf they sent the card data from their customers to a 3 person startup it could be stolen and make their customers unhappy.
- sky_rw 6y agoThis was likely just as much about credit card fees as it is about data. Stripe's amazing service also comes at a substantial premium. For a high-volume thin-margin company like Lyft where every penny counts, per transaction fees at 2.9%+ are killers. Furthermore, large companies prefer to own the raw card data themselves as the interchange rates for card not present debit cards is different than card not present credit cards. Once you hit a certain amount of scale this .15% difference is substantial. (edit: I missed that parent comment was about trust in a 3-person startup, but point is still somewhat valid)
- bbrinx 6y agoWhen I run the example code I get "Error: Cannot find module 'decimals'". I'm on latest Chrome macOS
- andriosr 6y agoNoted, I'm working on it. Thanks!
- forthwall 6y agoLooks pretty cool and useful. Only note is that the runkit environment doesn't seem to be working. "Error: Cannot find module 'decimals'"
- andriosr 6y agoThanks! noted, I'm working on it.
- Gepsens 6y agoI'm actually building a crypto trading system from scratch (like gekko but more sophisticated). For now not as a SaaS, but even with a simple system, all the transactional problems occur quite fast. This is really interesting !
- andriosr 6y agoThat's great! One of the companies using Decimals is building a crypto exchange, it's been great to see how the API can be extended. They are creating a multi-signature wallet on top of Decimals, adding a signature to each transaction. Let's talk, I think it can really accelerate what you are building.
- Gepsens 6y agoI mean, I'm on the client side, so I don't need a ledger to manage wallets, for now. But as the system evolves, I'll definitely need to 'allocate' budgets in the form of ledgers, where an algorithm decides to move funds from one account to another.
- tathougies 6y agoWhy is something that should be a library over an ORM or other data store now a service product?
- andriosr 6y agoThanks for the question! My view is that when you are creating a product and there is something that can get you faster at delivering your core value to your customers, it makes sense to leverage it. From past experiences, on a reasonably big company (>100 engineers) that needs to do these money movements checks, it would save at least 3 engineers from support/evolution and not counting the development time for a good ledger.
- tathougies 6y agoFrom my experience as running my own SaaSes, I'd rather have a library over an ORM, or a self-hosted service. Having yet another cost to manage, another API to monitor, and an unreliable interface (HTTP over internet), just isn't worth the cost.
- andriosr 6y agoThat is very interesting to hear. I would love to better understand the kinds of problems you may have faced with these systems. On the cost side, the goal is to charge on average 1/10 of what you currently spend, so cost is actually a feature. I'm working on a self-hosted version for some customers that are asking for it, but not due to reliability of HTTP over the internet, I would love to hear more about this. Can we chat?
- justsomeuser 6y agoHow would this be better than designing a simple SQL schema, and then generating the ledger as a report?
- andriosr 6y agoGood question, I think it is the same asked here: https://news.ycombinator.com/item?id=23355547 https://news.ycombinator.com/item?id=23355547 Let me know what you think. Thanks!
- deleted 6y ago[deleted]
- justsomeuser 6y agoI think that the people you are targeting (developers) do not care or know about the issues you are solving, and they also have the skill to make their own thing - its too close to "persist this list of numbers, sum them". Using decimals, how would users generate reports? I think maybe you should do a detailed blog post comparing the difference with the default course of action developers take when they need to record transactions with the benefits decimals provide. At a loans company I worked at before, we just used a transactions table and generated accounting reports using SQL.
- andriosr 6y agoThat's great advice, thanks! What sources of data were you pulling into your transactions table at that company? For instance: payment data from Stripe?
- justsomeuser 6y agoWell we weren’t really pulling data as our database was the “source of truth”. We had a schedule to charge cards, so the state machine was defined completely in our code - unlike Stripe-like companies that control the state machine and send you events to tell you what is happening.
- jFriedensreich 6y agoNot to be "that guy", but if your pitch is that you can keep money transactions consistent, also make the use of semicolons on the landing page example consistent. ;) Apart from that it looks really nice, but as a naive person it would be really cool to give examples of issues i would run into, if i tried building something like this myself...
- andriosr 6y agoNo worries at all! I'm here to get feedback and thoughts. Thanks so much for noticing and letting me know, it's now consistent! It makes a ton of sense to add the common issues section, it should speak to people having the problem as soon as they see it. I will work on that.
- ncallaway 6y agoI would definitely second that. I don’t have a great grasp on why I shouldn’t do this myself. Somewhere (it doesn’t have to be on the landing page), I’d like to hear about why I shouldn’t do this myself.
- andriosr 6y agoGot it, I will improve on that. The point is: besides being a consistent store, Decimals connects to multiple sources of data and make it available in your ledger automatically. Say you have transactions in Stripe, besides building the system to store the transactions in-house if you need, you also have to connect to their webhook to pull the data. Then you need to compute the usage of your saas, you can also do that on Decimals, just use the currency of your app (MB, GB, events, etc), now you have payments and usage in a single consistent store, and so on.
- spraveenitpro 6y agoWhat about bitcoin?
- scrollaway 6y agoCool. Couple questions: 1. How do you handle / plan to handle multi-currency accounts? (normalize to single currency vs. Selinger's approach https://www.mscs.dal.ca/~selinger/accounting/tutorial.html https://www.mscs.dal.ca/~selinger/accounting/tutorial.html) 2. What tech did you use to build all this? db/languages etc.
- andriosr 6y agoGreat questions, thanks! The API is currency agnostic, so one account can have many balances from multiple currencies attached to it. However, you can't do transactions cross currencies at the moment. You can do it on your side, and use the API to store the result, both normalized and Selinger are doable. I definitely plan to add this at some point, thanks for the reference, it's great! On the tech side, the service is written in Go, and the database is DynamoDB, everything runs on AWS right now. I'm planning to add support for Cassandra and MongoDB, as some enterprise customers want to run it inside their datacenters.
- deleted 6y ago[deleted]
- arthurcolle 6y agoThis is a great idea, and I think you should pursue it. Immutability of transactions is obviously a fundamental necessity and coupling this with GraphQL seems like a great fit.
- andriosr 6y agoThanks! Yes, it is, I will make it more clear on the copy.
- venantius 6y agoWe are planning on offering a competitive service to this later on this year. The major difference for us is that we’re an actual bank, so we need to run this infra whether you pay for it or not.
- andriosr 6y agoInteresting! That's great to hear, I think there is a big market for this. A lot of companies are struggling to build this in-house, without the required finance/accounting domain knowledge. I would love to chat, can I reach you on keybase?
- RileyJames 6y agoSubLedger was another startup in this space a few years ago, which I thought had the right idea. But they didnt really follow through. They seemed to focus on uber and their ilk as customers, where as I felt they would have been a killer if they focused on being the accounting backbone between business apps. Like Xero is, but api first / only. https://www.crunchbase.com/organization/subledger https://www.crunchbase.com/organization/subledger
- andriosr 6y agoInteresting! I’m going to try to learn and avoid making the same mistakes. The goal is definitely to be the backbone of any money movement record. The goal is to do what Segment does for analytics data, or Auth0 does for identity, but for payments data.
- andy_ppp 6y agoYes, in the end there are only lists of transactions and so great potential for interacting with them from a central, simple API. It may or may not be worth having a look at the open banking APIs that are in use here in the UK.
- andriosr 6y agoThanks! I read a couple of specs, didn’t like the design, I think it’s too complex. But it may be due to the complexities of the UK banking system. From an integration point of view, it’s definitely something I’m looking at.
- ianhawes 6y agoI thought this sounded familiar. I got an email out of the blue 10 days ago about this app from the creator: > Hi! I run a startup trying to make it easier to create systems that store transactions and balances. I found your contact searching the stargazers of the php Money lib: https://github.com/moneyphp/money https://github.com/moneyphp/money Are you using it? The project is in the early stages, I have nothing to sell. I need help to make sure I will build something useful. -- Rob.
- andriosr 6y agoHello Ian, yes! That was me. I reached out to a couple people using money libraries to better understand how are people dealing with the problem right now. The goal was to help in the design of the api for client libraries and get a better sense of how the product fits into different orgs. Thanks for commenting!
- nnn1234 6y agodidnt ledger cli try this with dot ledger that was used by hackclub?
- andriosr 6y agoNice question! Dotledger is a full suit accounting tool To replace Xero personal finance. Decimals is a primitive API that can be used to build that or other kinds of applications, but it would be only one of the pieces of the overall system at the moment.
- bhargav 6y agoMoney and keeping track of it is a big problem. Depending on your problem though, its not fully always in your control. For example, we integrate with a discount calculation service that only supports values up to the 100ths. This means that we have to introduce rounding as an intermediary and then solve the "off by one cent" problem, after the fact. In addition to the problem @joshuakelly mentioned, I think one of the challenges here will be to gain trust. Asking someone else to keep track of your books is a pretty tall ask. How does it affect a given company's auditing? What about SOC Compliance etc? I would suggest you try to address some of these things. Best!
- andriosr 6y agoThat's great feedback, thanks! I agree with both points, handling different precision strategies from multiple parties is a challenge on itself, we don't solve it yet, but is definitely on the roadmap. On the trust side, it's a question of time, as the curve of adoption for any technology, we have been working with the early adopters now, and providing them the competitive advantage they deserve for being innovators. Thanks for the comment!
- bluewalt 6y agoHow did you build the landing page? (any tool?) I like the sleek style, it reminds me Stripe pages.