WEBVTT

00:03.840 --> 00:07.520
Hey did everyone if they share and welcome to another new section.

00:07.530 --> 00:12.720
I know this course is a bit longer one but I really wanted to cover pro back end of the part like it

00:12.720 --> 00:17.670
means to say as pro I wanted to go in depth and that's exactly what we'll be doing.

00:17.670 --> 00:22.380
Now this section, you can go ahead and watch it in 1.5 X or maybe more.

00:22.380 --> 00:23.100
In this section.

00:23.100 --> 00:28.020
We're going to cover a lot of theory work not too much, but a bit of theory that is required for this

00:28.020 --> 00:33.480
course itself as well as we're going to do a small mini project by integrating a razor pane.

00:33.480 --> 00:38.880
Now, this is one thing which actually sometimes amuses me a little bit that people say, Hey, I know

00:38.880 --> 00:41.850
how to implement Braintree, but I don't know how to implement Stripe.

00:41.850 --> 00:46.830
Some people say, I know how to implement Braintree and Stripe, but I cannot implement Razorpay or

00:46.830 --> 00:48.270
Paytm or something else.

00:48.270 --> 00:55.200
Now, my point is that if you really have thoughtfully understood the concept of implementing a payment

00:55.200 --> 01:02.220
gateway, then implementing the stripe or Razorpay or Paytm or pay you money or any other is almost

01:02.220 --> 01:03.690
kind of exactly same.

01:03.690 --> 01:09.210
But the thing is, most of the time a lot of people, not you, but a lot of people actually just write

01:09.210 --> 01:10.380
code along with the instructor.

01:10.380 --> 01:15.120
They don't give it a thought for a moment that, okay, this is how I should understand the things and

01:15.120 --> 01:17.190
that is the most important aspect of it.

01:17.220 --> 01:21.900
So in this particular section, we're going to discuss a bit theory in the initial phase, and then

01:21.900 --> 01:27.810
we're going to create a very minimum viable project which will include how to get payment with the RAZORPAY

01:27.810 --> 01:28.320
done.

01:28.320 --> 01:30.210
Surely we can make it complicated.

01:30.210 --> 01:31.650
We are not going to do it right now.

01:31.650 --> 01:35.700
We will be keeping it as a separate project itself and we'll be working on that.

01:35.700 --> 01:40.560
So this is what it is and make sure you go ahead and create an account on the Razorpay because that's

01:40.560 --> 01:41.460
what we'll be using.

01:41.460 --> 01:44.250
You don't need to go into the actual mode, production mode.

01:44.250 --> 01:45.840
You can be still in the test mode.

01:45.840 --> 01:49.200
I have just created an account here for the testing purposes.

01:49.200 --> 01:52.290
I use that just for API keys, so go ahead and create that.

01:52.290 --> 01:55.260
We will be reading together the documentation of Razorpay.

01:55.290 --> 01:57.180
It's exactly the same as Stripe.

01:57.180 --> 01:59.940
Very familiar, actually, very similar to Stripe itself.

01:59.940 --> 02:01.620
So shouldn't be a big deal at all.

02:01.740 --> 02:02.850
So that's basic.

02:02.850 --> 02:03.630
You have to do.

02:03.840 --> 02:07.200
And let's go ahead and talk about the back end of LPR.

02:07.200 --> 02:12.540
So we are about to move into the phase where we are going to build an entire E commerce application

02:12.540 --> 02:17.640
and this will give you more confidence of how to develop a proper project and how to add functionality

02:17.640 --> 02:20.760
over the time into it, or at least how to design that.

02:20.760 --> 02:24.750
So we're going to go ahead and we are going to be implementing everything onto that one.

02:24.750 --> 02:31.200
So let me go ahead up here and let's go ahead and simply combine that all we got for this one.

02:31.200 --> 02:36.120
So so far, whatever the knowledge we have gained so far, we will be going ahead and we'll be using

02:36.120 --> 02:36.900
that now.

02:36.900 --> 02:40.200
Definitely we'll be add we'll be adding a little bit more to this one.

02:40.200 --> 02:44.040
So first, a concept that we are going to discuss is a file structure.

02:44.070 --> 02:48.870
Now, there are there is a lot of debate around how you should be doing it, how you should not be doing

02:48.870 --> 02:49.110
it.

02:49.110 --> 02:51.690
Some people like to divide it so much in depth.

02:51.690 --> 02:53.310
Some people just like to divide it.

02:53.310 --> 02:54.900
Basics, stuff again.

02:54.900 --> 02:55.650
Which one is good?

02:55.650 --> 02:56.430
Which one is right?

02:56.430 --> 02:57.840
There is no right or wrong here.

02:57.840 --> 03:01.170
As long as you are able to properly see where the things are.

03:01.200 --> 03:02.490
That's all it matters.

03:02.490 --> 03:03.360
That's all it matters.

03:03.360 --> 03:06.030
There is no written definition that you need to follow.

