AGAM - IOU Tracker

AGAM - IOU Tracker


Written by Erick /

As I've come to learn, getting thrown into a new codebase can be bewildering.

However, this feeling of bewilderment is a common one, and one that I've tried to overcome by using the tech that I see at work in a personal project.

So to better familiarise myself with TypeORM and to improve at TypeScript and Node.js, I created a web app that works a bit like a simple banking app, but instead of money, we send IOUs.

The idea seemed pretty straightforward and was only mildly inspired by Lloyd Christmas in Dumb and Dumber.


The user should be able to:

  • Send an IOU
  • Receive an IOU
  • See IOU status

In this simplicity was hidden some complexities.

Sending an IOU

As it turns out, sending "money" is a little more complicated than it looks.

In order to send an IOU, I needed to ensure that the user is who they claim to be, for which I use a Json Web Token, but we'll save that for another day. The user needs to have credits equal to the IOU amount that they'd like to send. So, I first check to see if the user has enough "credits/money" to cover the transaction. Ignore the fact that it seems silly to need money to ask for money, but you can think of credits as reputation points. This requirement can be adjusted later, of course.

Verify Funds

After ensuring that the user is who they claim to be, I make sure they have enough money. So I query the database with their credentials from the token, and then I determine if it's a transfer or a withdraw.

In both cases, I need to verify the user's funds. If not, we return an error, otherwise we continue to the next step -- the adjustBalances middleware.

Adjust the Balance(s) (if necessary)

There are multiple types of transactions:

  • deposit adjusts a single balance
  • transfer adjusts two balances
  • reminder adjusts nothing, but creates an entry in the database for the user.

The deposit is straightforward. I query the database for the user and I increase their existing balance by the deposit amount.

The transfer is a little bit more involved. By this stage, however, I've already ensured that the sender has the money to cover the transaction. I then update the sender's balance by subtracting the amount transferred and then then update the receiver's balance, increasing it by that same amount.

The reminder is one that can later be refactored out of the transactions endpoint as it does not modify balances at all. It simply adds a reminder entry in the database with any information they'd like. In this scenario, they do not even need to have enough money to cover the transaction as it is just that; a reminder. enter image description here

On the dashboard, they'll see a little clock that they can expand to see this: What a reminder looks like after expanded

Eventually, all reminders will go here, including the ones with IOUs that you promised to pay that are coming due.

Accepting/Rejecting IOU(s)

Just because someone wants to pay you with an IOU, does not mean that you necessarily want to be paid in one. The idea behind this is pretty straightforward. If your friend says they'll buy you dinner next time if you pay for dinner tonight, then you can either agree to that or not.

enter image description here


enter image description here

Your Transactions

enter image description here

In the transactions, you have a a high-level view of everything, ranging from what you owe others, your payment status, what they owe you, and if they're paid or not. Of course some features may be lacking, but that's expected. This seems to be a decent MVP to start with.


Making any sort of app that mimics transactions is a good way to flex your programming muscle and forces you to think of many edge cases. The most difficult part was understanding the wonky way of creating relationships between the database tables using TypeORM, but that was just a matter of reading through the docs and experimenting.

There are many more improvements that can be made to this that I am considering implementing:

  • Automatically reminds those to pay you so that you don't have to awkwardly remind them about the $0.50 you let them borrow for a can of Coke. (How much does a can of Coke cost these days anyway?)
  • Connect to a third party payment platform to actually send real money to pay back the IOUs.
  • Earn reputation points when an IOU is paid on time and reflect this information on your profile so that other's are more likely to extend credit / IOUs to you.

enter image description here

🍻 Erick