WEBVTT

00:01.090 --> 00:08.560
In this lecture, we're going to review a system diagram that outlines the architecture of our application.

00:08.590 --> 00:11.050
Now, this lecture is completely optional.

00:11.050 --> 00:14.530
You don't need to complete this to move on with the project.

00:14.530 --> 00:19.120
So if you simply just want to download this and move along, you can.

00:19.150 --> 00:21.940
Otherwise, let's jump through this diagram.

00:22.120 --> 00:29.260
We can see the first component here is the actor, which will just be the user sending a request to

00:29.260 --> 00:32.500
our system and ultimately create a reservation.

00:33.590 --> 00:37.910
Now each of these rectangles represent a different microservice.

00:37.910 --> 00:39.860
So of course we have the reservations.

00:39.860 --> 00:48.110
Microservice listening on Port 3000 and this is going to represent the gateway to our system.

00:48.110 --> 00:53.900
It's going to be where the user is going to send the request to actually create the reservation using

00:53.900 --> 00:56.150
post slash reservations route.

00:56.180 --> 01:00.500
Now you can see here they need to first obtain a JWT.

01:00.830 --> 01:09.230
And in order to get that JWT, we're going to communicate with the auth microservice on Http port 3001.

01:09.260 --> 01:16.480
We're going to send a slash login request with our user's login credentials to the auth microservice.

01:16.490 --> 01:22.790
Now the auth microservice will also have a route to create a user which is going to persist users to

01:22.790 --> 01:26.240
our MongoDB database that you can see is connected here.

01:26.240 --> 01:33.210
So the user will create an account and then they'll use the slash login route to authenticate with those

01:33.210 --> 01:35.970
credentials that will be stored in MongoDB.

01:36.150 --> 01:44.670
And in exchange they're going to get back this Json web token, which is a sign token and provides authentication

01:44.670 --> 01:46.740
for future calls in the app.

01:46.890 --> 01:53.250
So when we do make this post call to reservations, the first thing it's going to do is it's going to

01:53.250 --> 02:01.110
take that JWT and then send a request to the auth microservice on TCP Port 3002.

02:01.140 --> 02:07.170
It's going to use this message pattern, authenticate and include the JWT that the user sent along with

02:07.170 --> 02:08.370
the original request.

02:08.400 --> 02:15.000
Now the auth microservice will throw an error if this JWT is invalid, otherwise it's just going to

02:15.000 --> 02:21.570
return a successful status and that means that we're authenticated and can continue to create a reservation.

02:21.570 --> 02:28.500
So from here the reservation service will persist the data to the MongoDB database and then it's going

02:28.500 --> 02:35.580
to communicate to our next microservice the payments microservice on TCP Port 3003.

02:35.610 --> 02:42.870
It's going to send a message pattern of create charge, which is going to actually bill our user so

02:42.870 --> 02:49.710
the payments microservice will reach out to our Stripe API to bill the user with the payment credentials

02:49.710 --> 02:52.440
that are supplied in this request.

02:52.560 --> 02:59.490
Then the payments microservice is emitting a notification to our notification service, which is our

02:59.490 --> 03:02.760
last microservice listening on Port 3000.

03:02.760 --> 03:09.780
And for the notifications microservice will have a notify email message pattern that will take your

03:09.780 --> 03:14.490
request and emit the notification to our email provider.

03:14.490 --> 03:20.700
In this case, we will be using Gmail, so we'll send an email to the user after we have billed them

03:20.700 --> 03:23.190
and successfully created the reservation.

03:23.190 --> 03:28.380
So feel free to download this PDF and reference it as we start to build out this system.

03:28.380 --> 03:30.270
Let's go ahead and jump right in.

03:30.270 --> 03:31.620
I'll see you in the next lecture.
