Mark Tobin Projects Articles Github

Web-dev

My Portfolio. The architecture, db and setup

How the backend of the website was created.

By Mark Tobin

Main Image

The initial MVP

The original specification for this website was to setup a very basic informational website as part of the web development course at my college (NSCC). To do so, the instructor walked us through many basics including how to format HTML tables, how to color and change elements and generally how to solve problems. Ironically enough at the end of the semester I was very close to not even passing.

The initial requirement for the website included having a few endpoints which referenced pages in the navbar. This included things such as a resume, a github account, a skills section etc. I was fairly proud of what I was able to accomplish within the semester. I ended up getting a decent final grade for the assignment and continued working on the website far after the project was submitted.

The Architecture

Being the most comfortable in python, the clear choice for what to use as the web framework was either django or flask. After being able to quickly run through a quickstart with flask I decided that it was going to be what I was doing to use to build my website.

Choosing a database is something that became a recurring point of confusion for me. Going to college for data analytics, a lot of the classes were taught using MS SQL server. SQL server has loads of really good features that make it a great option to choose. They have sensible syntax for creating stored procedures for databases. School taught me how to use SQL server with SSMS (SQL Server Management Studio) which made working with the database far easier than any other solution I've come across since. That being said, they have many disadvantages that makes it nearly unusable for my use case.

The main issue is the pricing. SQL Server standard edition in Canada, as of 7/21/2023 costs $4,686.00 for just licensing. While there is a "free tier" to SQL server called SQL server express, using it would be a massive mistake. Some of the infuriating restrictions for this "free tier" is a 10GB max DB size, 1GB max memory usage, 1MB max buffer cache and can only use 4 CPU cores. This pricing model I find completely repulsive however I suppose SQL server isn't specifically designed or priced for dev blogs.

Options such as MySQL also exist however the best database software that I've found is PostgreSQL. It is an open source DBMS that doesn't cost a car and most importantly doesn't feel like they are setting me up for failure.

That being said, instead of going for any of the previously mensioned options, I decided to go with sqlite. I have a fierce love hate relationship sqlite. With sqlite you can store the entire DB in a single file which makes backups as easy as copying the file somewhere. That being said, each connection you must manually enforce referential integrity by using a special command on the connection. The only way to have this on by default (as it should) is to use special compile time options. That being said, you don't need an external server for hosting the database on and because my usecase doesn't require changing the data I can just have the database file with my website files inside a docker container.

And finally the front end framework. For this website there is no frontend framework beyond Jinja2 (a default templating engine with flask). I understand why something like react could be very helpful for designing websites that can do more, however I just don't think that I need to have the added complexity of a frontend framework is worth the positives one could provide.

Hosting is done with digital ocean. Digital ocean makes it really easy to link your server to a git branch and your website update any time there is a change in the code. With changes there is 0 down time and for the scale I work at, this is more than enough.