Blog of Fregiva

The server structure

Let’s get technical! Here’s the server structure of Fregiva. Below, I’ll describe every step and it’s benefits.

The server structure of Fregiva

1. Get static files from Cloudflare

Every page you load from will come from a CDN called Cloudflare. Basically, it spreads the files to different servers around the world. When you request a file (e.g. a FAQ), it routes you to a server near to you. This assures a fast delivery of the file. This also means, that every page and file you get from is static. No dynamic content from any database is delivered. The server doesn’t have to do stuff like fetching data from a database before delivering the file. That’s good for the websites speed.

2. Communication with Firebase

Firebase is my choice of backend service. The app just communicates with their servers – in realtime over websockets. That provides a neat performance for every interaction you make in the app. Firebase is easy to set up, safe and provides many of the functions you expect from a backend like log-in-functionality and saving the users data. For some functions, you’ll have to write your own code:

3. The Node Backend

While Firebase is good for most tasks, some have to be done by a custom backend. For example, the creation of static content is not possible with Firebase alone. Fortunately, you’re able to use the same Javascript API of Firebase that also runs in the browser with a NodeJS backend. You can watch for events (like a deploy of a FAQ) and then execute a function in NodeJS. I like NodeJS because it’s fast, you can write Javascript in the backend like in the frontend and there are tons of usable packages for it. Like the one for Amazon S3:

4. Amazon Simple Storage Service

The static files are stored in S3, a storage service by Amazon with unlimited capacity, nice uptimes and low prices. There’s a NodeJS Library for uploading or deleting files. If the NodeJS catches a deploy event, it will create the HTML code for the FAQ and upload it to S3 directly. I can store it as a static file with nearly no downtime at all! Users of Fregiva can be shure to be able to get the FAQ everytime they need it – even if the NodeJS or Firebase backend is down. That’s one important point when you want to deliver something for other peoples which use it on their websites.

5. Spread the static files

After the FAQ is uploaded to S3, Cloudflare automatically pics up the static file and spreads it to their servers around the world. Everyone is now able to get it fast, secure and with no downtime.

I’m pretty happy with this structure. What do you mean? Are there downsides?

wrote this on October 15.

Benjamin Kowalski

Get our RSS Feed!