Prediction Project: Architecture
Pretty much my only architecture requirement was “Use tools I enjoy using”. But when I started this project I didn’t know any web-dev tools, so I did a brief scan of the entire landscape first.
Angular 2 (I’d already used AngularJS)
(I didn’t try out every combination of these).
Ultimately I settled on a very standard MEAN2 (mongo, express, angular 2, node) stack. I liked all the tools (I’m saddened by mongo’s data integrity but my database needs are minimal), they were popular in industry, and there was pretty good documentation available.
I didn’t like Meteor, Django, Rails, or Ember - far too much magic. I like having complete control over my projects, and I had no intention of spending enormous amounts of time learning the ins and outs of frameworks I might never reuse.
Knockout, Mithril, and Backbone got rejected on the grounds of having relatively small communities.
Mongo got picked over postgres because I thought mongo would have a nicer learning curve (not sure this is the case now that I know both of them).
Node got picked over every other backend because it’s fast and I suspect it will be the future plus I don’t like using more than one language for a project. (This turned out later to be a good idea: I wrote stuff to autogenerate request routes and I wouldn’t have been able to do this if I wasn’t using javascript on both ends).
Angular 2 got picked over React because I had marginally more experience with the former. I like React though.
The whole project is in Typescript because default javascript is just terrible.
I use systemjs for front end modules, but I might convert to webpack in the future. Nodemon gets used for building and watching. Jasmine gets used for testing. HTTP route testing gets done with a custom library because I couldn’t get the various libraries I looked at to work and this was easier than debugging them.
I ended up writing my own (partial) implementation of JSON web tokens because the available libraries all sucked. I will probably change that to something else entirely once I actually get around to worrying about security.
I didn’t like Mongoose at all so I wrote my own set of functions to eliminate as much boiler plate as I could. I have code to both create data types (with pre-determined database interactions) and to run ad-hoc database interactions more cleanly.
I find writing HTTP routes extremely frustrating (because you have to write them twice) so I wrote code to generate them automatically (given a bunch of information about what the route should do), and then I attached that code to my database management functions so that I can do stuff like create a class, say what routes it should have, and then have everything (routes, database interface, etc.) be generated. This will probably turn into a horrible kludge if I try to make it do anything more complicated though.