WEBVTT

00:03.910 --> 00:05.380
Hey, did everyone share?

00:05.380 --> 00:09.730
And in this video we're going to talk about modeling of the application, but before that, we should

00:09.730 --> 00:10.930
know what we are building up.

00:10.930 --> 00:13.080
So let's go ahead and talk a little bit on that.

00:13.090 --> 00:16.690
Now, our major goal is to design an authentication system.

00:16.690 --> 00:21.160
Now what this authentication system is protecting, we are not worried about that part.

00:21.160 --> 00:27.040
Maybe it's an e-commerce store, maybe it's an AE application, or maybe it's just an API which nobody

00:27.040 --> 00:27.550
can access.

00:27.550 --> 00:31.750
If he's not logged in, maybe are using a GitHub searcher or something, anything like that.

00:32.110 --> 00:35.740
Now, authentication system is not very complex.

00:35.740 --> 00:41.380
It can be from the perspective of what you are designing, but on a very basic level it has just three

00:41.380 --> 00:42.010
components.

00:42.010 --> 00:46.000
It has a registered component, a login component and some restricted routes.

00:46.300 --> 00:48.280
Now what does it mean by that?

00:48.280 --> 00:52.840
A user will be able to register into your system by providing all the details that you're asking him

00:52.840 --> 00:56.320
once he has successfully registered means he's into the database now.

00:56.320 --> 00:59.500
Whenever he comes the next time, he don't need to provide all that information.

00:59.500 --> 01:03.040
Rather, he can enter into our system by providing less information.

01:03.040 --> 01:06.760
That less information can be just user name, password or email password.

01:06.760 --> 01:12.190
However you are designing your application further down the road, there can be some restricted routes,

01:12.190 --> 01:16.870
the routes that nobody all can access, routes that only logged in user can access.

01:16.870 --> 01:23.020
Now, further down this road, authentication can also become some of the more complex system you might

01:23.020 --> 01:26.830
want to go for authentication as well as some validation check as well.

01:26.830 --> 01:29.650
For example, some routes can be open for everyone.

01:29.650 --> 01:35.620
Some routes can be open only for admin, some route can be open for managers and some routes for users,

01:35.620 --> 01:37.240
and some are not for all everyone.

01:37.240 --> 01:41.890
So there is authentication as well as a little bit of the validation that can be done.

01:41.890 --> 01:44.560
So again, it can be complex, but we'll keep it short.

01:44.800 --> 01:50.920
Now in this one, since this is not a register model or a login model, we call this one as user because

01:50.920 --> 01:52.690
that's all it is governing up.

01:52.690 --> 01:57.700
So I don't expect you to just go ahead of me in this section because there's so much detail and so much

01:57.700 --> 02:01.330
to talk up here, and we won't be using any of these models.

02:01.330 --> 02:05.650
We will be using our same free mirror or any other such mind mapping application.

02:05.650 --> 02:10.270
So go ahead and create a free one up here, the empty one, and we're going to go ahead and start with

02:10.270 --> 02:10.870
this one.

02:10.960 --> 02:14.590
So we're going to call this one as simply auth system.

02:14.590 --> 02:16.930
There we go, if I can write that.

02:17.140 --> 02:17.890
There we go.

02:18.460 --> 02:20.590
So this is the old system that we are having.

02:20.590 --> 02:22.120
Let's go ahead and move it up here.

02:22.120 --> 02:26.170
Now, this old system or any application that you're designing, maybe it's an E commerce.

02:26.170 --> 02:30.940
It might have other components, like there can be controllers, there can be routes and a whole bunch

02:30.940 --> 02:31.720
of other things.

02:32.080 --> 02:33.640
We're going to go very short in this one.

02:33.640 --> 02:38.080
We won't be separating our controllers and everything routes, at least in this section later on for

02:38.080 --> 02:38.560
sure.

02:38.560 --> 02:40.300
But let's go ahead and add this one.

02:40.300 --> 02:45.040
So in this one, obviously, we'll have a model route that a lot of modeling can be done.