03:06.060 --> 03:10.320
Again, it's all personal preference, but this is the basic reference that I personally use in all

03:10.320 --> 03:14.880
of the production grade application, and mostly you're going to see almost exactly the same.

03:14.880 --> 03:19.050
So let's go ahead and discuss what each of these folder comes and contains into that.

03:19.170 --> 03:23.610
So obviously this is the route that means this is the basic folder, the empty one, which you're going

03:23.610 --> 03:26.610
to push it on to the GitHub or somewhere to deploy it.

03:26.640 --> 03:30.120
Now the very first folder that I usually like to create is config.

03:30.120 --> 03:36.060
Now this config includes a lot of configuration file and I like to keep my database file into this one

03:36.060 --> 03:36.480
as well.

03:36.510 --> 03:37.440
Do I need to?

03:37.470 --> 03:38.280
Not really.

03:38.280 --> 03:43.350
Some people create a separate folder, which is just the database, and in that we have a database connection

03:43.350 --> 03:43.830
file.

03:43.830 --> 03:46.890
You put it into config or the database folder totally on you.

03:46.890 --> 03:48.510
You can go ahead and change that.

03:48.510 --> 03:50.220
I usually prefer to that.

03:50.220 --> 03:56.370
I have even seen that some people actually prefer to put this dot E and V file into the config because

03:56.370 --> 04:01.320
they have the argument that configuration is inside the environment variable that should also go there.

04:01.320 --> 04:05.130
I personally don't do that, but you'll see a lot of people does that no harm in that.

04:05.130 --> 04:11.400
Also now controllers now so far we have seen the method that we have been writing, which is request,

04:11.400 --> 04:13.080
response and all that method.

04:13.080 --> 04:15.060
This needs to go into the controller.

04:15.060 --> 04:19.590
Now, I personally believe also that this is always a good way to separate out all of your controller.

04:19.590 --> 04:22.500
Maybe later on you want to go into serverless or something.

04:22.500 --> 04:26.730
So separating your controller is the most important thing that everybody should be doing it.

04:26.730 --> 04:31.620
If you are not going to do it, you are going to not make your application scalable and workable by

04:31.620 --> 04:32.640
a lot of other people.

04:32.640 --> 04:38.910
So having a separate controller always makes sense the middle where you will be needing a lot of middleware

04:38.910 --> 04:40.950
and we are going to talk about that in the future.

04:40.950 --> 04:46.110
Videos and the theory itself, middleware is like something a specialized middleware which is handling

04:46.110 --> 04:51.180
your errors, your custom errors, maybe a middleware which is identifying whether you are logged in

04:51.180 --> 04:51.840
or not.

04:51.960 --> 04:57.120
A middleware which is identifying what role you are having admin role, manager role or a simple user

04:57.120 --> 04:57.360
role.

04:57.360 --> 05:01.440
So how you are going to identify these things, they actually goes into the middleware.

05:01.440 --> 05:01.830
They.

05:01.910 --> 05:03.560
Don't do much of the stuff.

05:03.560 --> 05:07.980
They actually just return you the next based on what you really want to do.

05:08.000 --> 05:11.600
So there is not too much of the information in these files.

05:11.900 --> 05:13.310
Next step is the models.

05:13.310 --> 05:15.980
So this is obviously a production grade application.

05:15.980 --> 05:19.280
So we need to go ahead and put some database information here as well.

05:19.310 --> 05:24.590
Model is like a basic bare minimum structure that this is how the things are going to look like.

05:24.590 --> 05:26.840
For example, you are signing up the user.

05:26.840 --> 05:31.700
So what information you are going to be taking from the user, maybe their first name, last name,

05:31.700 --> 05:34.480
their address, email, information, password.

05:34.490 --> 05:39.800
So all of this needs to go inside a model itself that is a structure and we are going to design a couple

05:39.800 --> 05:40.670
of models together.

05:40.670 --> 05:43.370
So that will help you to understand it a little bit more.

05:43.520 --> 05:45.050
Then comes up is the route.

05:45.080 --> 05:48.200
Now a lot of people don't like to break their roots like this.

05:48.200 --> 05:50.450
I personally love to break it like that.

05:50.450 --> 05:53.870
It helps me to kind of scale application easily.

05:53.870 --> 05:59.750
For example, if I am having an application which is an e-commerce store or maybe a hotel booking that

05:59.750 --> 06:03.410
is a single product, there are a single hotel that I'm putting out.

06:03.410 --> 06:08.150
So all the routes related to that product or that hotel goes into a single file.

06:08.150 --> 06:11.930
So that is absolute amazing way of architecture in your application.

06:11.930 --> 06:15.950
So whether I want to add a product, delete a product, edit a product, whatever I want to do with

06:15.950 --> 06:20.150
the product, I can do it in just one file and it keeps things at a central place.

06:20.150 --> 06:21.590
That's why I like to keep that.

