Sinatra - Project Tracker

Posted by Mark Kanko on July 15, 2019

With my Sinatra Project completed and ready to submit, I am left with the last little detail of writing a blog post about my project and the learning experience.

Approaching this project was quite a different experience than our first project. Having already been through the process of building out a project, the second time around was a lot more fun. The fact that the process involves implementing all the concepts and skills learned over a period of weeks and let’s face it, how good are these new skills and how thorough is our understanding of the concepts at this point. In my case, I was in all too familiar territory, my head swimming with all the new concepts, which are just more complex abstractions of the previous concepts we have come to understand quite well. No matter how fragmented my understanding at the beginning, the building process itself and putting all the moving parts together really facilitates a much more comprehensive understanding and complete knowledge of all the material we have covered to date.

The requirements of our project were to build a simple content management system implementing MVC (Model, View, Controller) architecture within a Sinatra Web Framework (environment) which implements ActiveRecord to provide a user (CRUD actions) - the ability to create data resources that can be persisted to a database, retrieved to read, retrieved to be edited/updated, and/or deleted. The web application will need to sign up a user with a password that will be encrypted and can be authenticated. Our web application needs to be able to keep track of the user as the user moves from one page within our web application to another. This is achieved through the implementation of Sessions, Cookies, and Session Secret.

Throughout all and at the heart of our web application is the MVC Architecture.

On the backend of the web app is a data base that is accessed by our model. The model is a template with the singular responsibility of instantiating objects with attributes using data that has been persisted to the database. These objects are mapped to a database table that has datatypes with values. This object relational mapping and the database queries through SQL (standard query language), in our case SQLite3 and all the code required to query the database and map objects to the rows and columns of tables is handled by the powerful meta-programming of ActiveRecord. On the other end (front-end) of our web application is the view. The view’s singular responsibility is to display web pages to the user with the requested content. A view is comprised of HTML code styled with CSS, and inside of the HTML is Ruby code wrapped in erb tags to facilitate Ruby executing inside of HTML.

Interacting between the backend and the front-end is the controller class that directs traffic so to speak. The controllers contain Ruby code to implement the necessary logic and execute the Restful Routing which is a uniform and conventional means to provide mapping between the HTTP verb requests (get, post, put/patch, delete) associated with URL addresses and the CRUD actions/ functionality. My web app is called Project Tracker. As a former Building Contractor and PM, I decided to build an app that Project Managers could use to track their building projects. So, my app has two models, a User (Pm) model and a Project model. With three controllers. A User (Pm) has many projects and projects belong to user. This has many/belongs to relationship sets up the associations between models and provide methods relative to those associative relationships that are inherited from ActiveRecord.

I had a lot of fun building this Sinatra Web App, but more than the fun, I am excited that all the loose ends and fragmented understanding has come together into a complete and more robust understanding conceptually. Looking forward to Rails and looking forward to the Rails Project because I know that it will be the project build that will be the most valuable learning experience. You have to build the project to understand all the concepts you have covered working towards the project.