Build a Microservices app with .Net and NextJS from scratch

Build a Microservices app with .Net and NextJS from scratch

English | MP4 | AVC 1920×1080 | AAC 44KHz 2ch | 240 lectures (31h 38m) | 16.80 GB

How to build a microservices based app using .Net, NextJS, IdentityServer, RabbitMQ running on Docker and Kubernetes

Microservices is the latest ‘buzzword’ and hot topic in the web development industry at the moment and nowadays having microservices as part of your skillset is becoming more and more essential. This course aims to teach you how to build a microservices based app using .Net for the backend services and Next.js for the client app. We start from nothing and build up the app until we have a completed app that we can publish to a Kubernetes cluster on the internet.

Here are some of the things that are covered in this course:

  • Creating several backend services using .Net that provide functionality for the app
  • Service to service communication using RabbitMQ and gRPC
  • Using IdentityServer as the identity provider.
  • Creating a gateway using Microsoft YARP
  • Building a client side app with Next.js using the new App Router functionality (since Next.js 13.4)
  • Using SignalR for push notifications to the client app
  • Dockerizing our different services
  • CI/CD workflows using GitHub actions
  • Adding ingress controllers
  • Publishing the app locally using docker compose

The goals of the main part of this course is to build this app and be able to run and publish everything locally without having to sign up or pay for any cloud services. Once you have completed the main part of the course there are 3 optional Appendixes that cover:

  • Unit and integration testing
  • Publishing locally to Kubernetes
  • Publishing the app to a Kubernetes cluster on the internet

Tools you need for this course

In this course all the lessons are demonstrated using Visual Studio Code, a free (and fantastic) cross platform code editor. You can of course use any code editor you like and any Operating system you like… as long as it’s Windows, Linux or Mac. Please ensure that your computer can run Docker as this is a requirement for this course (please see the pre-requisite lesson available as a preview to confirm this).

Is this course for you?

This course is very practical, about 90%+ of the lessons will involve you coding along with me on this project. If you are the type of person who gets the most out of learning by doing, then this course is definitely for you.

On this course we will build an example Auction Application with several services that we will use to provide its functionality. For the client side of things we are using Next.js to take advantage of its client side and server side capabilities which is an excellent fit for what we are building. All you will need to get started is a computer with your favourite operating system that is capable of running Docker, and a passion for learning how to build a microservies based application using .Net and Next.js.

What you’ll learn

  • To build an application with .Net using Microservices architecture
  • To build a client app for the application using NextJS
  • To use RabbitMQ for Service bus communications
  • To install and use IdentityServer in the Microservices app
  • To be able to test the projects using Unit and Integration testing with XUnit
  • To publish the Microservices app to Docker compose
  • To publish the Microservices app to Kubernetes cluster both locally and on the internet
Table of Contents

Introduction
1 Introduction
2 Course prerequisites
3 Setting up the developer environment
4 Course assets and source code
5 VS Code troubleshooting and tips
6 Microservices the big picture

Section 2 Creating the first microservice
7 Introduction to section 2
8 Creating the first micro service
9 Reviewing and simplifying the project
10 Adding the entity classes
11 Adding the Database context class
12 Adding a Postgres database server
13 Creating seed data
14 Shaping the data to return
15 Adding an API controller
16 Adding a postman collection
17 Adding the create auction endpoint
18 Adding the update auction endpoint
19 Adding the delete auction endpoint
20 Saving changes into source control
21 Summary

Section 3 Creating a Search microservice
22 Introduction to Section 3
23 Creating the second micro services
24 Adding the MongoDb server
25 Adding the Item model
26 Adding seed data
27 Adding a search controller
28 Paginating the results
29 Adding filtering and ordering
30 Synchronous messaging
31 Adding Http communication to get the data
32 Making our Http communication resilient
33 Summary of Section 3

