onestopjs

by Martin Koparanov

0%

Person holding phone with the website on it

Aktuella Nyheter


Aktuella Nyheter (Current News in English) is a website I made for a Swedish client, with me being the sole developer for the whole platform.
It is simply an automated news aggregator for currently trending topics.

For every topic, you could choose between many articles from multiple sources.

How?

The sourcing of trending topics and articles for them was my client's idea, so I won't give that secret away.

All the topics and articles related to them are saved in a database. A large volume of data was expected, so I chose MongoDB for its scalability and simplicity.
Indeed, in just a day, thousands of articles were added.

Article images were copied locally because we did not want to rely on external providers for that, plus some of them had no SSL, which was not cool. The client was okay with using a lot more storage, so we just decided to host the images ourselves.

The data was updated all the time - as often as the external providers allowed to be queried. This means that the topics are very recent. If you open the website for your country, it would be all you need to be in touch with recent events.

Oh, and yes, it was developed to be easily deployable for multiple countries, just by updating some strings for translations.

Technologies

Frontend

SEO was, understandably, of utmost importance for my client, so I chose to use NextJS (+ TypeScript) for its Server-Side Rendering capabilities.

Since there is no login functionality, all pages were the same for all users, so I decided to implement a simple short-lived in-memory LRU cache on the frontend's server to reduce the load on the backend. The LRU cache prioritized the most visited pages (i.e. the homepage).

Here is what the website looks like, designed by my client:

Desktop view of website
Mobile view of website

Backend

The backend was written in NodeJS, paired with TypeScript.

Since building the homepage was relatively computationally expensive, I implemented a simple cache with Redis, cleared every time the data is updated.

As mentioned, for a database I chose MongoDB because it is relatively simple to scale horizontally. We never got to that, but I wanted to future-proof it as much as possible.

CMS

For a CMS (or Content Management System) I choose Strapi since it allowed a lot of customization. It was integrated with the backend, so my client could edit topics/articles on the fly.

The CMS also had its own layer of quite heavy caching, since querying the database for ALL its content every time you open the CMS is, as you can imagine, problematic.

Unfortunately, having a lot of cache is also problematic when you want to update something as soon as possible. So, the compromise was to make the backend notify the CMS every time something changes, so the CMS is always up-to-date, without querying the whole database all the time.
This added a bit of unwanted complexity, but the runtime performance is great, so the trade-off was worth it.