06:22.130 --> 06:23.810
Next come up is the seeds.

06:23.810 --> 06:29.020
Now, this is a little bit of a new folder to you, but it usually exists there.

06:29.030 --> 06:34.340
Now the idea behind the seed is sometime maybe there is a guy who is testing your application or the

06:34.340 --> 06:37.400
front end guy who is having a less idea how the data will come up.

06:37.400 --> 06:40.640
So in the seed file, we actually get a simple two things.

06:40.640 --> 06:44.420
The first is connection to the database, and second, some of the dummy data.

06:44.420 --> 06:49.040
So as soon as you are going to run the seed file, it will connect to the database and then we'll throw

06:49.040 --> 06:50.570
up some information in the database.

06:50.570 --> 06:55.970
It includes some dummy users that log in and password that are pre known to the entirety of your team.

06:56.240 --> 06:57.650
Some information about product.

06:57.660 --> 07:02.090
So every single model that you have created in the database, it is going to fill a few information

07:02.090 --> 07:02.390
in that.

07:02.390 --> 07:07.220
So that is easier for the tester or maybe the front end guy to actually see some data coming in because

07:07.220 --> 07:09.380
the application is new, it's not being deployed.

07:09.380 --> 07:11.420
So we need some kind of information there.

07:11.420 --> 07:16.490
Now it's up to you that how you're going to provide the seed information, maybe through some packages

07:16.490 --> 07:20.510
or library like Faker, or maybe you are going to manually enter that totally up to you.

07:20.510 --> 07:22.970
We are not going to discuss that too much in this course.

07:23.150 --> 07:24.950
Then comes up is the utils.

07:24.950 --> 07:29.960
Now these are utilities which are really, really basic, but you want to still keep them as separate

07:29.990 --> 07:30.920
utilities.

07:30.920 --> 07:36.050
For example, sending email that could be one, sending an OTP via a mobile phone, that could be one.

07:36.050 --> 07:42.200
The reason for separating them is maybe you are having a basic information of how to send email that

07:42.200 --> 07:43.640
always remains same.

07:43.640 --> 07:48.800
And maybe later on you want to use send in blue, maybe eight blue email services.

07:48.800 --> 07:51.950
So there are a lot of services available and you want to configure them.

07:51.950 --> 07:54.560
But how you send email basically always remains the same.

07:54.560 --> 07:56.300
Just the configuration changes out.

07:56.300 --> 07:59.600
So that's why you keep all the utilities totally, entirely separate.

07:59.600 --> 08:03.650
Maybe a function which you are using probably ten different times in your application.

08:03.650 --> 08:07.910
It's a best idea to push that into the utilities and everybody then can use it.

08:08.180 --> 08:10.850
Then of course our all time favorite get ignored file.

08:10.850 --> 08:16.040
So all the files that you don't want to push to the source code onto the GitHub or any repository that

08:16.040 --> 08:19.590
all goes into the git ignore kind of basics for the get dirty.

08:19.610 --> 08:24.440
And B we had a long discussion about this simple package dirty and we can give you this file, you can

08:24.440 --> 08:30.170
create this one and all the information, secret information like your keys, secret keys and all of

08:30.170 --> 08:32.300
that information resides here.

08:32.300 --> 08:35.870
And at the time of deployment, we go ahead and just place it there.

08:35.870 --> 08:39.350
Whatever the service you are using, Heroku, Digital Ocean doesn't matter.

08:39.350 --> 08:41.900
All of them gives you the information to upload that.

08:41.900 --> 08:44.210
And yes, you have to manually write all these values.

08:44.210 --> 08:50.300
There is no automation happening there and after that comes up is your root file which can be JS indexed

08:50.300 --> 08:53.870
or JS server or g is something, logs, whatever it can be.

08:53.870 --> 08:56.390
This is the basic entry point of IT application.

08:56.390 --> 09:01.340
I usually prefer to keep it as a keep it as indexed or JS and I use the same functionality that we saw

09:01.340 --> 09:06.830
in one of the earlier section that I like to keep indexes separate and also my G is there which actually

09:06.830 --> 09:11.330
exports the app in the index or GSI, import that app and run the application.

09:11.330 --> 09:12.830
So kind of a basic one.

09:12.830 --> 09:15.020
So again, don't freak out.

09:15.200 --> 09:16.220
Break your application.

09:16.220 --> 09:20.540
It's a good habit, but don't break it too much that you just get lost into it.

09:20.540 --> 09:24.590
Make sure it is all kind of makes sense when you are breaking your application.

09:24.590 --> 09:26.390
So that's how you keep your folder structure.

09:26.390 --> 09:27.110
This is basic.

09:27.110 --> 09:32.270
Again, this is not a compulsion, but this is what you are going to see in majority of the application.

09:32.270 --> 09:37.280
So a bit of a theory told you watch it in 1.5 and let's catch up in the next video and discuss a bit

09:37.280 --> 09:39.170
of a tiny subject in the next one.