RabbitMQ
34 Introduction to Section 4
35 What is RabbitMQ
36 Installing RabbitMQ
37 Adding and configuring mass transit
38 Adding the contracts
39 Adding a consumer to consume a message from the Service bus
40 Publishing the Auction Created event to the bus
41 What could go wrong
42 Adding a message outbox
43 Using message retries
44 Consuming fault queues
45 Challenge Adding the update and delete consumers
46 Challenge solution
47 Summary of section 4

Identity Server
48 Introduction to Section 5
49 OAuth and OpenIDConnect
50 Creating the Identity Server project
51 Reviewing and configuring our new project
52 Seeding data and adding a migration
53 Reviewing the login page in identity server
54 Adding a register page
55 Adding a register page part 2
56 Adding a register page part 3
57 Adding client credentials to allow clients to request a token
58 Adding a custom profile service to identity server
59 Configuring auth on the resource server
60 Configuring the auth endpoints on the resource server
61 Summary of section 5

Adding a Gateway Service
62 Introduction to Section 6
63 Adding the Gateway service
64 Adding the Reverse Proxy configuration
65 Adding authentication to the Gateway config
66 Testing our Gateway service in Postman
67 Adding the remaining contracts we need
68 Adding the remaining consumers to the Auction Service
69 Adding the remaining consumers in the Search Service
70 Adding a new client to the Identity service configuration
71 Summary of Section 6

Dockerizing our application
72 Introduction to Section 7
73 Creating a docker account
74 Dockerizing the Auction Service
75 Updating our docker compose file for the Auction Service container
76 Dockerising the Search service
77 Dockerising the Identity Service
78 Debugging a Net service in a docker container
79 Dockerising the Gateway Service
80 Testing our docker containers
81 Summary of Section 7

Adding the client side application
82 Introduction to Section 8
83 Creating the NextJS project
84 Reviewing and simplifying the NextJS Project
85 Creating a nav bar
86 Fetching data from the API
87 Adding an Auction Card component
88 Styling the auction cards
89 Adding a countdown timer to the auction card
90 Adding loading to the images
91 Adding types to the project
92 Adding pagination to our list
93 Using server functions in client components
94 Adding a set page size option
95 Using Zustand for state management
96 Refactoring our code to use the zustand state
97 Adding a search bar
98 Adding the search functionality
99 Adding a reset to the search function
100 Adding the sorting functionality
101 Adding the filtering functionality
102 Adding a component to display when zero results
103 Summary of section 8

Client side identity with NextAuth AuthJS
104 Introduction to Section 9
105 Before we begin
106 Installing Next Auth into our client app
107 Adding the login functionality
108 Getting the session details in the client
109 Populating the session data
110 Populating the User actions dropdown
111 Protecting routes
112 Testing API authentication
113 Getting the access token to use to authenticate to our resource server
114 Summary of Section 9

CRUD operations in the client app
115 Introduction to Section 10
116 Routing in NextJS
117 Getting the auctions won
118 Creating an Auction form
119 Creating an Auction form part 2
120 Creating a reusable text input
121 Creating the auction form part 3
122 Creating a reusable date input
123 Creating a fetch wrapper
124 Adding the create auction server action
125 Adding react hot toast to display notifications if something goes wrong
126 Adding the auction details page content
127 Adding the edit auction page
128 Adding the delete auction functionality
129 Summary of section 10

Creating the bid service
130 Introduction to Section 11
131 Creating the Bid Service
132 Adding the models to the Bid Service
133 Adding an API Controller for the bids
134 Adding the get bids endpoint
135 Adding the auction created consumer
136 Testing the bid functionality in Postman
137 Adding the DTOs and Automapper
138 Adding a producer for the BidPlaced
139 Challenge solution
140 Adding a Background service for the auction finished event
141 What is gRPC
142 Adding gRPC part 1
143 Adding gRPC part 2
144 Adding a gRPC client
145 Updating the Gateway service
146 Dockerising the BidService
147 Summary of Section 11

