Cloudreach .create() hackathon
I took part in the first Cloudreach Hackathon known as .create(), and the first in a series, Cloudreachers from across the globe got into teams of 2-3 to create something – with the theme being to “Create something which improves someone else’s life at Cloudreach”.
We only had a couple of restrictions this time around and they were:
- Use an AWS service released in the last 6 months
- We had 48 hours (we took 12)
- Code must be documented
And from this – my team was born. #TeamKestrel. Made up of myself (The Captain), Adam Ocsvari (HaDam), Rafal Jankowicz (Big Daddy) and Mixer the dog. Our name was supposed to be the Polish translation of Hawk but due to some linguistic issues by our resident Pole, we got to Kestrel before we realised it was the wrong word from Polish. Oh well! Team Kestrel it is.
So what did we do?
Well as the title reveals, we decided to focus on automating expenses; using Serverless technology in AWS and the Developer API made available by the bank Monzo. I’ve been obsessing about and flying the Monzo flag now for a few months now. Long story short – It is an awesome bank that I think are doing and going to do awesome things with banking – from the immediate viewing of your transactions to very in-depth searching and analysis features of your transactions and spending.
One of the awesome features built into Monzo is the ability to mark your transactions as a different category. In our case, Expenses is one of them. You can also add an image straight to the transaction… receipts! and you can add a note too – Project code etc.
Using this information along with the merchant and date, we could create an expense entry in our company finance system – Financial Force.
How did we do it?
After figuring out we could get the information we needed from a transaction, it was time to dig into the documentation for Monzo’s developer API. The API functionality that Monzo provide is simple yet powerful, allowing us to read user transactions, set up webhooks and even add extra information to a user Monzo feed. Using an OAuth2 flow, we were quickly able to set up a secure authentication flow that ended with a time-sensitive token to a user’s account.
We would then store this secure token in a DynamoDB table and use KMS encryption for an extra layer of security.
Once we had the key, we were able to scan a user’s transactions for a specified date range – this would be 1 week on the first scan then 1 day on each subsequent scan going forward. Once we had transactions for the period and had filtered it down to only the ones that were marked as expenses, we could then do some extra processing to see what we had to work with.
The data processing was required to make sure we had the minimum amount of data required to create an expense, in our case a Project code. This is needed to be able to assign an expense to an internal or external project – the rest of the information was either always available (date, merchant etc) or optional (image).
For each transaction that was tagged as an expense, we would give it a rating made up of its completeness – 1 being it only had the correct category, 2 indicated it had a project code and 3 meant that the transaction also included an image we could upload. Transactions that matched our criteria would then be stored in our DynamoDB table so we could deal with duplicate and incomplete expenses down the line.
Finally, after processing we would send our transactions that were ready to be uploaded to FinancialForce to an upload endpoint. The purpose of this endpoint was to map Monzo categories to Expense categories and build up descriptions based on the merchant name and the category. It would also deal with image upload and even pass said image through AWS Rekognition – AWS’ Image analysis service that we decided to utilise as our Service released in the last 6 months criteria.
This last part was particularly cool as we were able to use AWS to figure out how likely it is that the image uploaded contained an actual receipt. It is scarily accurate
Our finished product, in this case, was a system we could reliably use to upload expenses from Monzo to Financial Force. To test this in the “real world”, I used my Monzo card whilst away on a customer project in Nottingham – adding the required info to my transaction and then seeing it appear in FinancialForce ready to submit. Amazing and super satisfying to see working!
What did it look like?
Our project was all built on Serverless infrastructure and you can see an overview of what made up our project below