Decoupling in Practice

Rate this content
Bookmark

Deploying decoupled and microservice applications isn't just a problem to be solved on migration day. Moving forward with these architectures depends completely on what your team's workflow experience will look like day-to-day post-migration.


The hardest part of this can often be the number of vendors involved. Some targets are best suited for specific frontend frameworks, while others are more so for CMSs and custom APIs. Unfortunately their assumptions, workflows, APIs, and notions of security can be quite different. While there are certain advantages to relying on a strict contract between apps – where backend and frontend teams work is limited to a single vendor – this isn't always realistic. This could be because you're still experimenting, or simply the size of your organization doesn't allow for this kind of specialization just yet.


In this workshop, you'll have a chance to explore a different, single vendor approach to microservices using Strapi and Next.js as an example. You'll deploy each app individually, establishing a workflow from the start that simplifies customization, introducing new features, investigating performance issues, and even framework interchangeability from the start.


Structure:

- Getting started

- Overview of Strapi

- Overview of Platform.sh workflow

- Deploying the project

- Switching services

- Adding the frontend


Prerequisites:

- A Platform.sh trial account created

- The Platform.sh CLI installed

This workshop has been presented at Node Congress 2023, check out the latest edition of this JavaScript Conference.

FAQ

Chad Carlson's workshop at Node.Congress focuses on deploying a decoupled architecture using Platform.SH, involving a front-end framework like Next.js and a back-end CMS like Strapi.

Platform.SH is a platform as a service provider that supports a wide range of frameworks and runtimes, including Next.js, Gatsby, Nuxt, Express, Remix, Django, FastAPI, Drupal, and Magento. It allows for deploying both front-end and back-end applications in a single environment, enabling seamless workflows and easier management of development environments.

Using Platform.SH provides several benefits, including the ability to deploy both front-end and back-end applications in a single environment, automated creation of development and staging environments, easy sanitization of databases for development, and simplified handling of data migrations and API changes.

Strapi is a headless CMS that provides a UI for defining collections like blog posts, users, reviews, and categories. In this workshop, Strapi is used as the back-end CMS to build an API that is consumed by a Next.js front-end for a restaurant review website called FoodAdvisor.

Platform.SH allows data to be inherited across environments, making it easy to create development and staging environments that mirror production. It also supports easy sanitization of databases to exclude or obfuscate sensitive data.

Platform.SH supports a variety of runtimes and frameworks, including Node.js (Next.js, Gatsby, Nuxt, Express, Remix), Python (Django, FastAPI), PHP (Drupal, Magento), and many others.

You can integrate a GitHub repository with Platform.SH by creating a GitHub token with public repo and admin repo hook permissions, and then using the Platform.SH CLI to add an integration of type GitHub, linking it to the repository and project ID.

The .platform.app.yaml file in Platform.SH is used to define the configuration for an application container, including the runtime environment, build commands, start commands, and any specific settings like writable directories or environment variables.

You can add email support to a Strapi application on Platform.SH by updating the .env file to include email-related environment variables and creating a config/plugins.js file to configure email settings using a provider like NodeMailer.

To use a production database like PostgreSQL with Platform.SH, you need to add a services.yaml file to define the database service, update the .env file with the database-related environment variables, and create a config/database.js file to configure the database connection using those variables.

Chad Carlson
Chad Carlson
102 min
11 Apr, 2023

Comments

Sign in or register to post your comment.
Video Summary and Transcription
Platform.SH is a platform as a service provider that supports various frameworks and runtimes. In this workshop, a two application project called food adviser is deployed using Next.js as the front end and Strapi as the back end. The process involves creating a Strapi application, managing content collections, building the Strapi API, setting up the database and admin panel, deploying the project to Platform.SH, integrating with GitHub, configuring routes, and deploying the backend. The workshop also covers deploying the frontend, configuring the frontend and backend, and additional topics such as email settings in Strapi.
Available in Español: Desacoplamiento en Práctica