02:45.040 --> 02:47.110
And we don't need you as of now.

02:47.260 --> 02:53.170
And further down the road in the model, we are going to have multiple models, maybe, maybe not sure.

02:53.560 --> 02:55.570
So we're going to call this one as user.

02:55.960 --> 02:57.730
That is fine now.

02:58.030 --> 02:59.560
Okay, go back up here.

02:59.680 --> 03:02.020
So now how can I scroll this?

03:03.680 --> 03:03.890
Okay.

03:03.890 --> 03:05.090
We can move this one here.

03:05.090 --> 03:10.100
So once we have this model defined and we're going to call this user again, it's not usually called

03:10.100 --> 03:15.280
as users, it's called as user because this is defined as how single entity will look like.

03:15.290 --> 03:16.730
Again, these are recommendations.

03:16.760 --> 03:19.820
Nobody's stopping you to call it as users, but it is recommended.

03:19.820 --> 03:24.500
In fact, people will say that, hey, this should be something like user, but this is totally up to

03:24.500 --> 03:26.090
you however you want to define it.

03:26.090 --> 03:28.490
And usually models have first uppercase letter.

03:28.610 --> 03:33.950
Now on top of that, once this is all done, I you can actually go ahead and click on Add Button and

03:33.950 --> 03:40.430
can say that, hey, this will have a first name, something like this first name and then you can add

03:40.430 --> 03:41.180
last name.

03:41.180 --> 03:45.980
But I have found that if I use this kind of mind mapping, it actually creates so many of the threads.

03:45.980 --> 03:51.680
So what I do now is I go ahead and delete all of this, and in fact, I just put up a sticky note right

03:51.680 --> 03:52.280
in front of it.

03:52.280 --> 03:54.800
Probably this is sticky note, this color is good.

03:54.800 --> 03:57.680
And I'm going to say, hey, I need your first name.

03:57.680 --> 04:00.980
I will be needing a last name.

04:01.010 --> 04:03.230
I will be needing probably country.

04:03.650 --> 04:05.180
I will be needing email.

04:05.180 --> 04:08.420
Of course I will be needing password from the user as well.

04:08.420 --> 04:11.330
And for my personal I will be using a token.

04:11.330 --> 04:17.330
Now while we are using token because token is a unique information which will be sent to the user and

04:17.330 --> 04:21.470
we'll talk more about how we can send the this token and how it is being generated, all of that.

04:21.470 --> 04:26.210
But remember, this is just a unique information that we can send to the user that if you want to access

04:26.210 --> 04:30.290
any protected route, you have to use this token, you don't have to use your ID and password again

04:30.290 --> 04:33.440
and again, and we can also kind of automate that system.

04:33.440 --> 04:35.810
So this is how my user will look like.

04:35.810 --> 04:38.930
Now, it can be more complex as well, but this is all what we have.

04:38.930 --> 04:42.260
So again, this is a really nice way of handling that notice here.

04:42.260 --> 04:46.340
I haven't mentioned that the first name should be String or the country should be String or something

04:46.340 --> 04:48.560
like that or password should be like a combination.

04:48.560 --> 04:49.430
Now we don't do that.

04:49.430 --> 04:50.720
We usually do that in the modeling.

04:50.720 --> 04:53.420
This is just a basic overview of how it will look like.

04:53.420 --> 04:56.960
Now, again, this is a little bit of a rudimentary way of doing it.

04:56.960 --> 05:01.310
In the professional versions, we actually use all the tools that helps us to build all of that and

05:01.310 --> 05:02.540
have a visual of that.

05:02.540 --> 05:04.160
But this is still a good visual.

05:04.400 --> 05:06.560
Okay, now this is all done and settled up.

05:06.560 --> 05:10.790
It's a good time that we go ahead and replicate this into the code file.

05:10.790 --> 05:17.360
So finally, yes, finally we are going onto creating our application and let's go ahead and use Mongoose

05:17.390 --> 05:20.840
as well as learn how we can design this a schema onto the code files.

05:20.840 --> 05:22.880
Let's go back into the code section.