Adding a SignalR service
148 Introduction to Section 12
149 Creating the Notification service
150 Adding a SignalR Hub
151 Adding the Consumers
152 Adding CORS support to the Gateway
153 Dockerising the NotificationService
154 Updating the Docker compose file
155 Summary of section 12

Adding the bidsnotifications to the client
156 Introduction to Section 13
157 Refactoring the auctions into a zustand store
158 Updating the Auction cards with the current high price
159 Getting the bids for an auction
160 Creating a bid item
161 Creating a bid store
162 Creating a bid form
163 Updating the error handling
164 Adding conditionals to the form and testing
165 Adding SignalR to the client app
166 Adding the new bid to SignalR
167 Adding a toast for an auction created
168 Adding a toast for an auction finished event
169 Disabling the auction finished form when the auction finishes
170 Preventing low bids
171 Summary Section 13

Publishing the app to production locally
172 Introduction to Section 14
173 Preparing the client app
174 Creating the Dockerfile for nextjs
175 Fixing the identity server issues in docker compose
176 Giving the Identity Server a static ip address
177 Adding an ingress to Docker compose
178 Adding SSL to the ingress
179 Final app cleanup and resolving SignalR issue
180 End of course summary

Appendix A Testing
181 Intro to Appendix A Testing
182 The simplest unit test possible
183 Reviewing the code in the Auction controller and what we are testing
184 Creating an Auction Repository and interface
185 Refactoring the Auctions controller to use the repository
186 Mocking things
187 Unit testing the GET methods part 1
188 Unit testing the GET methods part 2
189 Unit testing the POST request
190 Challenge Practicing creating unit tests for the other controller methods
191 Challenge solution
192 Integration testing setup
193 Setting up a Custom web application factory for integration testing
194 Adding test data to the DB
195 Creating an integration test for the GET method part 1
196 Creating an integration test for a GET request part 2
197 Creating an integration test for the POST request
198 Challenge Practicing creating integration tests for the other methods
199 Challenge solution
200 Testing the Service bus
201 Using Collection fixtures to share the DB across test classes

Appendix B Publishing to Kubernetes locally
202 Intro to Appendix B Kubernetes
203 No depends on in Kubernetes using Polly to retry instead
204 Adding a GitHub action to push our Identity Server image to Docker hub
205 Deploying our IdentityServer to a Digital Ocean server
206 Configuring the Linux server to host the identity server
207 Creating the first Kubernetes manifest for a deployment
208 Adding a persistent volume claim
209 Adding a load balancer to allow us to connect to the postgres deployment
210 Adding a cluster ip our services can use
211 Creating a deployment for RabbitMQ
212 Creating a Mongodb deployment
213 Creating the auction service deployment
214 Creating the search service deployment
215 Creating the bid service deployment
216 Creating the notification service deployment
217 Creating the gateway service deployment
218 Creating the client app deployment
219 Adding an nginx ingress controller for dockercompose
220 Adding SSL to the ingress controller
221 Fixing Identity Server issues

Appendix C Publising to Kubernetes Internet
222 Introduction to Appendix C
223 Kubernetes secrets
224 Using a manifest to create secrets
225 Updating the rest of the secrets
226 Adding a workflow to deploy our Auction service
227 Creating a kubernetes cluster on Digital Ocean
228 Connecting to our new kubernetes cluster
229 Creating a workflow to deploy our manifests automatically
230 Dev resources and prod resources
231 Creating the other deployment workflows for the other services
232 Deploying the secrets and the ingress controller
233 Deploying our manifests via github actions
234 Checking our deployment
235 Getting a domain name to point at our Load balancer
236 Tying up the loose ends part 1
237 Tying up the loose ends part 2
238 Adding SSL to our deployment part 1
239 Adding SSL to our deployment part 2
240 Finishing up the deployment

Homepage