1. Introduction to Platform.SH

Short description:

Hello, I'm Chad Carlson, the DevRel team manager at Platform.SH. We provide a platform as a service with support for various frameworks and runtimes.

Hello again, my name is Chad Carlson. I manage the DevRel team at Platform.SH. This is my second Node.Congress, second time doing a workshop. Previously, I did a version of this one as well.

My background is primarily in Python, but since working at Platform, I had been tasked a few years back to do a lot of the exploration on this decoupled topic on our platform. And a lot of the time, or certainly when I've come across it, and what many people do, is they will often have two separate targets for deploying a front end and back end of an architecture like this whether that's many, many microservices or just the back end CMS and your front end of framework of Next.JS or Gatsby, whatever it may be.

So what makes platform a little bit different is that, first of all, we're a platform as a service provider, and we don't have any restrictions on the types of frameworks that you can deploy on our platform. So that can be Next.js, Gatsby, Nuxt, Express, Remix, but it can also be Django, FastAPI, Drupal, Magento, all these different things that may fall into a number of different runtimes. So we have support for all of them.

2. Deploying Multi-App Projects on PaS

Short description:

Platform.SH is a platform as a service provider that supports various frameworks and runtimes. It allows you to deploy applications using different frameworks and runtimes, such as Next.js, Gatsby, Nuxt, Express, Remix, Django, FastAPI, Drupal, and Magento. Platform.SH also allows you to add resources to a singular environment and deploy copies of containers across each environment. This is especially helpful for security and data obfuscation, as well as making changes to both the front end and back end simultaneously. In this workshop, we will deploy a two application project called food adviser, with Next.js as the front end client and Strapi as the back end headless CMS. We will explore the logic of the back end, configure the platform, and deploy the project to production.

So what makes platform a little bit different is that, first of all, we're a platform as a service provider, and we don't have any restrictions on the types of frameworks that you can deploy on our platform. So that can be Next.js, Gatsby, Nuxt, Express, Remix, but it can also be Django, FastAPI, Drupal, Magento, all these different things that may fall into a number of different runtimes. So we have support for all of them. If you are interested at all, we'll probably be hopping back and forth between the documentation while we're doing things. Here is our public docs, and all of the runtimes, all the programming languages that come with built-in support on our platform.

So as we'll see in a little bit, if I want to define an application that uses Node18, I can do that while at the same time, say I'm pulling from a backend Drupal CMS, which many of you are probably familiar with, you have my content team in the back, I can deploy that with this same type key but using PHP 8.2 instead. And on top of that, instead of having sort of this language-agnostic support, we also allow you to continue to add resources to a singular environment, whether that's production, staging, or development so that you can deploy copies of these containers across each environment. So when I was talking about if I've got two different deployment targets for front and back end, separated workflows and separated teams as we're making changes to the front and back end. But on Platform, as we'll see, I can have in a single environment in what we'll call a project for our repository for a fully deployed set of applications that has the front and back end included in that single environment. And then as we make changes, I create a new branch, a new environment. I'm going to get exact copies of both of those app containers across each environment. And so it's not necessarily going to be the most important thing all the time for developing new features. But two reasons that I've come across, this becomes especially helpful. One is the security and PII, personally identifying information, angle. If we have a production website that users are logging into and we want to create development environments for any particular change. It's very easy within this model to sanitize the database to exclude obfuscate or totally fake that kind of production data in these environments. All becomes part of the same workflow. And then the second is if we're doing any kind of migrations of adding a different front end or adding a secondary front end for mobile or whatever the case may be, And we need to not just make changes to the front end or just to the back end, we're really dealing with changes to that contract in the middle of that API. So we may need to make changes to both apps simultaneously. So it becomes really helpful to have them in their own set aside environment in order to do that.

