Automating Income and Expense Tracking: A Step-by-Step Guide to Using AWS

Introduction:

Tracking income and expenses can be a tedious task, and it can be time-consuming to manually record every transaction. In this article, I will share how I automated the tracking process for my day-to-day transactions.

Problem:

How they work is that they contact our banks to get data on our transactions. Categorize each transaction both expenses and income. and show them in beautiful charts. This seems to be promising because We just need to give all the details sit back and enjoy!

But it comes with disadvantages too.

  1. Giving bank details to a 3rd party. Putting our financial information at RISK!

  2. Compromising our privacy, As 3rd party can get all our bank transactions. We can't be sure that they won't misuse/sell the data.

  3. NOT free, All such apps out there charge based on subscription.

To overcome giving access to 3rd party apps to contact banks. I tried contacting banks If they can provide any developer API to get transactions, but Nothing worked.

3rd party app:

After much experimentation, I discovered this app called Wallet by Budgetbakers. I found it very useful It has a nice UI and beautiful charts and it was able to overcome the disadvantages as well.

  • This app is mostly free But some features are premium.

  • This app has connect to bank feature, We are not gonna use it Instead, this app can import our bank transactions via CSV file!

  • I created an account with temp email and fake details to stay anonymous

Solution:

I was surfing through my bank account portal to figure out a way to get my account transaction details programmatically.

  • I saw an option from my bank to receive monthly transactions to my registered email at the start of each month.

  • I created a lambda to read for bank emails and download the csv attachment with transactions.

  • I used the lambda to process and format the csv file to the supported format of the Wallet app.

  • In the app there is an option to import csv files from via email as well. Basically how this works is the app will give a random import email. Once we send our csv attachment to the random email. Our transactions will be imported to our account on the app.

  • I used AWS SES to send the email with formatted csv attachment to the wallet app.

Setup:

  • Created a lambda with necessary permissions.

  • Created a cron job to trigger the lambda on the 2nd of every month.

  • Gmail provides an API to programmatically access email. In lambda, I used Gmail API to read my inbox for an email from the bank And was able to download the attachment.

  • I used AWS SSM Parameter Store to store my Gmail API key.

  • After fetching the attachment I used pandas library to format the CSV

  • Finally using SES I mailed the CSV to the randomly generated email provided by the wallet app

Wallet app:

All the imported transactions can be automatically categorized by the wallet app. Of course It won't be accurate But we can always categorize our transactions. The best part is in the future If the same kind of transaction happens again the wallet app automatically categorizes it. By this, We can see how much we spent on each category.

Conclusion:

Now after setting up everything I can sit back and enjoy, while my transactions are automatically updating to the wallet app via lambda every month. Do you have any related tips or questions? Please share them in the comments section below.