
Design, build, and scale an enterprise-level event-driven microservices system using NestJS, Kafka, Docker, and Postgres, learning producers, consumers, DLQ, retries, and API gateway patterns.
In this lecture, you’ll learn how to download and use the complete course source code.
Each milestone of the project is stored in a separate Git branch, so you can jump to any stage during the course.
Repository link:
https://github.com/HaiderMalik12/nestjs-with-kafka-build-microservices
Steps include:
• how to download the repo
• switching between branches
• running each version
• matching branches to lectures
This makes it easy to review and follow along — even if you join later or revisit topics.
Understand Kafka as a high performance, durable distributed data pipeline that uses topics, partitions, and offsets to enable scalable, fault tolerant microservice communication via producers and consumers.
Create a Kafka topic, explore it in the Kafka UI, list and describe topics, and create a topic with partitions to enable parallel consumption.
Configure docker volumes for Zookeeper and Kafka, store data in var and lib directories, initialize volumes, restart containers, and use the interactive CLI to create topics.
Send real-time Kafka messages with a producer and consume them with a consumer to see Kafka working live. Understand topics, partitions, and offset commits through examples like payment.completed and user.registered.
Explore producer and consumer communication in Kafka using the interactive shell to send messages to a test topic and view offsets from beginning.
Explore Kafka UI, a graphical user interface to view topics, partitions, messages, and consumer lag in real time. See how producer and consumer activity, headers, offsets, and timestamps are displayed.
Set up the product microservice in NestJS using Kafka transport, replacing HTTP in microservices mode; configure Kafka.js with localhost:9092 and a product service consumer group to enable event-based communication.
Install prisma as a dev dependency and set up prisma with Postgres. Initialize the prisma folder, configure the database URL, run prisma dev, and define models for migrations.
Prisma provides type-safe database access by generating TypeScript types and a database client from your schema in a Kafka-based microservices architecture. Parameterize queries by default to prevent SQL injection.
Configure prisma with postgres, define a product model with uuid id and created at and updated at timestamps, run migrations, and generate the prisma client to access products table.
Refactor event handling to process complete payloads for delete and update product actions, extracting ids and handling product deleted and updated messages within a NestJS with Kafka microservice.
Create a Prisma service in the order microservice to expose the Prisma client, implementing on-init, on-module-init, and on-module-destroy, with connect and disconnect. Inject the Prisma service into the order service.
Fetch all products by batch requesting an array of product IDs to the product microservice, using a wait expression and RxJS to take the first value in a try-catch transaction.
Many backend developers struggle with:
• tightly-coupled REST APIs that don’t scale well
• complex inter-service communication
• confusion around Kafka concepts and workflows
• a lack of real-world implementation examples
• uncertainty about how microservices work together in production
• theory-heavy tutorials that skip practical coding
Kafka often feels powerful — but intimidating and abstract.
This course turns it into something clear, approachable, and hands-on.
This course solves those challenges by:
• teaching Kafka fundamentals in plain language
• using real diagrams and hands-on demos
• connecting Kafka directly to NestJS microservices
• guiding you through producers, consumers & messaging
• showing real event contracts & naming conventions
• building Product & Order services together
• saving data using PostgreSQL + Prisma
• testing & debugging event-driven flows step-by-step
By the end of this course, you will:
Understand event-driven architecture
Build real microservices with Kafka + NestJS
Gain confidence working with distributed systems
Add in-demand backend engineering skills to your resume
Learn tools used in industry — Docker, Prisma, PostgreSQL
Be able to design scalable, loosely-coupled systems
Have real project code you can reference or extend
Most importantly:
Kafka will finally “make sense” —
and you’ll be able to apply it in real-world backend projects.
So you don’t just learn Kafka —
you use it to build a working microservices system.
Event-driven architecture is one of the biggest shifts happening in backend engineering — and Kafka is at the heart of it. In this hands-on course, you will learn how to integrate Kafka with NestJS to build powerful, scalable, production-ready microservices step-by-step.
We start from the very beginning: understanding Kafka concepts such as topics, partitions, replication, and consumer groups. You will run Kafka locally using Docker, create topics, and publish and consume events so you fully understand how messaging works before writing any application code.
Then we move into real development. You’ll build multiple NestJS microservices that communicate through Kafka. You will create producers, consumers, shared message contracts, and event-driven workflows. Along the way, you’ll learn best practices such as message naming, debugging techniques, consumer groups, and application structure.
Next, we build two real-world services — a Product Service and an Order Service — backed by PostgreSQL + Prisma. You’ll emit and consume events like product.created and order.created, showing you how real microservices collaborate through Kafka.
By the end of this course, you’ll not only know how to use Kafka with NestJS — you’ll have built a complete event-driven backend that you can apply to real systems such as e-commerce, fintech, delivery platforms, SaaS, and more.
This course is perfect for backend developers who want to level up from REST APIs to distributed systems — with simple explanations and practical coding every step of the way.