So that's a quick on the project, what are we going to be doing today. So our goal here is to deploy a two application project on our platform on platform SH, and the project that we're going to work on is called food adviser. So I'm sure many of you are familiar with next JS, that's going to be our front end client. And it's going to be consuming data from a back end headless CMS called strappy. If you haven't heard of it, it's it's simply provides a UI for defining collections, whether that's a blog post or in this case the thing we're deploying is a restaurant review website that includes blogs, users, reviews, restaurants, food, categories, things like this. Strapi makes it pretty easy for you to build those content types in the UI in the back end, to then put together this production API that can then be consumed by something like Next JS. And so even for Strapi, which they're, this is their main demo. And I claim no credit on developing the applications themselves, but we can take a look at a little bit of how they're put together to understand the logic of, especially the back end of Strapi. And then add the platform configuration around it to deploy it to deploy this thing to production. So that's where we'll be focused on today. So, I am going to share a link with all of you. So this is a repository that I've set up for us to go through this workshop, so I will add it both to discord and to the zoom chat. And so it's basically the starting point of, of how we're going to both build this demo and then deploy it piece by piece. So let's get rid of that for now. From this main repo that I just shared. Right, sorry. Let's do the users templates, and let's just create a new one in our namespace. And we're going to just do all that. So this is me. If you have any questions, I'm pretty much Chad W Carlson on everything. Chad Carlson has taken on pretty much everything. So we're going to go ahead and clone this repository locally. And so while that's going, the way that this is sort of structured is a brief description of the workshop is in the main read me license information for the upstream food advisor demos included in this front note, and then a. Excuse me, structure of what we're going to be going through is included here. So like I said goal here is to talk a little bit about this back end and how it's put together. Deploy it, connect to the front end. And then if we do have some time, start talking about what it would mean to start switching to production services and developing new features like adding email support. Most of the steps are going to be inside this help steps set of sub directories, and then client is the front end code which we'll we'll get to towards the end. Let's see is this done, yes. Alright, so let's open this in VS code.

Watch more workshops on topic

Decomposing Monolith NestJS API into GRPC Microservices
Node Congress 2023Node Congress 2023
119 min
Decomposing Monolith NestJS API into GRPC Microservices
Workshop
Alex Korzhikov
Alex Korzhikov
The workshop focuses on concepts, algorithms, and practices to decompose a monolithic application into GRPC microservices. It overviews architecture principles, design patterns, and technologies used to build microservices. It covers the theory of the GRPC framework and protocol buffers mechanism, as well as techniques and specifics of building isolated TypeScript services in the Node.js stack. The workshop includes a live use case demo of decomposing an API application into a set of microservices. It fits the best architects, tech leads, and developers who want to learn microservices patterns.
Level: AdvancedPatterns: DDD, MicroservicesTechnologies: GRPC, Protocol Buffers, Node.js, TypeScript, NestJS, Express.js, PostgreSQL, TurborepoExample structure: monorepo configuration, packages configuration, common utilities, demo servicePractical exercise: refactor monolith app
How to develop, build, and deploy Node.js microservices with Pulumi and Azure DevOps
DevOps.js Conf 2022DevOps.js Conf 2022
163 min
How to develop, build, and deploy Node.js microservices with Pulumi and Azure DevOps
Workshop
Alex Korzhikov
Andrew Reddikh
2 authors
The workshop gives a practical perspective of key principles needed to develop, build, and maintain a set of microservices in the Node.js stack. It covers specifics of creating isolated TypeScript services using the monorepo approach with lerna and yarn workspaces. The workshop includes an overview and a live exercise to create cloud environment with Pulumi framework and Azure services. The sessions fits the best developers who want to learn and practice build and deploy techniques using Azure stack and Pulumi for Node.js.
How to Convert Crypto Currencies With GRPC Microservices in Node.js
JSNation 2023JSNation 2023
117 min
How to Convert Crypto Currencies With GRPC Microservices in Node.js
Workshop
Alex Korzhikov
Andrew Reddikh
2 authors
The workshop overviews key architecture principles, design patterns, and technologies used to build microservices in the Node.js stack. It covers the theory of the GRPC framework and protocol buffers mechanism, as well as techniques and specifics of building isolated services using the monorepo approach with lerna and yarn workspaces, TypeScript. The workshop includes a live practical assignment to create a currency converter application that follows microservices paradigms. It fits the best developers who want to learn and practice GRPC microservices pattern with the Node.js platform.
Prerequistes:- Good understanding of JavaScript or TypeScript- Experience with Node.js and writing Backend applications- Preinstall Node.js, npm- Preinstall Protocol Buffer Compiler- We prefer to use VSCode for a better experience with JavaScript and TypeScript (other IDEs are also ok)
How to Convert Crypto Currencies with Microservices in Node.js and GRPC
Node Congress 2022Node Congress 2022
162 min
How to Convert Crypto Currencies with Microservices in Node.js and GRPC
Workshop
Alex Korzhikov
Andrew Reddikh
2 authors
The workshop overviews key architecture principles, design patterns, and technologies used to build microservices in the Node.js stack. It covers the theory of the GRPC framework and protocol buffers mechanism, as well as techniques and specifics of building isolated services using the monorepo approach with lerna and yarn workspaces, TypeScript. The workshop includes a live practical assignment to create a currency converter application that follows microservices paradigms. The "Microservices in Node.js with GRPC" workshop fits the best developers who want to learn and practice GRPC microservices pattern with the Node.js platform.

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

