Reading Length 2.0 - Technical design

Reading Length 2.0 - Technical design

The version of Reading Length in production at the time of this writing is a Node app which uses Jade for templating the front-end, Express for routing, Nginx for the server, PM2 to make sure it stays up, and MongoDB for the data. It's all hosted on one $10 DigitalOcean droplet. This works, but it doesn't fit my needs.

Breaking up the server

For the redesign, I want to be able to scale up different pieces of the system as needed. If there's a lot of traffic, ideally I could scale up the front-end hosting temporarily. If, after a few years, my data storage gets too large, I want to have the option of adding on additional storage, rather than upgrading the whole package. One part of the system going down shouldn't take everything with it as well.

To achieve this, I will break up the system into three different servers: one for storage, one for data, and one for the front-end.

Storage

The database I will be using is MongoDB. I was raised as a devout relationalist, having taken multiple data design and database architecture classes. However, NoSQL is sexy and there are services that abstract away the need to carefully design or even manage your database. One such service is Prisma.io, which I will be using to create a GraphQL wrapper for the mongo database.

Data layer

I will be using Apollo as the data layer, what is traditionally the 'back-end'. Apollo will hold all of the data models and provide an API for the front-end to query and mutate data in the the database. The data layer will also communicate with external APIs and handle user authentication.

Front-end

NextJS, developed by Zeit, is the best React framework out there at the moment when it comes to integration with Apollo and provides features such as optional server side rendering (useful for search engine optimization), state management without having to use Redux, prefetching, code splitting, and intuitive routing without having to use React Router.

Hosting

Since I have three different servers, I will likely need three different hosting setups. I could put everything onto DigitalOcean since it's what I am familiar with, but I want to explore other options for exposure to new technologies. At the same time, I don't want all of the servers to be too spread out, geographically. As such, I will be hosting both the NextJS and Apollo servers on Zeit's Now platform since they both have strong compatibility and continuous integration support. I will be keeping Prisma and MongoDB on a DigitalOcean instance since DigitalOcean makes it easy to add storage as you need it.

Photo by Spencer _ on Unsplash

Bridger Putnam

Bridger Putnam

Full Stack Developer

January 5th, 2019