Financial plan on Rails

My previous post Financial plan on PostgreSQL shows how to build primitive software that helps with financial planning. Unfortunately, not everyone can use it, because it needs SQL knowledge. In this post, you will see how to reuse those post results to make a user-friendly web application built on Rails.

That’s the application in action we are going to make in a moment:

Financial plan ActiveAdmin

Tools

Rails is a handy web development framework that saves a ton of time to build a Proof of concept (PoC), a Minimum viable product (MVP), a pet project, that later can be extended dreadfully. Eventually, a Rails project can turn into a unicorn such as Shopify or Twitter.

Furthermore, with additions like ActiveAdmin we can build a web application in a moment with no front-end code writing. That’s too beneficial since building user interface (UI) takes much time. But for a starting project (PoC, MPV) UI is not very critical.

To minimize development time as much as possible we take Rails and ActiveAdmin. In the end, we will have a ready to use web application that’s ready to any changes in the future.

Requirements

Usual app usage will look like that:

  1. Create a plan with some name.
  2. Add income and expenses to it.
  3. Observe the calculated plan within a table.

Later the expenses and incomes can be adjusted or added even more. The results should be recalculated immediately.

Implementation

According to the requirements, the application should have the following entities: Plan and Income with Expense belonging to the Plan.

In short, we should do these steps:

  1. Define these entities on a fresh Rails app with several Rails generator’s commands.
  2. Create thew view with results from the Financial plan on PostgreSQL post. I prefer Scenic gem for that. In short, it’s very handy, especially when it comes to amending views in the future.
  3. Create a model that uses the views as a data source. Note, normally a Rails model takes data from a table, but here I’m going to use the view (a virtual table) to feed the model.
  4. Install the ActiveAdmin gem into the project and configure it to use the defined models above so that users can create a plan, add incomes and expenses, and finally see the results.
  5. Deploy the code onto hosting so that the app can be used by everyone. I prefer Heroku for that: it’s free for small projects that serve not many users at a time.

The final code lives here and this is the live app.

Further, the app can be easily extended. For example, it can take into account one-off expenses and incomes.

Building this application and publishing it on the Internet took just only 2 hours. All of that’s thankfully autogenerated UI by ActiveAdmin. Rails generators created models and defined their tables and relations between them. ActiveAdmin configuration also took some time. And finally, Heroku provides the infrastructure to publish the code online too fast, with no configuration.

For sure, all of that is not for free: it requires special knowledge and experience working with the gems and the taken approach.

In this article, you saw how to transform a raw idea that’s implemented on pure SQL into a Web application.

Conclusion

This post demonstrates how a primitive subtask solution (financial plan on PostgreSQL) can be reused by a more complicated and important task that’s a ready Web application.

Nowadays, the mix of technologies around Ruby allows to build mature soft fast.