Menu

Building a Modular Decoupled Backend using a Monorepo
📰

Building a Modular Decoupled Backend using a Monorepo

DEV Community: koa·Sibelius Seraphini·8 months ago
#IjJVxuyT
#devtokoa#devto#dev#apirouter#router
Long article (597 words) — no AI summary yet.
Reading 0:00
15s threshold

There are a lot of articles about why you should decouple your backend to move faster, but very few content on how to practically do it.

This article is a practical approach that we use at Woovi to decouple our backend endpoints breaking them into packages in a monorepo.

As we scale we can easily convert them to their own microservices.

Creating a decoupled backend

We should first start designing what endpoint patterns we are going to expose.

In the image above we have five patterns: /login , /register , /home , /api , and /provider .

You can think about each of these patterns as separate services, but we will deploy them in a single service to simplify deployment and maintenance.

For each endpoint pattern, we are going to create a package in our monorepo, and each package will have its own Koa Router.

The monorepo for these 5 "services" will be like this:

packages - login - register - home - api - provider

Enter fullscreen mode

Exit fullscreen mode

A sample koa router code is described…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.