How to Build CI/CD Pipelines for a Microservices Application
DevOps.js Conf 2021DevOps.js Conf 2021
33 min
How to Build CI/CD Pipelines for a Microservices Application
Top Content
This Talk discusses the benefits of microservices and containers for building CI-CD pipelines. It explains how container technology enables portability and scalability. The challenges of microservices include network communication and testing in isolation. The Talk introduces Tacton, a cloud-native CICD pipeline for Kubernetes, and highlights the use of GitOps and Argo CD. It also discusses the importance of maintaining referential integrity between microservices and the evolving role of operators in the DevOps world.
Micro-scopes – How to Build a Modular Modern App in a Bundled World
JSNation Live 2021JSNation Live 2021
21 min
Micro-scopes – How to Build a Modular Modern App in a Bundled World
This Talk discusses the importance of bundling code in the modern JavaScript world and introduces Webpack as the de facto standard for bundling modules. It explores techniques such as code splitting, multiple entry points, and controlling the build process to optimize code organization and improve performance. The Talk also delves into concepts like Universal Model Definition (UMD) and using externals in Webpack to avoid code duplication. It highlights the benefits of separating and maintaining code in an application, as well as the use of micro-frontends and monorepos for scalability and collaboration. Overall, the Talk emphasizes the significance of code separation, dependency management, and efficient bundling strategies for developing robust and modular applications.
Optimizing Microservice Architecture for High Performance and Resilience
Node Congress 2024Node Congress 2024
24 min
Optimizing Microservice Architecture for High Performance and Resilience
Today's Talk discusses microservices optimization strategies for distributed systems, specifically focusing on implementing casual consistency to ensure data synchronization. Vector clocks are commonly used to track the casual relationship between write events in distributed systems. Casual consistency allows for concurrent and independent operations without synchronization, maximizing parallelism and system resource utilization. It enables effective scalability, better latency, and fault tolerance in distributed systems through coordination, resilience, reconfiguration, recovery, and data replication.
Building and Operating a Modern Composable Monolith
DevOps.js Conf 2024DevOps.js Conf 2024
19 min
Building and Operating a Modern Composable Monolith
In this talk, Luca introduces the concept of the modern composable monolith and discusses the challenges of microservices. He emphasizes the importance of developing modular monoliths and introduces Fastify and the Platformatic Runtime as tools for this approach. The Platformatic Runtime simplifies running modular, monolithic applications, and standardizing interfaces and communication is crucial in this context. Lastly, Luca introduces Meraki as a UI-driven tool for building composable monoliths and invites developers to join their marketplace for revolutionizing the operational experience of microservices.