This is a part of a series of articles around a personal project I've been meaning to do for years. My wife and I have used a spreadsheet to track our finances and I wanted to make it more automated and mobile. I wanted to make it an app. I've felt I've reached a point in my skill-set to go forth and finally make this happen. Writing about it allows me to externalize my thoughts, but also get support from the community along my journey to make this a reality.
My tech stack so far:
Backend
- AWS Lamba
- AWS API Gateway
- AWS DynamoDB
- ClaudiaJS to make sense of it all
- NodeJS for my endpoint language
Frontend
- Maybe React Native? Maybe Cordova with React? Needs to work on Android and iOS.
You can follow along in my progress at #jellyfin
So, I've decided to go with Claudia.js over the Serverless framework and let me tell you, it's gone a lot smoother to get up and running otherwise. I was able to quickly get endpoints up this way.
So, let's talk about transactions. This is a personal finance application, so its main goal is to keep track of bank transactions. I'm storing the basics like amount, payee, and date.
AWS makes it easy to get all transactions back, but that's not something we really do often (in our spreadsheet we use at home). If anything, we look at a month at a time.
It's a spreadsheet, so the nomenclature I'm using is a tab
. I have a function I created called getTab()
which takes two parameters: the year and the month. Using this, my goal is to get a range of transactions starting from the first of the month on to the end of the month.
Once I have that, I need to do some calculations on the data to get useful information from it. We look at the minimum balance as a useful metric to know if we're ever at risk of overdrawing our account. That's an extreme case, but most of the time it's just a nice-to-have knowing you'll have x
in your bank account at the lowest point in the month.
I found this extremely useful chunk of code to help me get the minimum value of an array of objects: Source
function getMinY() {
return data.reduce((min, p) => p.y < min ? p.y : min, data[0].y);
}
function getMaxY() {
return data.reduce((max, p) => p.y > max ? p.y : max, data[0].y);
}
The above is based on this array, but this isn't the model I'm using.
[
{x: 1, y: 14830},
{x: 2, y: 85055},
{x: 3, y: 03485},
{x: 4, y: 57885},
// ...
]
My challenge, though, is not so much to get the minimum amount from a group of transactions but to get the minimum balance that's calculated from these transactions. To do that, I would need to know the starting balance (which I think I'll store either as a transaction or as a field in a user account (which I haven't created yet).
There's other stuff I want to pass down in this getTab()
function, too. I want to know:
- A list of all transactions for the month
- A list of sums of unique categories of transactions (e.g. Spent $43 on gas over 3 transactions; $200 on groceries)
- Sum of all income
- Sum of all expenses
- Net of 3 and 4
- Beginning Balance (entering the month)
- Final Balance (leaving the month)
- Minimum balance for the month
While this is a personal project, I was considering making this open source, but not unless I had some contributors. What's open source without an active contributor-base?
If you're interested in contributing, let me know. Otherwise, I'll keep plugging away and writing more articles. :)
Top comments (0)