tl;dr — what is it anyway and will it help you with next project?

The problem

Let’s jump straight into the problem. We have users api with permisions handling. Nothing extraordinary. A bug occurs. You look into database it turns out that user has no permisions of any kind assigned at all. How could it have happened? The api doesn’t allow it. All we have is database state as it is, we have no idea what caused this state o application.

It’s even worse, there is no way to retract database to the moment when it happened without making backups every second…

tl;dr - when should I use CQRS design pattern and stay sane.

When building an API the typical practice is to divide it into parts, simplest would be presentation, service / business logic and data access layers

3-layer architecture

There is nothing wrong with this approach but questions araise when application becomes bloated and unreadable.I prepared simple user’s microservice with basic functionality to make case-study on it. But first things first.


Must be mentioned before. It stands for Command-query Separation. The simplest explanation would be:

In the previous part I’ve explained how to create api for real-time application. No it’s time for front-end. It was created with Vue cli version 4.1.1.

Similarly to api let’s look on router which binds together all business logic.

Main router

Here I’ve created two main components: Outer and Dash. The first one is responsible for non-logged-in part of application. Examples of this are help page or login form. From code perspective it sets language in localization module based on the browser language. Let’s look into it for a moment.

Culture and localization

Localization component

As you can see I’m using I18n plugin…

A couple months ago me and my team faced a challenge of designing a real-time application with REST support for external microservices. The problem was the necessity to choose or develop design pattern for modular and scalable api based mainly on client and server side events implemented by web sockets following model view presenter design pattern. In this article I’m going to present results of this considerations as well as example application, service for online notes, built upon mentioned principles available at

Application is built with Node.js 12.14.0 LTS using TypeScript and split into following categories:

  1. Logging
  2. Data model

Mateusz Fonfara

Full-stack developer with passion towards data science

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store