
Learn to break a monolith into NestJS microservices using Docker and Apache Kafka, with separate admin, ambassador, and checkout backends and dedicated databases.
Clone and set up the monolith for nestjs microservices, run npm install, start docker compose up, launch the frontends, register and log in users, and prepare for stripe integration.
Create a Stripe account, obtain publishable and secret keys, configure them in front end and back end, install mail hook, test emails, run checkout, and verify admin and ambassador notifications.
Explore the code for a NestJS monolith transitioning to microservices, with Docker compose, backend, database, and Redis; admin and ambassador authentication uses JWT tokens and scope, plus Redis caching.
Explore monolith versus microservices, where a single app houses search, product list, and contact forms. See microservices communicate via internal APIs or a Kafka event bus and scale across languages.
Create the email microservice with no database to handle sending emails, remove that functionality from the monolith, and wire it into the system via Apache Kafka events.
Set up the email microservice, switch to Kafka-based event listening with nest microservices, install the Miller model, and wire the Miller service to send emails when an order is completed.
Set up a Google Cloud account with free credits, launch a Confluent Cloud Kafka cluster, create a default topic, and obtain API credentials to produce and consume messages.
Install and log in to the confluent cloud CLI from the terminal, then run a producer and consumer on the default topic to send and receive messages.
Configure kafka in NestJS microservices with brokers, ssl, sasl, and api keys. Consume and produce messages on a default topic, logging the key and value.
Produce Kafka messages in a NestJS microservice by configuring Kafka transport, wiring the order model to publish to a default topic, and validating with Docker Compose.
Learn to send emails from NestJS microservices by fixing event payloads, stringifying data, and configuring docker mailhook with localhost:1035 to include order total and ambassador/admin revenues.
Build the user microservice after the email service, using internal ESTEP requests instead of Kafka, preparing for its feature-rich, complex integration within the NestJS microservices journey.
Set up the users microservice by scaffolding a NestJS module, configuring Docker Compose and database, and preparing to import data from the next ambassador app.
Import data from the ambassador microservice into the users database by creating a dedicated connection, fetching all users via the user repository, and seeding the database.
Learn http communication in a NestJS microservice as you break a monolith into microservices, implementing a register endpoint with api prefix, validation, cookies, and inter-service axios calls.
Learn how to implement a login endpoint in a NestJS microservice architecture, generating a JWT, setting it in cookies, and handling scope for admin or ambassador roles.
Explore how to retrieve the authenticated user across NestJS microservices by passing cookies and JWTs in request headers, validating tokens, and sharing user data securely.
Store jwt tokens in a database by creating a user token entity and token service, enabling logout by invalidating tokens with created and expiry dates.
Learn to implement logout in a NestJS microservices setup by validating JWT scopes, using a token service to delete user tokens, and clearing cookies.
Complete the auth controller by adding update user info and password endpoints, wiring to the user service and repository, and validating changes via API calls, with future refactor in mind.
Refactor the user service to centralize requests with a base url and a generic request function, add post, get, and put helpers, and streamline login and register with cookie-based authentication.
configure the user microservice to expose an endpoint that returns ambassadors by filtering users, balancing public access with guarded routes and integrating with the existing user service.
Remove the auth module and jwt service. Migrate authenticated user retrieval to the user service and update models and controllers for a streamlined microservice architecture.
Create a user decorator to fetch the authenticated user across controllers, replacing repetitive code and old guards to streamline authentication in NestJS microservices.
Build dedicated Docker networks for microservices to enable secure, internal communication. Assign container names, use external networks, and remove ports to create cleaner, safer inter-service URLs.
Implement scope-based access control in the user microservice by validating JWT, extracting scope, and enforcing ambassador or admin access on routes.
Create the admin microservice with its own database to support the admin frontend and enable communication with the user microservice. Publish events through Kafka to coordinate with other services.
Set up the admin microservice, configure docker files and networks, remove redis, set the admin port to 8000 and connect the admin database, and install validation pipes and cookie parser.
Move the user module into microservices by simplifying the user model, removing shared and unnecessary endpoints, and enforcing admin scope across ambassador and admin services for a streamlined flow.
Move the product module by implementing the product model and service, seed the product data, remove unused admin and shared models, and switch to kafka-driven events.
Move the order module across admin and checkout microservices, using a primary key (not a primary generated column) for orders and order items, with IDs assigned in checkout.
Complete the link module by finalizing the link model, removing the shared model and guards, and wiring relations with products, orders, and order items via the join table.
Configure kafka in the admin microservice, create a kafka service and topics (email, admin, ambassador), and emit and receive product events across microservices with a topic, key, and value.
Create a new consumer.ts and copy the consuming code to establish a dedicated Kafka consumer service for the admin microservice, then test with npm run consume inside the Docker container.
add an admin consumer service in Docker Compose to run Kafka consumer by moving npm run consumer from the dockerfile to the service, then rebuild with Docker Compose up --build.
Learn to build a Kafka-driven dynamic command dispatcher in a NestJS microservice by wiring a Kafka controller to execute functions like product created or product updated based on message keys.
Develop the ambassador and checkout microservices and wire the frontend to communicate via the users microservice and budget Kafka, completing the monolith to microservices transition.
Set up the ambassador microservice by configuring files, ports, and database, installing validation and cookie parsing, and running docker compose up to begin moving the user model.
Move the user module from the monolith to microservices by copying the user model, updating the scope to ambassador, and configuring the user controller and shared services with cache manager.
Move the product model from the admin microservice to the product module, update the controller, import the cash manager and request, and seed the data via Docker.
Move links and orders to microservices, simplify the order model by removing order items and excess fields, and keep only id, user id, and total.
We refactor the order entity and related models to compute ambassador revenue and order totals, seed the orders, and configure Kafka for the microservice.
Configure Kafka for the ambassador microservice by installing packages, copying Kafka components from admin, updating Docker, and implementing producer and consumer logic for testing.
Explore consuming events with kafka in nestjs microservices, wiring product created, updated, and deleted events between admin and ambassador services, and handling cache via cash manager.
Create a Kafka error model and repository to persist failed events, inject it into Kafka service, and use try catch to store errors for retry in admin and ambassador microservices.
Configure the checkout microservice by adapting docker files from the admin setup and updating docker compose, network, and database references. Install dependencies and prepare for Kafka integration.
Import and prune module structure across users, products, orders, and links in a NestJS microservices setup, configure stripe and config service, and prepare Kafka.
Configure Kafka by creating checkout and ambassador topics, wiring product, link, billing, and admin services, and emitting order events across microservices on order creation and completion.
Deploy microservices with Kubernetes on Google Cloud, using free credits and native cloud tooling to manage scalable containerized applications, with easy installation via Docker Desktop.
Build a production Dockerfile for a multi-stage image, with a builder stage to install dependencies and a lighter runtime stage using only production dependencies and the dist folder.
deploy a dockerized email microservice on kubernetes by creating a pod yaml, properly naming the image, building with docker compose, and applying the configuration to ensure the pod stays running.
Externalize environment values for development and production by configuring Kafka credentials and bootstrap servers, mail settings, and consumer group id in Docker Compose, preparing for Kubernetes deployment in next story.
Learn to convert docker compose to Kubernetes with Kompose, handle version compatibility, and deploy using deployments, environment variables, and replicas to scale microservices.
Learn how to use Kubernetes secrets to securely store and reuse values like usernames and passwords, creating secret generics for Kafka and mail configurations and applying them across Kubernetes files.
Set up a google cloud project named microservices, enable the kubernetes engine api, and create an autopilot cluster in europe to deploy the email microservice.
Deploy a yaml workflow from cloud shell by configuring the gcloud project, obtaining cluster credentials, and applying email.yaml with kubectl while addressing image deployment issues on Google Cloud.
Install the Google Cloud SDK, log in with gcloud, configure the project, and push the bequant image to the Google Container Registry.
Push the docker image to Google container registry, tag it for the project, and apply the updated Kubernetes file, configuring CPU and memory limits and Kafka secrets.
Deploy the user microservice by creating a Google Cloud database and setting up production Docker configuration. Configure environment variables for host, port, and database, then test the Docker Compose deployment.
Authorize networks to connect NestJS microservices database on Google Cloud, resolve Docker compose issues, seed users, and prepare a Kubernetes deployment.
Create Kubernetes deployment and service files for the users microservice, rename the deployment to users, remove unnecessary annotations, and configure the port exposure before pushing the image.
Push docker images to Google Cloud Registry, update latest tags for users and email, deploy via Kubernetes with an external load balancer, and diagnose a database connection timeout during startup.
We explore migrating from public IP addressing to private IP addressing to securely connect microservices and databases in a dockerized Google Cloud Kubernetes setup, comparing private IP simplicity with proxy options.
Create a Kubernetes ingress as a unified API gateway to connect microservices via a single URL, enabling load balancing and SSL termination, routing /api/users to the users service.
Clone the users database to an admin database and prepare its environment. Configure Docker compose for the admin service, set admin consumer credentials and seeds, and prepare Kubernetes manifests.
Convert the docker compose setup into kubernetes yaml files for admin and consumer services, updating environment values, secrets, and ports to enable deployment of backend components.
Deploys admin microservices by building with docker compose, pushing images to the registry, updating ingress to admin routes, and testing admin and user services via Kubernetes and the /api/administration API.
Set up the ambassador microservice by configuring docker compose, cloning the admin database to ambassador, and aligning environment variables and Kafka settings; seed data and prepare for Kubernetes deployment.
Master Ambassador Kubernetes files by configuring Docker Compose, bootstrap servers, and secrets, building Ambassador services and Redis integration, and preparing the deployment from Docker Hub with YAML tweaks.
Push the ambassador docker image via docker compose, publish to Google Cloud Registry, configure port 8003 and ingress, and verify the ambassador and admin microservices run as distinct deployments.
Deploy the checkout microservice by cloning the checkout database, configuring docker compose and environment values, updating stripe keys, seeding products and orders, and finalizing the Kubernetes file.
Convert docker compose to Kubernetes files for the checkout service, creating yaml resources, adding a bootstrap service, configuring secrets for the Stripe key, and updating service definitions and images.
Push the checkout service to Google Cloud registry, build and push Docker images, configure the API gateway and ingress, then deploy and scale microservices.
Test the frontend across multiple microservices by signing up and signing in with test users, inspecting cookies, handling cross-browser issues, and validating checkout flows from one to five services.
Welcome to NestJS and Kafka: Breaking a Monolith to Microservices Course - the course that will take your Javascript development skills to the next level.
How this course works
This course will start with a pre-built monolith, the building of the starting app won't be covered in this course. So in this course, you will start immediately with Microservices Architecture, this course is intended for people that have a solid understanding of Javascript and want to learn in a short amount of time more advanced concepts. I am very clear and precise in my way of teaching so this course won't have unnecessary explanations on my part, I will explain what is needed when it is needed.
If you are interested in learning how the Monolith is created you can check my other courses:
Angular Material, Universal & NestJS: A Rapid Guide
React, Next.js and NestJS: A Rapid Guide - Advanced
Vue 3, Nuxt.js and NestJS: A Rapid Guide - Advanced
In those courses, you will learn how to build a SPA with your favorite frontend framework.
What you will learn in this course
In this course, you will start with a pre-built monolith and you will learn:
What is the Microservices Architecture
How to Configure Kafka with NestJS
Internal Http Requests
How to make a Microservice only for Authentication Purposes
Run Docker with multiple networks
Produce Kafka Events to multiple topics
Create Custom Middlewares & Services
Import Data from multiple databases
About Me
I'm a FullStack Developer with 10+ years of experience. I'm obsessed with clean code and I try my best that my courses have the cleanest code possible.
My teaching style is very straightforward, I will not waste too much time explaining all the ways you can create something or other unnecessary information to increase the length of my lectures. If you want to learn things rapidly then this course is for you.
If you have any coding problems I will offer my support within 12 hours when you post the question. I'm very active when trying to help my students.
So what are you waiting for, give this course a try and you won't get disappointed.