hello and welcome to this course and in this course we are going to build a full St Mar projects using M Stack and these websites will have front end part back end part we will work with database and obviously we will have a strong dashboard where there are three types of dashboard one is for gener users who would like to purchase courses from here then another uh is for instructor if you are instructor you can upload course like this and and can obviously get paid then the third option is then there will be admin dashboard where you can approve instructors you can approve courses and obviously you can do lots of things so we'll cover everything from the basics you don't need to have a strong background on react J and obviously you don't have uh to a background of back ends I will obviously Show You by using a step by step process so you don't don't have any prerequisite for this course actually if you have basic understanding of react then you can just uh purchase this course and obviously this will be a great journey with me where you will learn lot of things okay so at the beginning let me show uh the user dashboard actually and user interface for this website so you can see uh this is a banner of the websites and if you just frag then you can see another banners so this is hero sections and at the top you can see uh actually the na and here is a toggle button where you can just toggle between dark mode and light mode if you click here you can see this is now dark mode and your dark websites will see look like this and then if you toggle again then it will be light mode you can see uh we will implement it very easily and then there another option is that here we have the homepage and in the homepage after the banner you can see after the hero sections we'll have a gallery and here is a very simple uh grid actually and there we will have popular classes all the popular classes will be here you can just select any of these classes from here you can see uh when you hover you can just get this type of effect uh we will uh just show you the inside thing things within a later but you can see there's a awesome cards here then we'll have amazing tasers so you can just uh show instructor uh details here then here is the simple Statics then a email sections is here and then a simple footer but the most interesting thing is that if you want to access the instructor you can see you can all uh instructor list will be appear here you can just see or any of this instructor profile from here and then the most important thing is that the class so here you can see some of the class are listed and this class has a view options and this is the select options you can see the details so cover image and instructor details available SE then there is the uh thing the price is here and if you click the view options then you can see uh the course details is here you can see the course title then here course details is actually here then you can see uh a enroll button and all of the course details will create in this uh sections and if you want to enroll then you can hit this enroll button then it will say you have fastly log to this accounts without having an account you cannot access it so to uh log in this accounts you must have an account so if you don't have you can just continue with Google then you can see you can see lots of options you can easily log in using your Google accounts or if you want then you can just simply Let me refresh it then you can just sign up using uh manual process so here let me show you how it will work for example here you have to Define your name for example let me Define a name that name will be maybe Emma and then here uh let me Define a email for this so maybe uh that would be Emma gmail.com then here you will have to define a password this password will be at least six character and you must MCH with this so let me Define the same thing Emma and let me just copy this uh so Emma W 1 2 3 4 5 6 so this is a simple login let me provide it and here I'm just uh providing a wrong passwords so then here you can have a to provide a phone number so let me Define a phone number I'm just typing randomly and here you can just provide a user email sorry user photo and then you can choose the gender and address maybe it's from West West Bengal okay something like this and if you hit this register then you can see the password is not matched if this password and this password is not the same then you will get the warning so let me just choose the correct password for this okay so I'm just choosing the correct password and if I get uh hit this started uh register button then you can see a profile is created you can see the image that we provide the link here is the thing and here right now there is another thing is added uh you can see there is a dashboard and log out button so right now if you go to the the dashboard then you can see uh some uh tool tip is here you can just access your enroll class right now there is no enroll class if you select any of this then you can see it here you can see the payment history is here you can apply for instructor by here if you just Define uh a message here and submit then your the website admin can Define your in uh instructor on this platform and you can upload course we will show that a little bit later but before that let me just try to purchase a course from here so here we'll go to the course sections and you can see right now the available seat is uh on 120 okay and the price is here if you just uh hit this select or either uh view then hit this enroll then you can see bad request so why this is bad request okay select successfully and and right now uh if you go to dashboard then if you just uh hit this my select then you can see you selected this course if you select another course so let me select it another course for now so I am selecting maybe this course so select here you can easily select here so okay it's maybe it's still loading okay let me try again okay uh successful and now if you go back to the dashboard and go to the my selected then you can see we will have two course is listed then you can easily delete any of these from here or you can simply pay individually or you can just proceed the checkout so let me proceed the checkout and here it's simple uh card UI from the strip and we will Implement strip here so that's why uh let me Define stripe test card for now and here we will just uh test the payments using this card any of this card here many card listed let me chose the first one and if you just provide the card details and here you can provide a future date maybe 25 maybe 25 or something let me provide a CVC and here uh if you just provide wrong Jeep code and try to pay it will say postal code incorrect if you just provide uh everything correctly then let me just provide everything correctly and right now if you hit this pay then you can see the payment successful and now you can access the class so after doing this if you go to my enroll then you can see the courses is here and you can access this but what if if you uh want to apply for instructor so here let me just apply for instructor so let me I would like to be an in structor okay and then if you just hit this submit then it will obviously submit so how you can understand actually you will have to login as an admin so let me just log out and let me try to log in as an admin I am already an admin I will show you how you can just make you admin so let me just going to log in to the admin dashboards and here I now on admin so you can see the total Statics of the admin dashboard so let me show you the overview of admin so by default you can see the total member total approved class so and then H structor and painting so right now let me go to the yoga Master sorry um our website's link so let me go there a little bit and here we'll have to go to the to directory and right now if you go to access the course here we have only six course and write me okay let let me just uh here you can see manage users you can manage any of users and you can manage classes so if you have any painting classes you can approve it so right now uh here we will have to check the application so the application is not there but uh you can just uh let me manage a user so the last users uh is here actually so this is Emma and these users will make it uh an actually uh instructor so here everything is fine so let me make it instructor and update this okay if you do this right now if you back to the uh let me log out and log to the uh account so here we'll have to go to login and then uh let me uh Define Emma gmail.com and here is the password let me log to the accounts and if I sign on then you can obviously see you can see the another option this is you can now add classes previously you can just only purchase the classes but right now you will have an option to add classes so how you can add classes so let me Define a test class here so test class one then you can upload a image for that maybe we can just uh let me Define a yoga image yoga image so something like this we can choose it from uh we can just choose it from any website so let me uh choose on this spash and here you can choose any of this image so let me choose maybe this image let me copy the image URL okay okay let me download it and here this is downloaded and you can just actually uh upload it so I just uploaded it and here available it you can Define maybe 25 then you can just Define the prices Maybe it would be 80 uh $90 and here you can provide a YouTube link and you can just provide details maybe let me Define details is test class one you can add more details here and then you can simply add it so if you submit your classes wait uh it's actually submitting so submit successfully after submitting successfully then you can just access my classes you have you can see the status actually this status is actually painting right now when admin approved then it will be just obviously shown there okay so again what you have to do you have to log out let me log out from here and let me log in again as an uh let me login uh as an admin so that I can approve that so let me login to my accounts and then dashboard then manage classes so right now if you go to the second page you can see the on test classes is uh required to uh approve so you can see right now the status is pending uh and if you just Define if you want to send a feedback you can obviously do that you can just Define a reasons why you reject or you can approv it simply clicking here if you click here and refresh it let me go back again then second p and it's now approved if you uh if you uh have this approval then if you go to the course sections actually sorry classes sections you can see the test is approved now anyone can purchase so the admin obviously not can be purchased so if you are users you can just purchase so let me show you let me just uh should okay uh actually we don't have to show it we have already did but if you want to just uh view details you can see obviously you can just see all the course details is here uh and you can change the text actually uh for due to making this tutorial I don't uploaded the titles but you can do the upload uh you can just uh make some adjustment here but I will show exactly the what you have to do to build this type of websites and get paid from online and this is a very simple websites but here you can see now we'll have two instructors and lot of stuff we will work obviously lot of thing in this uh course actually so I hope you can enjoy this tutorial and obviously so if you like this obviously uh I will try to provide best services and this course will be free for on YouTube but if you want to just get my support and if you want to get the source code you must have to enroll uh my courses and this is the prerequisite for this actually I don't have to provide I don't have option to provide uh it for free actually I have lot of works on this projects so obviously you will understand actually so uh hope you will get the content on YouTube for free but if you want to get a better conversation with me and the source code you obviously paid it uh for me okay thank you today uh now we have to get started we have to create our project so before that let me show you one thing if you scroll a little bit then you can see this is poal Cassis sections and in this sections we have some data and this data from the back end and here we'll have amazing t-shirts and this uh details is from obviously back end so if you go classes page then you can see all of these classes data from coming from the back ends let me show you so if we go yogam and then uh this is our uh server running I will obviously show it how you can create create your own server and host it so don't worry I will start from the beginning and if you go to the classes route then you can see all this classes data is here and we are rendering and showing it on our website so uh for this websites actually I will start back end part first then move to the front end because we need uh this data from the back end and obviously we will start from the beginning so you don't need to be worry about it how you can set up your backend data and other syu so let's get started but before that what you have to do you have to check if your machine is capable uh uh if your machine have node or others things so let me just search here so you will open your terminal and type node dasb so this will be node version it will check if this machine has node installed so you can see the node version is 20 1.1 so right now node version this is the node versions and if you don't have node install then you can just search node js and then you can install obviously I think you have already set up this nodejs if you don't have just just download it and set up it's very simple and then you have to check another one that is git so if you search G download then you will get the uh official websites you will have to download also this git you can also check it by this command actually so you can just type g-b that will check the version of the git and you can see the Git Version is this if you have this two version installed to uh software installed then you can just go okay so what we will do at the beginning we will have to create a folder let me create a folder here you can just create folder anywhere and for this actually I'm uh remaining it renaming it as a uh yoga Master you can just name it anything okay based on your projects and I'm just creating this folder and now we will have to open this folder on BS code I will use this uh code editor so I am just opening BS code and what you have to do you have to drag this folder and paste it here if you paste it here so look uh paste it here and then you can see yogam Master uh is here that means uh this folder is open and this folder is right now don't have any file and folder so that's why it's empty you can also uh if you want to open this folder by this you can obviously go to Open folder and choose your folder if you want okay so my favorite thing is that I just love to drag and drop so if you drag and paste it here then your folder will open on BS code okay so at the beginning we will have to create two folder okay so here you can see this panel and this is empty now so if you click here you can see a border is created there and at the top you can see this is file if you need any file you can click here and if you need any folder then you can just click here this is for refresh and this is for clubs okay so we need two folder one is for front end and one is for back end so let me create two folder here I'm clicking here and then uh at first let me Define front end and press enter so inside this front folder we will develop our front end part and right now we'll have to uh click on this blank space and then we'll have to create another folder that is for server or backends so let me Define back end and in this back end actually we'll have backend code so at the beginning we will develop our back ends and here you don't need to worry about I will show you from the uh basic so what we will do we will go to uh our Chrome browsers and here we'll search Express Js so to build noj uh back end you have to use express J and here you can see this is Express j.com the official website and we'll go to these websites and here what why I'm coming here actually by using hexpress uh website then you will get a step by step guidance how you can just build your first server okay so from this websites you can see get started if you click here then at the beginning you can see this is installation and at first it says MK dri then and name my app actually we don't have to command this actually we already did it here actually we have created a folder mkd means which this will create a folder for you and then as we have already created our folder then we will follow the next step that is we'll have to go to CD that means change directory and then folder name okay let's command it so you have to open the terminal you can drag it from here or you will have I access this terminal from here actually if you click here then the terminal will open and the shortcut is control shift and carot sign from the uh keyboard okay so let me drag it for now and at the beginning I'm using a g bash terminal so that's why it's showing something like this you can change your terminal if you want but I think G bash is okay for here and you can see there are many terminal and you can toggle by uh clicking here okay so at the beginning what you have to do you have to go inside this backend folder right now we on the pent folder that is Yoga Master this is the folder name so we'll go inside the uh back end so that's why the command is CD and then the folder name okay here if you type CD click here then type CD and if you press tab then you can see this suggesting the two folder and here we as we are going to go to the back ends we will type B and then press tab then it will suggest would you like to go to back end so yes you have to just press enter right now if you do this then you can see so this is our parent folder and inside this folder we'll have backend folder so we are correctly inside this folder if you do any command this will be working on this folder actually okay so the second step we have to initialize get in it we will have to command this we will copy this command and here we'll have to paste it so if you just paste it then it will ask you some questions but if you you want to ignore that you can simply Define a Das y that means you are agree with uh some questions actually question is okay I would like to Define Dash here and press enter you can see it will create a package.json file here so you can see a package. file is created and this file contains all of this data okay so let me open this folder and here you can see at the beginning it says the name this is actually the project name that we have the folder name you can just edit it if you want so you can just Define it yoga Master uh server or something like this uh then here you can see this is descriptions you can add author name or other system but right now it's okay so then the third option is we'll have to create a new file that is entry point this is actually index.js uh if you check this then you can see the main is index.js that means uh in this back end folder we will have a index.js file and that is the entry point to the nodejs app okay so that's why what we will do we'll have to create a index. Zs file that will be our entry point so let me create a file and we'll have to choose this backend folder and then we will create a new file that is index.js so this is the I'll write all our uh code here actually in this index.js file then if you have created this then the next option is you have to install Express so let me copy this command and here make sure you are on the back end path and then you will have to paste it here so we are going to install Express JS inside this project so that's why we will have to press enter from here okay so if you do this then you can see we will have a package on uh package log. Json file and package.json file if you check the package.json file then you can see on the dependency a another thing is added this is dependency and we're using Express so all the packages you installed will be included either in dependency or deep dependency okay so that's fine and now the next point is that you will have to go to the next options we have already command that we don't need to do it again okay then hit this next and here you will find some code you can see uh uh will have some codee and you can easily copy it and paste it if you just copy paste it then your server will be okay so to run but uh let me copy this first okay and paste it here actually in this index.js file let me explain it a little bit at the first light here on this line actually it's defining we are importing Express from Express package okay so require means it's import okay we are importing Express from Express JS and then here we're calling this Express functions actually you can see we're calling it here that means it's a function and we're calling it here then we will have a port this uh server will run on this port if you run the server that will be on this port and then here we'll have a gate so so get means you can just uh call any API by this way here it's a get call we are just getting class so that uh from the database we are getting all the classes here actually it's the similar thing get means you are getting data from anywhere okay we will explain it a little bit later and here uh on the r. send we'll Define a string that is Hello World then here we are defining app. listen that means uh what we do after getting this data it will just print a console log here so that is defining a port okay so for this how you can run this actually so run this here uh you can see this is the common node app.js but here actually we don't have app.js we have uh index. Z so that's why to run this server what we will have to do here let me do it will Define node and then the entry point is index.js so if you just press enter Then you can see example app uh I'm listening on this port so this console log is printing here actually and if you go to the browsers and Define Local Host and the port you can see the port is actually 3,000 so if you define this port 3,000 and and then press enter Then you can see hello world if you change anything here so instead of hello world I just Define hello developers developers and again you have to run this command node index. Zs after the node you have to defend the file name and then press enter then again example app running on this port and if you refresh then you can see how developers let me Zoom it so you can see this actually so this is our basic server by this way you can set up your server very simply and it's actually not a complex task okay our server is running and you can see uh here is the server okay but every time when you write edit uh or editing anything you have to run this command but it's not actually the best way so that's why what we will do who will in install another package that would be no demon so from here you can search no demon package or if you just def noon install SE it and here actually if you just check this no demon and then click here so it's a npm package we have to install this so that's why we're copying this Uh npm I that means install and then no okay we'll have to run this commment okay here so how you close this actually look here you can uh if you type something it will actually not work so how you will fix it you have to press contrl C to terminate this okay press contrl C and then you can see this is terminate and here is the options you can just write your command again or you can just open another terminal from here if you would like to do okay so let me paste it here npm I means install and we are not going to in install uh no demon so let me show you how actually no demon help you so if you press enter Then noon is installing okay so how you make sure this is installed properly if you check the package. this one you can see no one installed successfully so if you have this then you have to do another thing you have to write a script here so the script is the thing that when you just Define a start command then we will Define here noemon index. by typing npm inst start this script will run and our server will run always okay it will not stop okay so let me just drag again here we'll Define npm then this script actually no demon index. that is actually a start script so that's why will type start and if you press enter then the same thing actually you can see example app is running on Port here and if you check here actually refresh it you can see it's is still available if you type anything on this index.js file WR me let me hello developer 2025 then if you just refresh it then you can see it's automatically work we don't have to command uh node index.js every time it's actually always is running you can see the first time it's run is here then when you Ed it it actually run it here okay so every time our sub keep running we don't have to manually uh run it every time so that is the basic stuff we did here but here what if if you try to access to another port for example uh the another server is running on this port then you are trying to uh just Define it for example let me uh okay uh right now I don't have to show for you but uh here if another Port is running on this but you are trying to run this app on this port actually that will not work so that's why how you can fix it actually so we can just Define optional uh Port so that if any existing Port is just not available it will try to Define another Port okay so we'll just remove this and then here we'll Define process dotv then here we'll have to Define port and this port will have an optional Port it will try to just get in Port if not available then we can just uh do it another Port you can just Define any numbers here 5,000 3,000 or any number so if this 3,000 Port available it will run this server on this port otherwise it will do with another external Port okay so that's it you can either Define 3,000 or 5,000 my choice is 5,000 right now so if you now try to go to this R to this 3,000 it's actually not working you can see right now it's actually not working but what if if you want to run on Local Host 5,000 5,000 and press enter Then you can see uh hello developers 2025 you can just Define any number if you want then this way you can customize your put okay so that's it the basic thing of experences now what you have to do if I have to install mongodb for this backend projects we will use mongodb so let me go to let me close all of this stuff and we don't need to Define Express right now we can close it and this time we will set up our database so that's why we will search mongodb DV okay search it and from here you can see this is mongod tv.com and then you have to sign in or you can just click this uh try free or here you can see exra free so this is actually you can use it free for uh learning okay let me click here or here you can just click any of any of here so let me click here then wait so it's loading right now this is the option you can just sign up by using your name first name last name then your company then your email accounts and then passwords then if you agree then you can just join free but if you are using your Google accounts you can simply sign up okay so I would like to use Google account so that's why from here I will click this or you can just manually do that stuff it's not mandatory to keep it manually I am just going to sign up with Google so I I'm clicking here then you can choose any of these accounts or any of your Google accounts so I have already many projects set up on this actually and I'm going to do that again or okay so I choosing these accounts I have already did many times here actually you will see how many projects I already set up there so this is actually the landing page and by by default you won't be on this place actually uh it's actually another project set up there and you can see all of this project is set up but it's actually not working for you will just start from the uh beginning what you have to do when you are on this uh page actually you will click this logo icon click here then you will go to this dashboard and then you can see if you want to do another project then you can just create create a new projects and this is the basic things you will have to project set up a project first and don't be worry about all of this stuff actually you will start from here so come on this TV Atlas then you will create a new project I'm clicking here then at the beginning we will have to define the project name let me Define the project name yoga master and this is actually server or something like this I'm just defining this and here you don't have to Define tag here you can just simply after writing this project name you can just Define any name you can just uh Define your name uh whatever you would like to use and then you have to click this next after then you can see uh if you would like to uh give any exess permissions then you can just do that but right now it's not available we will do that on later so okay from from here you have to just click this create projects so this project is creating and after creating this projects you can see this dashboard previously yours just uh have seen that dashboard so this is actually created now so this project setup is done what you have to do you have to do a little bit customizations so at the beginning so database access you can see this is database access so if you are a fencer and your client you can ask your client to create a mongod database and you can get access from here by this actually you will hit this database access and you can just create a new database users for example uh so your client can define a username password and then create a rule for you for example here choose a rule maybe if you want a superior then your client can just Define it uh Atlas admin then you can just create a new users but we have already set up a new users so we don't need uh already created it so next thing what you have to do here you can see we'll have to go to network access it's very important you must have to just go there at the beginning so click here network access and from here we'll have to add a current IP address from here you can just choose a new IP address so you IP address is added and see a new IP address is added you can just add another IP address then from here you will choose access allow access from anywhere and then you I don't need to Define it temporary it will be uh keep always so that's why I'm clicking here always access and confirm it so at the beginning this is my IP address and right now this is actually we set up a custom IP address this is actually uh active always okay so it's still not active why actually we didn't have set up our database so that's why it's not active but it will active I will show you within a seconds okay then after defining this network access what you have to do you have to go to this database sections click here this is database sections and you have to create a new database so that's why you can just build a database click here then you will have to choose a plant we would like to use to go for free version so I'm just choosing the third one then we will choose the provider AWS is better so this is okay with me you can just Define your region you can choose any of this region and the Easter try to choose Easter one so right now this is the region and you can choose any of these if you would like to I think it's okay for me so these on then you can just Define a clust name so if you just would like to you can just Define a claster name but or you can just go with the cluster zero let me Define a cluster name that would be yoga master so this is actually cluster name it's actually not required you can just Define any name here after then you have to hit this create button uh let me choose this capture sorry this is not actually let's put something like this so capture completed right now here actually the important thing our database is creating and we have to exore this username and this password so let me uh keep it here at the beginning I'm just commenting it so this is username and we have to obviously copy this password it's very important I'm just also commenting this this the first one is username this is password it's very important keep it right now here we'll just secure that within a second but right now it's okay then we'll have to create a user click here then you can see a username is created right now we'll have to choose how you would like to use mongodb actually you can use if you don't have internet access you can use on local environment but I would recommend you can use cloud in enironment it's better actually so you must need it actually when you would like to host your server so that's why I choose Cloud environment and from here you can see we'll have already our IP address set uped to IP address this is my IP address and this is custom IP address for access from anywhere so it's already added right now everything is fine and you have to click this finish and close we don't need Qui guide so that's why have unchecked it and then go overview so already everything is uh fine and now we will have to hit this connect and then we will have to install a driver for this actually so there's a lot of option but for now actually we'll just click this driver and here we can just choose a driver as we're going to use nodejs actually so that's why this is nodejs if you would like to use uh other programming language for example python Ruby then Swip cotlin Java go and others programming language you can choose any of these so as we are using expressjs and njs so we will choose njs and here you can see the version try to use the stable API and the latest version so that is 5.5 and here it says the second step is you have to install mongodb let me install mongodb we will open our terminal our app is running okay let me uh try to take another terminal we have already run a port we don't want to stop it keep it running and from here we will choose another terminal so for this okay let me choose kid bash or command promt it's okay command prom is fine for now and here right now you can see the folder is Yoga Master but we will just install one our Command on back ends so that's why we will defend CD and then back ends then press enter right now it's on back end and here we can install this uh mongod okay copy this and paste it here press enter mongod is installing can see this is the installing process is running uh it will depend on your internet speed okay fine you can also check the package.json and here you can see Mong is installed okay so after doing this here you can see a short code and then if you want the full full code sample then you have to toggle this let me get the full code okay so for this actually you will have to toggle this then you can get a full code actually so what you have to do you have to copy this and then after this actually you can simply after this you can simply paste it uh let me comment it mongod DB uh here DB connection okay and I'm pasting the code here so let me paste all of this code here and here let me show you a think here actually uh we are requiring client and server API from TV we are reording this two fun function from the mongod TV okay then actually we are set up a e Ur is a URL string by this string actually mongod will connect on this actually on this nodejs project to the uh mongod TV platform actually so this URL is very important actually because using this URL we're connecting mongodb to this node app okay after then here you can see we're creating a client so this is actually client and here we're using that URL so that it can connect and then when it's done we will have a Asing functions you can see we will have a Asing functions if you don't have any idea how you can just Define Asing functions so here is the thing you can see at the beginning we will have a asnc then we will have a function so as it's a function and this function is run functions so this is the function name and here we Define the function call actually here we Define a function here and we run it here so without running it this function will not execute so that's why you must have to run this okay so inside this actually we'll have a trke and finally block actually if you don't if you have idea we have if you want to catch Z you have options you can just do try catch and finally you must if you use try you must uh either Define catch or finally okay so at the starting code we are just calling client connect that means uh we are just trying to connect to mongod DB by using this AB URL so AB a API actually above functions by this way we are just trying to connect after then here we Define client. DB so we Define this is admin and here we ping okay so everything is fine now uh if you just check uh your terminal you can see there is an actually error you can see server error bad o and authentication failed you will face this problem many times and how actually fixed it actually look it's very simple problem if you scroll a little bit here you can see this URI and here actually the password is not set uped so that's why the ER uh you uh error so if you just copy this password and just replace this okay let me delete it and paste it here if you just do this and then you can see ped development and you successfully connected to mongod if you just get this then we can say that you are just uh set up mongod properly okay but what if if you keep these your username passwords anyone can access your database and just destroy your all of your data so we don't do that we'll have to secure it we don't uh provide our username password publicly so that's why we will have to secure it how you can do it so we can do it using a package let me close it we don't need this right now and from here we will search EnV do EnV and then npm if you search this npm packages actually by this packages will secure all our sensitive information so how you can install it you have to command this copy this and again we'll have to install it so that's why we are choosing this second terminal and we p paste it here so installing EnV using this package actually we are secing some our sensitive information so install done then the second option if you scroll a little bit the first one is installation the second one is how you can use it you have to create a Dov file on the root directory you can see it says on the root directory if you explore the information you can understand properly uh as a developer you must explore the informations from the internet actually let me create a file and how you can see which is actually root directory you have to click here on this package. then if you hit this new file then it will create actually on the root directory so click here then we'll Define do EnV file at first do EnV file and here you will have to write this way actually you can just Define this way this way okay so let me do it here we'll Define DB user so that means database user and here we'll have a equal sign and a quotation inside this quotation we'll Define the user so let me do it from here this is the user name and we'll keep it here after then we will have another one that would be DB password and here we will Define this password okay okay if you do this we don't need to do have this we'll remove that on and then the next option is you have to import it uh so by this way actually we will Define require. config we can choose this one okay so you can just copy this and just add this uh at mass as top you can so I'm just adding this at the top here actually pasting it here so if you do this then if you just console log right now console log this way how you can just do this let me check it you have to do this process Dov then let me Define process do EnV and Dot here if we Define DP user okay if you just check your terminal you can see uh this is my name if you define here DB username and a comma here then you can see actually DB username and uh this is my actual username so this way actually you can access this EnV variables so let me delete this actually so right now we'll replace this actually we will have to replace this username and this password okay from here so how you will do this we will have to convert this string as a template string so instead of this double quotation we'll use template string so you can just Define this string and also this string at the end you can see we are using template roral from this keyboard actually the sign is uh above the Tab Key okay so if you don't sure you can just search it this way actually template string template LS so search it here then you can see this is actually template liter else okay so you can just read this if you want actually this sign you can just copy these actually uh you can just copy all the whole things and paste it these way and you can just replace this URL inside here actually it's actually depend on you if you don't find this icons on your keyboard you can just do it actually replace copy this and paste it inside here okay so I think you will understand that so now we'll have to customize this we want uh we don't want to directly show it on everyone so that's why here we'll delete the username first let me delete it and here we'll Define a dollar C craes inside here we'll Define process Dov dot database name so let me copy username so this is database username okay and now we'll remove this password so remove it then uh dollar sign crais and here process do Dot database password paste it here so if you do exactly what I did then you can see still so wait so pinked development uh your developments and you successfully connected mongod so everything is fine if you push this uh code to GitHub no one can access this actually no one can access your database actually this database is uh right now secure okay by this way you can use for this okay so if this database is secure right now what the next actually we will have to set up uh database so how you can just do it you can just do it two ways actually so after connecting this you can just click this add data then you can just uh choose any of these options but we don't actually do do this we can just simply create our database from here so after this uh after this actually after this uh connect client. connect here actually we will start creating our database so let me create a comment here so create a database and collections okay so here after this comments actually how we can create a database so let me check it we can just close all of this stuff this is actually not needed right now and we will go to this H sections or you can simply search it mongodb C us this example so this is the keyword so you will search this so if you just do it here you can see so us as example you can click this URL and here actually uh crate operations so from here you can just go to Quick started and after mongod TV install you can see create a mongod TV database and here you can just find the guidance Get It Started With mongod Atlas actually you don't have to do all of this stuff actually let me just show you simply what you will do uh let me back here again back here okay uh let me choose it from here we'll click this users example then we'll open it here actually so this is the exact URL so after connecting this what you have to do uh for example let me insert a new operations and here you will find how you can set up database okay so at first you can see here we'll have to create a database by this way we'll Define conos database equal client. DB then a database name here actually this way actually we can just create a database and this actually how we can create a collections okay so let me Define it so at the beginning we'll Define KOST and here we can just copy this actually the whole thing conos database uh let me paste it here so this is create will it will create a database and here we'll Define a name so that would be the name of yoga master so this database name will be yoga Master then we will have to Cate uh create a collection so actually for these projects we'll have many collections for example we'll have a classes collections so then we will have a collection of users collection so let me search so that will be a w it's still loading so this is actually user collection you can see uh actually it's still loading keep it there we'll need uh many collection so we'll create all of this collection first how you can just do it so for this actually maybe the result is okay this result is existed right now so we'll have to create a collection so the way is that you will have to define a name here then database Collections and something like this okay let's do that so how you can just do this here we defend const and here the first is one is user collection user collection okay and here we'll have equal sign then look here the way is that you will have database do collections so if you just choose database name here if you want any name you want to hear so that will be database do collection and inside this collection we will Define a name so at the beginning here we'll Define users so this collection name is users so right now if you uh just hit this database and then view this collections but you can see this is connected if you just go to this browser collection you can see anything actually we don't have any data so that's why it's actually not showing but when we'll have it will show actually okay I will show you a little bit later so this is the first collections then we will also create other collection the second one will be collection for the classes so class classes collection uh we can just Define it users collection it's uh depend on you how you define your variable okay so that would be database dot collections then here the collection name so class collections then we will need card collections so conos we are creating some collections so card collection and that would be Cur then we will have another collection we are just creating all our collections we'll have payment collections where we'll keep all our orders so payment collection so the name will be payments something like this after then we will have course enrollment and uh instructor apply so that's why we will have enrollment enrolled collection and that would be enrolled something like this and finally the last one is actually applied collection so conos when the users try to apply for in uh uh instructor to be an instructor will have uh applied collections so applied collections so here the same thing database do collection then here we'll Define that would be applied okay all this collection is just completed so if you have collections then next one is you have to uh upload data here so if you just try to do that you can just load sample data or you can just add my own data from here you can just choose the database name you can choose the collections name and here can choose uh these options okay so let me refresh again if it's working or not showing this database it actually takes a little time to present all of these collections here but don't worry I will show you and exactly show how we can just do it let me refresh it okay so let me simply post a data to database so that's why at the beginning we'll Define uh we will post a uh new classes so let's how to post actually we'll Define routes here so at the beginning here we'll Define class classes routes routes here okay so at the beginning we'll have to post a new class so how we can just do it so for this actually we will post uh we will use post man so post man so here you can just run all your API and test it so at the beginning we'll have to go to postman and you will have to install it so okay download download for Windows and let me choose a folder so here I'm downloading Postman using Postman you actually create all your API from the uh app actually you don't need to have to test it on browsers for example on browsers actually you can just test on uh just get request but you have to defend post request and others request so that's why we'll have to download that on first okay when it's downloading let me discuss a little thing how API actually work how API request is actually work so for this let me go to it is and I'm just showing uh this example from here actually wait so it's still it's not working so let me log in I'm just using this so that I I can just discuss the topics so uh with you very simply so let me log into this choose accounts and it's you don't need to have to create accounts here actually this is actually for explaining purpose okay so I'm choosing here my internet connection is very slow right now okay so at the beginning I would like to discuss a little bit about API request so there are some difference request actually on the first one is you can see uh lots of time get request so get method or request uh let me Define get method what actually defines so dat uh gate methods is actually defining for example here this is your database so let me Define this is your database this is our mongodb database and here uh the another is this is our website let me comment website okay so here we will have some collections for example the at the beginning we will we have created some collection here let me see at the beginning we'll have class collections user collection all of these collections so inside this database we will have collections so for example here we'll have a classes collection okay classes collection and inside this collections you will have all of these data actually for example we'll have something like this classes dat and we need actually this data you can see we'll have lots of data on these Collections and we need these collections data we need this data on this website so that's why uh how we can just call this data to call this data actually you can just uh here for example we'll have a button and we will Target these Collections and just call it so for this will will use this G method actually we'll just use this G method to collect this class data from the database and show it on UI so this is actually get collections so the another thing is that post collection so let me copy paste it and that is actually post method so how actually post method will work so let me keep it here post method will work differently for example uh here inside this website we'll have a form so maybe we'll have form this is a user form here we we will capture username so maybe we can just copy the two thing we are just capturing username username and maybe we're capturing password password so we want to just keep a storage uh keep this data on database so for example here we'll have another collection so that is actually user collection so that we created here actually look here we have created a user collections so we'll have a user collections on this database and we will store this information for example um we'll just post username and password on this collection so that's why to post this to the database here through this actually sorry to this actually we'll use this post method post method okay okay so post method will post any data from your website to database so here a little bit okay so by G get methods actually we can collect data from the database and post methods will p uh put data on database okay this is the two thing that next one is we'll have delete method so let me Define delete method so what actually uh do it actually for example you want to delete a class so for example here we'll have this class data actually this is a course name and we want to delete all of these data so that's why to delete this will just uh call this database class database and and here we'll just do a request so that would be a delete request to this database will just Define a delete request to the class database by using delete method actually so the method will be delete method so let me Define that would be delete method for removing data so if you want to remove any any data from the database you can choose this remove method okay so delete method actually and then the another two one is actually uh the another two one is actually for put method put or patch patch method so these two methods actually work when you want to update anything for example uh if you want to let me show you uh here we a store data about the users and for example if you want to update a username so here we'll have users and you want to update a username so to do this you will call this method actually will update information by putter patch update information so to update any informations we can just help with this method putter patch but here is a little bit difference so P method works if you want to update a single field for example if you only update the username it's actually partially update one or two things from the database this will work for pass method and put method upload full data so for example here everything uh a full data if you want to update completely the full thing actually you can update the name image available Ser price course and all this information if you want to update all of these permissions then you can use this put method so actually this is for wall data and this is for partially one or two so if you only update this maybe if uh me this name actually then you can use the help of the pass method and boot method upload everything the so this is the uh databased uh request Basics so API request Basics and I hope you understand this I think the uh Postman is downloaded so if this Postman is downloaded we have to install it uh wait go to the folder directory and here I have already clicked it's already working so let me close all of this stuff right now and here actually installing you will have to log in so let me just log in I have already created accounts okay uh I forget that so let me just uh login with Gmail so I forget to have let me just try to create an accounts continue okay so Postman is open right now you can see this is the post man and at the beginning how how you can just uh let me allow the networks okay here is a little thing maybe let me do this soon or let me choose your name and here let me back in developer continue a little survey shown here but don't worry okay everything is fine when you just open it here you will see this interface and at the beginning let me close all of this stuff what you can just do hit here so let me customize it here you can see a plus icons if you want to test for example when you just uh hit this route actually uh you can see Hello developers so we can do this on actually uh here actually if you click here then you can see there is a others option here you can see all of this request you can just request uh uh get request post request put request P request delete request so all of these request you can just TW it here let me show you if I just copy this Local Host 5,000 and Define this port here and it's actually get request and then if you just send this and here you can see Hello developer 2025 that is exactly what is shown it here but here you can see this is exactly showing the same thing if you check it you can see on preview you can uh check on pretty so this way actually API will work so I think you can understand how it will work we can just test all your API using this tools so this is actually get request if you need post request you can choose it as a post request if you need put request you can Define it put and then send request okay so my next task is we will create a new class we don't have any class on database so that's why it's actually not showing but if you want to show it here we will have to Define post request so that's why we Define app do post I have already said if you want to exactly post something on database actually you will have a post request so here let me Define this way here at the beginning we will Define the route so route will start from slash and then we'll Define new class we'll post a class on our database so that's why post new class actually and then here we'll have a arrow functions we'll have Carly veres you can see this is actually a arrow functions here and inside this Arrow functions it will receive actually two thing as a parameter so at the beginning we'll have request request and response inside here you can see uh you can just Define this way so inside here what you have to do will just receive uh for example when someone submit the information here so let me go to the routes here we'll have let me copy this and paste it here and the route is these routes actually new class so will when someone hit this route let me remove it and here it will be post request that would define post request so we'll Define post request here so we will send some data in this body so if you send body and let me Define row data and here we will Define it Json format so for example let me copy some data from here we can just copy the whole thing and let me paste it on the body sections we don't need to include the ID it will automatically generate but maybe uh it's an error actually it's not closing properly that's why this way okay so if we see here we'll Define a name of this course then a image URL then available seats price and all actually data uh of classes actually okay so if you have this information and hit this sent actually it will do a store on body so that's why at the beginning we will Define KOST new class equal required if we send data on body you can see we are sending data on body so this is body and this is format actually Jon format we're sending data on Json format so we'll Define require require do body we are sending data by body so that's why it will be required body and then we'll call this another one so that would be new class do available seats so here you can see we'll have available seats so we'll check it first it's actually not required right now but we will do this and then here we'll def par in and inside here we'll have new class dot available seats okay but it is optional you don't uh it's actually optional right now so I would WR I recommend you to comment out right now let me show it again first and here we'll have to send it if you are not familiar with you can just check it on here actually how you insert we're going to insert in document so here is the process I show you at the beginning you can see we to have to create a documents so we just receiving informations uh on the body so that will be body and then here you will have to Define results then a then this is the database name and insert one actually okay so this way actually we'll Define conos result then here we'll have to Define air we so if you want to Define a you will have to choose asnc here so Define asnc function here and that's why we can use a and here at the beginning we will have to call this collection so that would be class Collections and here we'll have insert on if you want to insert a document then you will have this method insert want and inside here we can just pass this new class so if you pass it here okay so our API is created done here so API is created and finally what you have to do you have to post it so that why rest do send we will send a request so that's why R means uh request and here is send uh response actually sorry this is for response and we will send the response and we'll pass this results actually inside here so if you do this then API is created now right now if you just hit this just if you just hit this button then here uh here is an warning so what is actually happening let me try it again so is still an error let me check what's the eror if you open the terminal actually so doc ID equal null is and uh doing an error okay okay uh maybe I got these issues actually we will have to create some medware so let me install course so here let me Define the two things we'll have to define a uh package so that way HPM install course okay so this is done then we'll have to Define to metal so metalware okay so app dot use then we'll have to call this or we'll have to require const course equal requires course and we'll have to call this course col it from here and after then we'll have to Define app do use we'll actually Define this so that's why it's actually working express. Json then here call this H1 format so I think right now let me check if database is running and right now if you send so acknowledge through that means we have posted data successfully actually the error is that we don't have to Define express.js actually we are sending data but it's not actually uh receiving the JS information so that's why the data and right now if you check your database and here if you refresh sorry if you just just uh refresh it then you can see we will have two data you can see uh inside this database this is one and here actually uh a database is created so that is actually two data okay so we don't actually it's actually manually created we can don't it we can just delete this actually we'll have the database so exactly the database is here the First Data we can just to eat another one so let me just try to insert this one actually right now and the same thing actually we'll Define the post method here we will Define the URL and here we will Define the think here we don't need to define the ID it will automatically taken and then what you have to do you have to send it okay acknowledge true that means if acknowledge true then it's inserted if you refresh this database then you can see all of this data is here we'll have two data so if you have this two data you can just get a post all the data uh this way but we don't do this how you can just do it let me copy the everything so I'm copy all of this data so if you have data created you can post simply this way actually so I'm just uh inserting documents by this way I will click this insert documents then choose this Json format here close everything and then Define a AR of objects and we are just posting all of these data by this way you can don't if you want you can just ignore this ID so it will uh take the ID dynamically I'm just removing all this ID from here then obviously the third one it's actually not mandatory but I think uh don't include the ID if this ID will dynamically taken then it will give you a little benefit so here the ID is closed the ID is removed okay so if you just hit this insert button all the data will be inserted you can see right now we'll have six data if you want to just post any data you will have to hit this route uh when we just work with front end we'll just hit this route and then from the body we'll send data we'll have a form inside this form will capture all of this information and send it to this URL so that it can post on the database so right now we'll have six data if you will have all of this data what to do you have to get this data so that you can just show something like this way okay so how you can just do it so for this actually let me close this so after this actually we'll have a app. get method so that we can get data from the database and here we have to define the route so the route will be classes so these will be classes and here same way assing our waight so AR functions that will receive required response so here make sure requir is fast and then response otherwise you will get an error so here what you have to do you will have to Define uh this way so let me get the details from here so you want to find a data so that's why the find operation and here find a document so this is the way actually you will have to Define database we will have already did that then you can just do a query so you can just query this way so let me copy this query and here let me paste it so the query instead of title will do uh if you check here actually we have a status we query based on the status only available so here uh if you check the websites actually uh on this classes sections is actually still loading Let me refresh it wait it actually takes some sometimes actually the server is is still waiting for the data so only approved uh course will show so that's why we'll do check it based on the status so that's why we will have the status and this way so let me Define the query will be a status and here we will have the value of approved something like this when approved we can just show that data so that's why approved so this is actually query after this query what you have you will have these options you can just Define option sort if you want to sort then you can just Define sort by this way but I think it's not required but if you want to Def sort you can use this can sort your results okay and then the last one is execute these way find one method and then you will pass this two thing actually okay so let me do this here we'll Define conos result then we will have to Define air we at first then we'll call the collections so that would be class collections here we'll Define find one uh actually find we will uh find all the informations actually we will find multiple document so that's why the second one actually so that would be the same thing find very actually so find methods and here we'll pass query and options so we don't have options so that's why here we'll keep it and then we'll have to Define uh to array we'll have to convert it to array then we'll do it okay then after this we'll have to define a response so rise. send results so it's okay if you hit this URL and then you will just see that so let me duplicate this tab and instead of new classes we can just Define slash classes and that would be the gate method you can see this is actually gate method so we'll Define get and if you send request then you can see all the data you are getting here and right now you can just as it's a g method you can also test it if you go to the classes routes class route then you can see let me Zoom fixed Zoom then you can see all of this data is here all the six data are presenting here so actually we'll have defined the two thing actually one is for how to post a new course on new classes and the second one is actually for how you can just load uh uh get the data okay so after doing this what if if you want to um get uh a special guest course by instructor so for this actually you can see actually here we will have another thing so instructor email you can filter uh a specific course by email so how you can just do it let me add a comments get classes by instructor trctor email okay so we would like to get courses by instructor email so that's why we will have app.get method and here we will have SL classes slash and here we'll Define email then we'll have asking award after then inside this actually what we will have to we will have to Define find a conest query the same thing uh instead of query we can use uh email first we have email and at the body what we will do we will check request. prams do email and that is actually let me remove all of this stuff it's actually automatically generate we just Define the email from the params actually uh what if uh how you can just do it state of this let me show you here when you can just Define the email for example this email here you would like to get uh only the courses available for these users actually okay something like this so that's why this way after the first one we'll have this then we'll have a query the query will be something like this we'll filter based on this email So based on this instructor email so this is the field then we'll Define here we'll pass this email something like this after then we'll Define conos result equal we will have to Define airw then class collections then we will have find find method then in inside of this we will pass this query this query actually and then we will convert it to array after then we will have raise. send okay the path is done and right now if you just uh refresh it then you can see one course available and this is by filtering the email okay so if you want to filter based on another email for maybe this email then you can see here after classes you can just Define email address press enter Then then you can see uh this instructor has two course actually the first course and then two course actually if you check uh incorrect one so for example let me Define H one then press enter Then you can see an empty thing that means we don't available any courses okay you can also test it by this here if you def find a email address so for example email address then you can also taste it on Postman only one cours is available by this email so these users only created on uh courses so by this way actually you can filter based on the instructor email actually okay so this is perfectly working after this the another one is how to manage courses so for this actually we'll create another one here we will have manage classes so and here we'll have app do get method then we will have a route so that would be classes manage okay and here the same thing as syn required then respon then you will have Arrow Carly bres and inside here actually we will have a result conos result equal we will have air wa and then we will have class collections something like this and it's very simple this way you can just when you hit this it will simply let me test it by this actually when you hit this route it actually showing all of these classes okay so it actually not filtered either it's uh approved or not it actually automatically give you all the classes it's not actually filtering so here you can see we are filtering uh we are filtering based on this everything but here we don't actually do filter okay that is the differences is here so after doing this what if if you want to update so for this after here uh updating for example you want to update information so that's why update classes okay so I already said here actually to update we will have either put or pass method okay so as we Define we'll Define app dop method and here uh for example we want to change the update of the status of the class so that's why we can just Define here that would be change change status and here we'll have a sync then we'll have require request response then we'll have Arrow sign then what we will do uh at first we are getting ID so ID will be request dot params do ID then we will check the status so status will be request body do status then we'll just check also conos region so is there any region okay this region actually so we'll check this region and here we'll Define request body sorry body dot region okay something like this after having this we'll filter so con filter so for this actually you can check documentation so here actually this update and replace so updated documents so here actually look so we'll have filter options we can filter based on title and other system so that's why filter and here the filtering option is Will filter based on underscore ID every uh data has an unique ID this ID is actually unique so that's why we will filter based on underscore ID so that's why we will filter based on this so as this is unique so underscore idid and here we'll Define new keyword and then we'll have to define object ID we will have to import it click here so you can see we imported that on at the beginning we will have imported object ID so object ID then inside here we will pass the ID from the above so this ID actually okay after this we can just Define the option upsert so here can see we'll have to Define options upsert through okay after doing this then you can see we will have a updated Doc and this way we have a set seter functions inside here so let me copy this and paste it here in state of uh C function is way instead of this plot actually we will Define a status would like to Define update update class status EST status and reion okay and here we'll Define the two thing instead of this the first one will be a status equ call a status and then we will Define reason is equal reasons and if you do this finally after having this we'll Define const result and then here you can see you don't need to memorize it actually we will have airw then we'll have database name then update one and you can just copy all of this stuff okay a wait database name class collections then we'll have update one and we'll pass at the beginning we'll have filter then we'll have updated dock then we'll have options okay and finally what you have to do you have to send this results okay uh let me Define it as a pass method so that it will only Define the a specific one okay so what if when someone hit this actually let me Define a path so here we will have have local 5,000 then this path so sends a status and here that would be pass method and inside this body okay actually we missed a little bit we have an ID here so that we can just get the ID so let me clone ID actually okay we would Target a specific uh class name so here so this is actually let me go to all classes and here maybe we can just Target the first one so the ID is this one so after this we'll pass the ID and then inside this body we will Define the two things the first one is we'll have to define the a status we'll have to define the a status and then the second one will be the region this region okay I'm just copying paste it here okay so we will just change the status when you click the same button it's actually uh just change the status right now the first one has a status of approved but will Define the status will be painting so let me Define pain ping pending okay so when you hit actually you can see this specific on will have a status of uh a status of will be obviously pending and you can change the value regon maybe you can just Define a string that would be updated okay something like this okay let try to send it if you click Send then you can see acknowledge true and modify count one and everything is working so if you right now refresh this then you can see the status is painting and updated reason is updated so this way actually you can just uh update any class status okay I hope you understand it's very simple if you understand the basic knowledge from here it can actually very simple so that's the everything actually okay okay so this is actually working and after then what you have to do you have to get approved class so for this actually get approved class don't worry it's actually lots of API so that's why it's a a little big so app.get and here will Define at the beginning approved classes and that would be ASN air w we have C brasses and here same thing and inside this we will have require response okay and here obviously Arrow sign okay so after this actually we will Define a query so conos it's same thing actually we'll have query the query will be a status status we can have a same query at the above we'll have a query the when the status will approve we can just get the things so that's why we'll Define KOST result and here we'll Define yeah wait class collections dot find then here we'll pass the query then we'll convert is to array okay simple and then we'll just sender results okay so let me just show the uh thing actually it's a get method so we can run it on browsers actually okay so for this actually you can see when you are hitting on the class route you will have 1 2 3 4 5 6 total six data but if you hit this let me just show it again Local Host slash this route actually so that is approved class all approved class shown on this route so if you hit this API and then press enter it's actually not showing why actually let me check the console log R.G ASN a request sense quite actually not showing let me try again approved class there is no error actually let me check if I did everything require response query equal con is status approv status then we'll have re find then inside here we'll have query and TST string then finally convert it okay so if it's not working let me run this server again so clear everything then npm start command so run the server okay so this time I'm going to just check it with the API okay here we are creating local host then we'll have the route so that would be uh let me close this that would be approv classes and here we'll hit this actually uh can get the approved maybe we'll have to pass a query so let me pass this one and here let me check it's actually getting so the query will be status I'm not sure why actually it's not showing it should show this so let me check can it get for actually get method approve class everything is fine actually okay let me write it again app dog method and here we'll have a approved class classes then we will have as sync then we will have request response crais and then inside here at the beginning we'll have conos query equal will have actually a status so let me check the a status here so this is the a status stuff so let me copy this and paste it here in instead of we can just remove this and we'll have approved the second one let me open the second one we will only just get the approved then we will just const result result equals we'll have a we then we have class collections then we will Define find method and here we will pass the query then we will have to array and pass and then finally we'll have a r. sent okay so let me try again okay we are getting all this results okay so right now check it so here actually if you close all of this stuff you can see we'll have only five data so 1 2 3 4 5 but here when you hit this classes you will have six data so the first one is actually painting status so that's it's actually not showing if you make this uh actually uh approved then you can just get it completely okay so you can update the data by this p method actually instead of this you can just Define approved then you can just get all of this stuff so let me just approved and change this value actually then we just get here that would be null and if you hit again then acknowledge true right now if you refresh these classes then you can see this is approved and if you have approved actually you can get right now all six data okay let me check 1 2 3 4 5 six okay all approved course is showing on here and finally uh here everything is done for this class route all of this route is actually for class route here you can see we did lot of stuff we'll have all of this stuff for the class route and next we will create uh the route for the actually we we need another one actually we need a single class we have to did update things but actually we will have single classes and update classes we'll have actually painting two things okay so the second one is we will get class details by single class get single class details okay so how you can just uh get single details for example here if you just Define something like this class slash ID wait it's actually loading I don't know why is actually not showing let me copy this and here refresh it again the internet connection is very slow okay so I will I'm just showing it here for example when you hit a single class route then you will define an ID here then it will show specific class details so how you can just do it so we can just have a set up a route so for this app.get here something like this okay let me just do it from again so so we'll have sorry my keyboard is doing something like this let me app.get and here we will have single class so that's why class then we'll have IG and then after then we'll have a comma as sync then we'll have request response and inside here we'll have to do get an ID so that's why con ID equal we'll get the ID on request do params do ID so if you have this type of thing you will get this on here actually you will get this on params actually then you will Define this ID here okay after this ID we'll have another one so that would be con query the query will be the same thing underscore ID will be new object ID we did it at the above so where is actually uh actually this here is not on maybe manage class will have this thing we will have filter the same thing actually we'll do here and copy this and paste it here we'll have to search a query and then we'll just get query on the ID then we'll have conos result equal we'll have a wa then we'll have class collections then we will just Define find one we don't need all documents so that's why we'll have find one and we'll pass this query okay after then we will Define r. send and then we will send that result okay so if you do this then right now if you hit this route actually this route it will show a specific ID okay so if you now refresh it then you can see one a specific course ID is showing so if you have another one so if you want to get the second one maybe exercise Hax for human if you copy this ID and if you hit this specific ID then you can see exercise ha for women so a specific ID you are getting by this route okay so after this the final one is what if if you are want to update all of these informations of a about a course so update CL details okay so how to update all the details so for this actually we will uh do app. putut method so right now actually we're updating all the necessary informations here we'll use p uh pass method why actually pass method pass method is actually for we are updating only two Fields but St a T us actually we're updating two Feld so that's why we're using pass method now we'll update wall informations so wall data allall data so that's why we will just do it on put method so app do put method and here we will have something like this we'll have classes firstly we will just Target an a specific class so that's why we'll just Target based on ID and and as we are updating we can just rename this so that would be update Route so update class and here we'll have asnc then we'll have request response and inside here actually what you have inside this Carly bres at the beginning will get this ID by KOST ID equal request do params do ID it's actually the same thing you can see here actually if you check this where is actually change the status so it's actually same thing you will have to get this then you will just quer it so you can get information on body and other system so let me con update class update class we will get this class on body so request. body then after then we'll have filtering so how we can just filter so you can filter based on the uh object ID after then we'll have options so options will be abser through and finally we will have update doc so const update do so that would be same thing we'll have a seter functions here so at the beginning we'll have set then we'll have a colum then CBR is inside here we'll set uh we'll say change the name of this course so that would be name name field so name field will be update class here will be update class do name then we will have descriptions so update class do descriptions then we'll have uh we have to Define comma actually we don't have to Define notations here we'll have after descriptions you can see what you can update you can just update price you can just Define here price price will be update class do price after then we will have available seats available seats so that would be par integer and here we'll Define update class do available seats then after the and we have video link so you can just copy this stuff so video link then that would be update classes dot video link after then you can just include the a status so a status will be painting painting and finally you can include lots of of others information based on here but I don't want actually I keep it in short but if you want to update more field you can include it and finally at the beginning we can just do Define con result then we'll Define a wait then we'll have class Collections and here we'll have update one so update one and at the beginning we'll Define filter then we'll Define update Doc and then finally we'll have options okay and then we'll just send results okay that's it so let me just test it so as it's a put method we can test it on browser so that's why we'll have to test it on hostman so let me create a new browser here uh at the beginning we will have Local Host so 5,000 inate of this actually we have something like this here we'll have the ID so let let me get an ID so for example we want to update this one let me keep the ID here and here we'll have to information on the body sections through Json format okay so let me copy some informations from here we will update the name okay let me copy all of these informations and paste it here and we we don't need to include ID here then we can just Define exercise hacks for Omen and here we'll Define and girls okay this is the editing and instead of the available seat we'll Define the available seat will be 250 then the price will increase this 150 then maybe we don't need instructor name we don't need descriptions we don't need to update emails we'll remove that so we'll update a status that would be painting so let me sorry painting status so that we understand we don't need to Define submit ID we don't need to Total enroll we don't need to uh this all of this stuff so we only update name uh image uh is image connected so if you okay not need to update image if need then you can keep it okay so available seats price video links status okay we obviously need description so let me include the descriptions here so let me I also add this one so you can just change that descriptions from here okay so description is maybe here we I'm just defining this is our updated description okay something like this then we include price available SE okay that everything is fine so right now we'll have to Define post method you can see here this is actually put method oh sorry I'm sorry it's actually put method then if you hit send let me click here then acknowledge true and modify counted one that means it's a specifically working if you refresh then you can see it's women and girls that we Define it here on this line then we'll have available 250 then price is 150 then the descriptions this is updated descriptions and others stuff are included only updated all of this stuff that we did here actually okay the others Stu uh the painting is here and other stuff is also included but it's not changed actually okay so everything is working so this route is obviously working so let me close this I think all the class routes has done right now so we can move to the users uh users routs and other routs we'll have to do the same thing for the collections all of these others collections actually class collection is done we will work with card collections we will work with payments collections will work with uh enrollment we will work with uh applied Collections and uh other system so right now it's okay so you can see that we have created all the classes route and we can test it on browser so but before that let me run the server right now we're on the yoga master so this is the folder name and we have to go inside this uh back end folder actually we are writing all our code on back end folder so that's why we will Define CD that means Sange directory then B you can use tab to get suggestions and when CD backends you can just press enter so right now you on the perfect folder this is backend folder and here we have to run npm start this will run the script uh node index. says and then you can see the server is running on this port and mongod is uh connected successfully okay so if you have you can test your all classes from here if you just try to get classes routes then you can see all the classes are here if you want to get single class then let me copy this and here the route was something like class SL single class ID then you can see the classes ID is here you can just do put operation patch operations you can do uh update delete and lots of stuff so right now uh today what we are going to do uh we'll write another rout so for this actually here you can see we have card collections and we'll uh make routes for the card collection so let's do that here we will Define uh let me style something like card routes and here we can just add some styling it's actually depend on you okay so something like this and here we will Define all our card rout so but before that if you check uh I will provide this data. Json file where you can find the sample data actually so you can see this is the user sample data will when we just uh create a users we can capture all of this information and send it to the back end then you can see this is the classes data format and this is the card so when we are working with card we will just get an ID we will have a name we will have a class name and instructor Emil something like this we will have to uh just select this type of informations on database okay so you can see the sample here so if you have sample then you can create a post method to post data on the card collection so that's why we will Define app do Post then we will have to Define route so that would be add to card something like this and here that would be Asing functions and that would be request and response and inside here what you have to do at the beginning so inside here at the beginning we will Define const new card item card item or something you can just do any variable name here and here we'll get it from body so that's why require from body then we'll Define in results so const here results and then we'll Define a weight first and then we'll have to call the card collections you can see this is card collections so we'll call the card collections then we would like to insert one so if you insert something on database you have to call the insert one actually we only uh insert one data and inside here we'll pass this new card item so for this actually how I did this you can just check it on uh here actually if you just search mongod card us just example and explore this us just example from these websites actually here actually you can just find insert operations so where is actually insert this is insert operation insert one document so this is the process here you can see uh the process is this is database name then this is insert one and then you will have to pass a documents the documents we are getting is here actually from the body we are just getting this information from the body then we'll have to Simply race do send so we'll send a response to the backend server to the mongod database and then we'll pass the results okay so let's test it so the route is here we can just copy this and then we'll set up another routes here sorry at the beginning we will have Local Host so it's actually not sugesting let me copy it paste it here then we'll have to copy the route so that was add to card rout and here we'll just Define that and this method is actually put methods uh sorry post methods so this is actually post method you can see this is post method so I Define it from the Arrow post method after then we will have to send some information on body so that we can just require from the information from the body actually okay so that's why this is body then we'll hit this R then we'll choose this Json format and inside here we'll pass the similar informations that we have defined here you have to pass this type of informations okay so you can just copy this information right now and here you can just simply paste it we don't need to include ID so we'll remove the ID from here after then if you just hit this send then it will be posted on database okay let's try to click the send button then you can see acknowledge true inserted id1 that means the the content is posted on mongodb let's try to check it so this is our database right now we have own collections here but if you refresh then you can see cards collection is here this is the card collections and the information is stored on database uh using this similar method you can see we'll have ID name class ID and instructor email the same thing actually where is this uh it's actually the same thing ID name class name uh and here is the instructor ID this is the same permit okay so I think it's posted successfully if you posted successfully then you can get access it's so how you can just do it let's define another route and here we can add comments so the comments will be get card item card item by ID okay something like this and if we want to get then it would be get method so that's why get method and here we'll have to define a path so the path will be obviously card something item then we will Define the ID so this is the ID after then we will have to Define comma then we will have sing functions then uh request and response after then inside this actually if you just have this type of uh uh clone and then something here you can just simply uh get it from param so that's why we will Define const ID equal require request. params do ID this same name will be keep there in here okay so after then what you have to do you can just uh also require informations from the body how you can just do it Con email then here that would be require body. email we'll get the informations from the body then we'll have a query so let me const and here query equals then we will query based on the three things actually we will query based on the class ID so that would be class ID that we Define let me check it this class ID or something like this uh then that will be this ID the above ID then we will have something like user email user mail so that would be the email you can see here we will have an email field so in instructor email actually it should be email field next time we will just fix it so that would be email field okay it's actually the user email I did a mistake if you want you can just fix it that would be email okay then is there anything okay so if you just try to send another one and that would be okay okay this is now posted again let me check it refresh this okay this uh second one is perfect we can just remove it the first one we can just remove the first one okay let me delete the first information is gone and here we can just do a little customization instead of instructor email we can just simply Define email here okay so that would be perfect after then what you have to do uh this is done after here we'll have to define a projection so con projection project and that would be will filter based on class ID so where is actually this is the class ID and we'll Define the value will be one after then the final one is we have to defend const results equal a wa then card collections then we will Define find on method find on methods so here at the beginning we will have query we'll have query here so instead of comma here we will have a column so this is query then we will pass the projection the projections we can just let me just uh check if the spelling is correct so here is find on find on documents and if you scroll a little bit this is actually projections you can just copy this way okay let me correct it I can mistake so that's why I'm just copying it and here inside these actually the value will be uh class ID class ID that would be one okay and finally inside here inside this Carly Braes we will have projection if you check here actually this is options we're patching options and instead of actually we'll have to pass the projection so the projection clone projection something like this so finally we have to post it so let's post it so response. send and we'll pass the results okay so if you hit this actually let me try to get hit here so we can just have this copy we can just copy everything from here and here instead of this we can paste it let me choose the ID so here we have to copy the ID from uh let me copy this ID and then we'll just send the ID here then we'll have to Define post request sorry get request and if we just hit the send uh and it will occur we have to check it actually let me remove all of this stuff it sends the error we have to cons uh check the error what actually happens so here projection is not defined actually uh the error is here actually projection is not defined so why actually it's not defined it should be defined uh we have to pass this from here oh actually the quod is projection equal projection this is not getting okay so let me check the documentations here how it passed you will have a options you can see this is options inside this options we have this way and we'll pass this options so okay so can we do this will projection and pass the projection here okay let me try again send it it's still an error let me check is actually not working okay so how you have to fix it let me check so from here this is projection oh I forget to Define const here then we'll Define it equal actually then I think here it will work so we'll Define CES projection projections equal this projections so that was my mistake I'm sorry for that okay right now server is running then if you hit send then it's actually return nothing can see it's actually return nothing but I think everything is fine right now I think everything is working so as the class IDE is one that's why maybe it's not showing but I think everything is fine we'll check it whenever we send thata okay so I think it's okay right now next move to the uh how we can get information by ID so card information info by user ID user email actually okay so that is the thing we'll have to do same thing app.get then here will have card then we will just filter based on email then we will have I think functions we have request and response f inside here we'll have to receive email and that would be from request do params do email the same name here then we'll have a query so const query equals we'll have user email user mail and that would be email after then we will just Define the same thing const then projection that would be class ID do one so let me check if we Define class ID actually it's class ID so perfectly defined so here we'll have a equal sign after then after this projections we'll Define const uh cards equal who will Define yeah weight and then we will have card collections then we'll Define find operations so we'll find wall so that's why here we will pass query first and then we'll have to pass the projection projection equals the projection from the above and then after the is actually what you have to do here we will just Define conos class I this here let me do a little Corrections uh Corrections here and then here actually we'll have equal sign we'll just map this card cards. map and then we will get every time we will get a card then we will have to Define Arrow here then what we will do we can just call new actually new keyword new then we will have object ID then inside this object ID we will have card do class ID you can see here there is a class ID we'll pass this class ID here finally we will have to close it after then we'll have second query so that would be query 2 then it would be equal and here we'll just do it by underscore ID and then we'll have in methods actually we will have in keyword so in will be class IDs okay something like this and finally we'll have to Define KOST result and that would be your weight then class collections so here actually card collections and here actually class collections we combined card and class collections then we have to Define find options and here we'll have query 2 then we'll convert it to array so that would to array we'll have to convert this and then finally we will just send a response something like this okay so right now any items is not on the card so that's we can check it but uh if when we have cart items for example so when you have a items selected on the card uh it's actually not showing why maybe uh server is not running let me check it render dashboard is the server is running or not I have to check give me a time so this is the server let me go there service is running here classes it's is running but okay it's is loaded after then okay I think it's fine right now my server is running and you can see uh you can see the details and if anyone just hit the uh card informations if any items is added to the card for example here if uh anyone just hit this select button it is select button then it will just call the add to card and it will add it to the card items okay so that's it when you have add to card then you can check it otherwise it's not possible to check right now okay but this API is fine after then we'll just delete a card item so delete card item okay so for this actually we'll have app. delete method then inside here we will just Define a path so that would be delete card item or something like this and then we'll just based on an ID specific items we will delete from a specific items and here we will have async then AO craes and after then inside this CIS we'll just get the ID from the request do params do ID after then we will have a query so con query equal will just uh do query on class class ID that would be ID and finally we will Define const results equal we have wait then card collections dot delete one and here we'll pass this query and after then we will Define response so sry okay here raise. sense okay you can test it by this way for example here uh we'll have only one ID let me insert another informations here so right now here is one informations and let me just insert another information so here uh we can just back this and we'll hit the part so the part will be this part we will insert in our C item so that we can delete it so here is the path let me Define it it would be post methods and here we'll have maybe second one and the class ID will be something like this okay if you just hit this sent then it's acknowledged through and right now here if you refresh then you will see we will have two informations and we would like to delete uh the first the second one actually we would like to delete this so that's why how you can just do it you will have to define a route so that would be Local Host and instead of add to card we will have to go to a specific ID for uh a specific route for this here is the route delete card item will paste it here then instead of this ID we'll call the specific ID we want to delete the second one so this is the ID let me paste it here and here the method is delete method and if you send then acknowledge true that means deleted successful and if you refresh your database right now so card items is not deleted let me check oh actually not deleted it says acknowledge true everything is fine I did it let me try to send it AAL true deleted count uh isn't it's working Let me refresh it so I actually not deleting okay two items and let me check the delete method so where is the delete so this is delete operation delete items and here we'll have a query then have to Define delete on methods and we'll pass the query okay so why actually it's not working KOST it will receive from the ID par ID then here we have this is the ID we're setting on class ID so let me check here is the class ID okay we can just check it by this actually we can just try with this let me check and and here if we send then deleted can count one so right now it's actually deleted uh we are trying to do it with underscore ID so that's why it's actually not working but whenever I just trying to the class ID then it's actually working okay fine so if this working then the next one is we have to define the payment route so here we can just Define payments route okay so here you can see the payments route will have this type of informations so this is actually this way we'll have a payments Collections and here we'll just uh keep a stores these informations okay so that is my Target right now and for this actually we'll have to implement the stripe so to do this so that's why we must uh uh create a account on stripe first then we can implement this okay let's do that so for this from here we can just search stripe.com then you have to sign in to this here uh it's actually taking a little time to create the accounts and here uh we can just add a new account so let me add a new accounts and uh here instead of the accounts name what you will Define it's a your G master so that's why will define something like this and let me create accounts from here in front of you so that you can understand the whole process we're creating a new business setup you can see this is now the uh business name and in this business name we don't need actually to uh really build it so to to really do business with uh it you have to set up more steps you have to set up uh complete all of these you have to complete payments balance and billing obviously and you can just do this explore here and you have to provide some informations uh and then continue you will have to provide some informations uh you have to verify your business add bank account secure your account add extra and complete if you complete all of this process then your account will be activate and you can really get order and get paid but uh as it's a test accounts we don't complete this actually we'll we don't have all of this information right now but if you have business informations bank account number and security accounts and some extra informations you can completely set up your STP accounts and you can get paid actually but we would like to do it with a test accounts so that's why let me leave it and from here actually we don't um need that information actually from the HomeBase is we will hit this API keys for developer and here you can see you will have a publisher Secret by default but uh we will work in a back end so that's why we will have to back end key but before that let me uh go to the documentation so that you can understand a little bit here stripe.com and from here so let me go to the documentation so this is get started let me pre-build okay uh actually let me go to the documentations from here actually how you can just work with uh this is actually get started so here you have the basic stuff so we have to set up you can read this documentations if you have any issues so first one is account setup we have did uh we have already done that then we have the Second Step so that is actually uh you can just click this Qui start then here you can see uh this is actually uh you can just Define from here this is you will Define it JavaScript then on front end we are going to use react then on back end we will use nodejs so that is nodejs so here you can see this is server.js and this is actually the index.js file actually this is actually server.js and we have defined the name that is index.js so that's why this actually need at the beginning you can see uh you have to require is drive so we uh don't have set up is stri first so let's set up stri first this is the command we'll copy this command and then open the terminal and this is uh one terminal running and we will work with second terminal so let me go to the back ends first so we are now inside back end let me clear all of this stuff okay and here npm installs D.P so we're installing strip first okay it's done then you can follow the tutorials at first you have to uh install it then you have to create a payment uh intent actually so whenever you just hover you can see the Mark is here how you can do it you have to do this way actually you have to Def find this you can just copy this first and you can just paste at the top of the screen so maybe we can just uh paste it here after this requir body we can just paste it here okay so it's actually saved uh we will call the stpe and import it from stpe and here is a publisher key we will have to change this key so how to uh change this key here in in this dot uh EnV file we will Define another folder so that is actually payment we'll rename it actually payment intent or secret you can just uh Define it anything secret something like this and we'll collect this secret so here you can see inside this developers key API key options here is the secret you have to reveal this so click here then you will get this you can just simply click here to copy and will paste it inside here so this is actually our secret key you can just check this secret key and we can use this instead of this hardcoded data so here how we can uh use it we can remove all of this and here we'll Define process dotv dot these actually these payment secret okay so this is actually done and if you have done this then you almost uh stripe setup is done then next step how what you have to do so let me just show you at first we have installed then we have set up our key then here you can see we will have a payment intent you have to create a payment intent by this way so this is payment intent and we'll have to create this way we'll have to create a post request and then we'll have to do on this route actually so let's do this so for this actually for where we can just do it if you scroll a little bit here we're implementing all our payments route so we'll have to let me copy it it's a payment intent or something like this you can simply copy the whole stuff from here app do Post will have to post something like this and inside here the path will be payment intent create payment intent okay here require a quotation mark after then we will have Asing a same way actually asking award and request response so let me Define it and here calias inside here you have to create this way actually if you uh you will just con will get items from the body something like this you can just copy this and here actually if you check the data uh we will get an amount so that is actually a price so we'll Define that would be our pricing in state of items we can Define that would be price Okay so then we'll Define conos amount and that would be let me check the amount will be you will have to call a functions this function is actually above actually these functions it will receive an items and then returned using these way so that's why here we'll Define amount so the amount will be called par integer and here we will pass the price and then we will multiply it in hundreds so why actually uh uh stripe will use actually in uh decimal points in actually these formats uh if you have $5 that means you will have this way you have to calculate it by this this is means five5 uh dollar actually so that's the way so that's why we will multiply it okay so you can see if you want to just check it here it will just get that information here okay so after doing this the next option is we'll have to create a payment intent the payment intent is here so look this is actually a uh create a payment intent so to with the order amount and currency so that's why here we will Define the this way let me copy let me paste it here we will have to call it and inside this actually is we installed okay so inside this we'll have a CIS and then you can see uh we will pass some objects item so here first one is amount so the amount will be our above amounts here we defined an amount so we'll pass this amount after then you can see here the currencies that would be USD that would be USD format after then we'll have payment types so it's actually using automatic payments method but we will Implement card payments so that's why we will just uh just search card payments okay so here is actually the thing that we are just uh ing so that would be also payment method types and that would be this we have to copy this and we will paste it here actually uh this way and we don't need to Define quotations here sorry and we'll have these actually we don't need link uh Define the linking page and that would be we enable cards from here actually so that would be payments method type and that would be card actually we are implementing card functionality so that's why this one and if you have this then finally what you have to do raise do send you can see so where is the thing actually here you can see it's actually have to send that so raise. send and then you have to do client secret you can just copy this simply this and you can just paste it here so our payment intent is cre so it's very important to create the payment intent so if you have then the tax is done next is we can just set up another routes so here we'll have to set up uh post payment information we'll have to save some informations to the database so that's why here we will create post payment info to DB Okay so here that would be ab. poost and here we'll Define the route will be payment information that would be a sync uh request and response then we'll have Arrow here then double quotations and here we'll have to code the uh parenthesis inside here actually will have a little Tex what you have to do uh we will get the payment information from the board so that would be payment informations so payment info we'll just get it from the request body let me format this code and here after this we'll Define class ID so KOST classes ID so that would be payment info Dot classes ID classes ID something like this after then we will get the user email so const user mail or user email that would be payment info do user email after then we'll have conos single class ID that would be require do query do class ID and finally we will Define late query and here we'll actually do some conditions we'll check if then we'll take single class ID single class ID then we we will have to write a condition so the condition will be query equal uh class ID class ID will be single class ID then that would be user mail user mail will be user email something like this okay then after this if condition we'll have Els then we'll have something we have query and this type of thing we'll have a in methods and that would be class ID and we don't need user email instead of this actually we'll have this okay so finally finally what you have to do we'll have to Define conos classes query and that would be parenthesis is and here we'll have underscore ID equal we will have dollar sign in and that would be sign in then we will have class ID sorry classes ID classes ID do map here we'll get ID that would be something like this so new object ID and here we will pass the ID something like this okay after this what you have to do we'll have to Define KOST classes and then we will have to Define new enrollment data so KOST new enrollment rolled data so that would be something like like this here we'll have user email user uh user mail equal uh here email equal user email then we'll have class ID equal class ID dot map and here that would be object ID something like this after then we will have we don't have classes actually we will have transaction trans action transaction ID and here we will Define payment info dot transaction ID something like this and after doing having this actually we will have to update documents so that would be const update dated Doc and that would be a seter functions craes we'll have total enrollment total enrolled and then we'll have to map classes do reduce then here we'll have total and then current if you are not aware of the reduce method then I should request you to please try a and try to understand this so that would be total plus current dot total enrollment then we'll have a zero so the initial value will be zero and finally We'll add + one or we will Define optional 01 Okay so so this is the first one then we'll have available seats you can see available seats so that would be same thing classes do reduce here that would be total and currents then we'll have a arrow so we'll Define sorry uh we'll Define total then plus current dot available seats then we'll Define a minus here so that would be minus and finally okay something like this class. let me check everything is is fine total currents availabil 0 minus one okay so it's fine and finally we'll have to update some documents so that's why here we will Define KOST updated results so that would be have wa do class collections so that would be class collections Dot update to manyu and here we'll pass class queries classes query then we'll pass updated doc then we'll pass upsert true upsert true or something like this the first one is done okay then we will have the another one so that would be enroll treasure so con enrolled enrolled results the enrolled result will be a wait then here we'll have enrolled collections then we'll Define insert one and we'll pass new interal data something like this after then we'll have uh deleted count so conos deleted results something like this will have deleted result and here we'll have air wait the in state of this we will call the card collection so card collections and then we'll just do delete menu delete menu then we'll have query okay and finally we'll have payment result so conos payment results and that would be a wa. payment collection payment collections dot insert one then we'll pass payment info so if everything fine then what have to do you have to finally send the response so that would be press do send send now we'll pass multiple value so that's why we'll Define Carly bres so we will pass based on the objects and here we will have payment result first then we will pass deleted results then we'll pass uh enroll results then we will pass updated results all of this we will pass all of this thing inside here actually so this is done next or the next we will have an another route so that would be for payment history history so get payment history we can just rename it and here we'll have to Define another Ro so that would be app. gate here there will be payment history that would be email and cbris and single quotation something like this okay inside here we'll have to Define const email equal require do params params do email then we'll have query so query will be user email so that would be email then we'll result we'll call the find method and we'll convert it to array but before that we can sort it so how we can just sort it we have to Define sort and here will pass by date so date will be minus one okay and finally we will just send a result so this is done after then we'll have another outs so we'll check the length payment length so let me Define payment history length history length Okay so that would be app do gate and here we'll Define payment history length by emails and that would be something like this we'll do the same thing we'll just reord the get uh emails from the params then we'll have user email equal email then we'll have payment collections then we will Define instead of these actually we will Define payments collections then count documents and we'll pass the query uh we don't need actually to short it so something like this is okay and finally we'll Define results so that would be in instead of this we can just def and total and the total will pass it inside a object so that would be total something like this okay so it's fine we have the payment RS done so you can see we will have all of these payment rounds so let me close all of this stuff so if payment routes done then the next option is we will have to Define uh we have us actually some less uh uh routes actually we can do it very soon so that would be enrolled enrollment routes okay so on the enrollment routes we will have at the beginning we will have app. gate methods and here we will have something like popular pop classes popular underscore classes okay so here we'll have Asing a Carly bres and inside here we will Define const result the result will be a wait then we'll have class collections collections do find method then here we'll have to sort it so let me sort method and here we'll have a object so we'll Define total enrolled and that will be Min - one and then we will just Define a limit so if you define limit you can just use slice method to uh reduce the how many uh data you will show but limit is very efficient so it will reduce your API call uh cost actually then we will Define to array okay something like this and finally we'll just send it okay so then after then we'll have popular instructors so app.get methods and here we'll have SL poo popular underscore sorry popular inos track chour so here we'll have as sync then request response and something like this and it's very important actually we to create a pipeline actually here actually the pipeline is what actually pipeline is if you want to just make a combined if you want to uh group some uh Collections and make some results from here so that is actually the pipeline so let me Define conos you can just search it on the database if you just check uh here actually pipeline so search it something like this Let Me Wait so save a pipeline aggregated actually we're working with create an aggregated pipeline we have to create a aggregated pipeline so this is the process actually so it's actually let me check the code okay so this is way we can calculate pipelines and do uh explore you can explore these issues but right now we can just Define it here pipe line and here it would be an object inside this objects we will have uh a group so that's I will use the group keyword if you want to group to uh to database so here you can use the group keyword and we will Define will group based on the ID and the ID will be uh using here that would be dollar sign then we'll have instructor inos trctor email we'll combined this group based on in trctor email and total enrolled so that would be something like this we will Define a calibr and we will Define Su this is a method obviously and that would be total enroll something like this okay so this is the one thing after this actually we'll Define look up so we'll search on this database so that's why we was lookup keyword and that would be dollar sign lookup so here we'll have cbris so this is lookup and we'll Define form so the form will be our users then we will have local field so that would be underscore ID for infield will be email here we'll keep email and then s will be in trctor inos trctor okay something like this after then we'll have a project so let me Define dollar sign that would be projects and the ID will be zero then here why actually it's a ER let me check it we'll have something like this here we'll Define projects column then we'll have craes and inside this craes we we'll have unders so that would be zero then we'll have in structor inos tractor so where is the inos tractor this inos tractor actually here let me copy this one and paste it here so that would be col bres and here we'll have to use array elements so that would be array elements and that would be in know structor and zero and finally after this we'll have total enrollment that would be one after this we'll have a comma and then we will just Define short method so that would be short total enrollment minus one and after then we'll have so that would be limit six okay and finally after this after this finally what we will do we Define con result so the result will be here wait then we will call the class Collections and here we will Define aggregated Aggregate and we'll pass the pipeline from the hab of so we'll create a pipeline we'll copy the pipeline and paste it here and finally we will convert it to array okay finally we'll have to send it so R do send will send the results so that's it the thing uh I think uh it's done right now and let me close after this stop we'll have to create uh admin starts so that would be create admin starts okay so we'll have app do gate methods so here we'll have slash admin starts and here we'll have asking AIT so request response inside here we'll do some uh think so here at the beginning we'll have to check KOST a AR approved classes so that would be yeah wait then we'll have class collection so class collections then we will Define find okay inside here we'll have a status the status will be approved and finally we'll convert it to array and then will map uh we will Define the length so that we can just check the length Okay so here is a little mistake so let me GTS okay okay I think it's fine then we'll have to Define painting classes so KOST painting classes will have class collections then the status will be painting and everything is fine so after then we'll have conos inos tractor and that would be yeah wait then we'll have users collection then we'll Define find and we'll just check here we'll have rule so cbris role will be inos trctor then we'll just defin array then we'll Define length so we can remove this air wa after then after this instructor we'll have total classes so conos total classes that would be aw then we'll have class collections then we'll Define find then we don't just filter it and at the end we will have uh two array then we'll have length something like this and after then we'll have total enrolled so that would be a then we'll have enrolled collection enrolled collections then we will find to array and something like this and when everything is done we will create a variable so that would be results and here we will create an object so as we have many things so that would be create an object and finally we'll just send it so rest dot send then we'll send the results so it's done and after this we'll have H so this routes is done now we can just create other routes so that is actually instructor routes we have to create another rout so that would be get all instructor okay so here we'll have app.get then here we'll have instructors Asing a and here rule will be uh user collections here rule will be structor and we will convert it to array and finally we'll set it so after this we'll have app do gate then we'll have slash INR classes then we'll have based on email after then we'll have Asing white response and inside here this is actually will a check if anyone enrolled in a class so that will be something like this at first we'll have conos email equal body we just Define this from params actually as body after then we will have query so that would be query equal to user email email so after then we will have to create another pipeline so that would be Pipeline and and we will have equal and objects inside this objects we will have two Mass so that would be match the match will be on this query we'll try to match it after then we'll have to Define lookup so the lookup will be dollar sign look up then here we'll have to Define all of this stuff so here we'll just find look up from classes and the local field will be classes ID then for field will be underscore ID and then we'll have classes okay all of this stuff after then we'll Define another comma uh and here we'll have something like this we'll have unwind then we'll have classes something like this and finally we'll have another look up we'll have we'll have from uh we have all of this field so let me paste it here so from will be here will be users then here will be classes dot instructor email so let me check you structor email then here we'll have present field so that would be email and S we will have instructor okay and after this failed actually we'll have projects so let me Define dollar sign project so here here we'll have craes then we'll have underscore ID so that would be zero instructor will be class will be on and instructor will be ar image so that would be something like this and finally after this actually what we do we Define const result so that would be a wa and here enrolled collections then we will Define aggregated and we'll pass the pipeline then we'll convert it to array okay and finally race do send will send the results okay after then we will have to define a route for applied for instructor so when someone hit this app applied uh for instructor will have have have to post as request so that would be fb. post and here we will Define as inos tractor we'll have Asing request response inside here what we will do we'll def KOST data equal we'll get request do body after then we will Define conos result equal we'll have air we then we'll have applied collections then we will have insert one and then we'll just Define the data inside here and finally we will send it raise. send and after then we will have app. G so this is uh which users can appli so that will be applied inos trctor so that would be something like this and here we'll just Define const and we'll get it by email so that's why we'll have colon email we'll have email equal request Quest do params do email after then we'll Define conos result and that would be a wait then we'll call the applied Collections and here we'll have to Define find one and we will pass the email s a parameter so email will be email something like this okay and then finally we'll have is do send and it will send the results so we have almost done actually uh I think almost done let me go above and actually we have everything is done and right now we have to create the users collection when someone login or register to your accounts you have to create a routes for that so that when someone uh create an accounts or just get an users so to be an users we will have to do something so that's why we will create a routes for the users new users and other system so okay so for this actually we can do that here so so routes for users okay so at the beginning we can create a new user so that would be app. poost and here we'll have call new user we'll have asnc request response and if you understand is actually very simple we have conos new users we'll be get it on requir body then we'll just uh just insert one on the new users and that would be will sent so this is done it's actually we did it uh many times then what you have to do we have to get the user so that would be app.get we will hit this users route and here we will have users and that would be we don't filter it so that's why here actually users collections will don't pass anything and we'll get the users okay and we'll get by ID so that would be app.get and here we'll get users by ID so this is the route and inside this route I'm just doing a faster way so that actually I already taking lot of time so that's why I am just uh doing it fast I hope you understand the fundamentals so require. params do ID then we will have const query call new object ID then we'll pass the query inside here find on so actually we'll have to Define we need to change it so we'll just Define find one and inside this find one we'll pass the query okay and then we'll just uh send the response then we will get user by email so app.get then get user slash user by email here we will have as sync a wa let me do it again app.get then we will have a route so that would be user then we'll have email then we'll we have Asing AIT and that's why inside here we'll have conos email pram email so we'll pass the email as a parameters and finally we'll Define this way so and finally we'll have to delete an users so that we will have to app. delete so this is delete method and here we'll just uh Delete users by based on the delete user and that would be Asing a simply uh we will just delete by ID so here we'll have a ID then we'll Define const ID will receive from the parents then will be a query so con query will beore ID equal ID and then we'll have to delete one and finally we will have to define the results and lastly we will have an app do boot method so app do boot method so that would be update users by this way and finally we'll have something like this so it's actually update Route and at first we'll just receive um const ID will be request dot params do ID then we will get const updated user equal we'll get it on request. body after then we'll Define const filter equal we can just filter based on underscore ID object ID then we'll Define options that would be upsert through then we'll have conos updated do so that would be and inside this doc we'll have a seter functions so seter methods here we'll have name equal updated users dot name we will have email value then we'll have rule updated users rule then we will have actually it will be option after then we'll have address can see actually when we are just checking the demo data so why is actually user data so here that would be address that would be update users address then we'll have um let me check uh we can have abot actually abot so that would be abot then we have phone number photo uh photo URL so here maybe we can can keep the users photo URL D store so this is actually photo URL then here updated user photo URL and finally uh we can just have skills and updated users skill if you have any skills otherwise we'll Define it's null okay I think it's okay so far finally after having this what you will do const result that would be equal air wa then we'll call users collection then we will Define update one then we will have to pass the filter then update blocks then options and finally we'll send it okay okay so all of this done and now we will have to Define uh JW token authentications and uh actually we will have to add admin verifications and um instructor verifications okay so right now we'll Implement JWT token authentication so that's why JWT so Jon web token so we'll go to JWT doio and here you can see uh let me go to libraries and here you can see many libraries is there let me choose the node so where is node you can just search by this node js okay this is actually nodejs you can choose any of this or you can simply search this way actually you can simply search uh JWT token and then you can just explore these uh npm packages and here you can simply get the code we will copy this and then we will open the terminal and again we will paste it here install it and then how you can use it you can see you have to create a you have to require it so at the beginning we will require it so let me require it so how we can do it at the beginning here actually or here different con J WT then we will just require and here that would be let me check this web token okay so that is fine so if you have then we'll write a verify code so here we can just after this we can just Define so verify tokens or set tokens set token or something and here we'll Define a variable so that would be verify JWT okay but before that let me set uh let me set up actually we'll have to set up jwd token first so at first you have to generate a token this way or you can just generate uh you can choose any of these actually okay uh let me generate a token first so to generate a token firstly we'll have to generate a token then we can just verify it so how we can just generate a token here you can see we are writing all the users route and here we'll Define a post request will request post and here we'll Define uh something like we'll Define when you uh hit this URL so that would be set token at first you have to generate a token so that's why it's the route set token and that would be asking request response and here what you have to we'll have to Define const user equal require do body then we'll have to generate token so here the process is that you can see uh JWT do sign that means you will use this format actually so let me use this format okay we can just Define it a token and here we'll have to paste it and instead of all of these way we can simply do this way actually at First we will Define the user and then we'll have to uh Define a exess token so we'll have to define a excess token how you can just generate excess token so for this you can just generate a token so the way is let me not random bits you can search crypto random bits and you can use this actually require crypto random Bits And if you run on the terminal first you have to commment note then you can just do this then you will get a unique token so this is actually secret and you can define a secret here at the end you can just Define access ACC access secret secret so that would be something like this we'll paste the code here and we can just copy this and here whenever we're using here we can just Define the secret will be process Dov do access token and then we can add the expirations when the token will expire if you check here the this actually sets the algorithm and here if you check the backend J WT token expire after 30 seconds so that will be the process you can use this actually simply by this way here you can just Define a method so that would be expires in and here you can just Define the two token will expire after 24 hours okay after one day the token will be expired and simply finally we will Define raise dot send and finally we'll pass this token okay so let's check if it's working when someone hit this API so let's try to do it here create a new API uh the first one will be Local Host 5,000 then this route API set token and we will do a post request and inside this body we can just pass some users data so for example we can just pass a username user name and that would be maybe the username will be Mamon and maybe we can pass another information so that would be maybe a or something like this you don't need uh you don't pass any sensitive information like password here because it's exract trable and is will be 20 uh 25 or something like okay so if you just hit this route then it will generate a token for you so let's hit then you can see here token is generated and you can check this token if you copy this and go to the JWT token so let me go to the website JWT token so this is token uh this is official websites and here uh if you want to decode if you paste your code here you can see uh this is name this is the information that we just uh sent from the body if we send any information here you can see this is actually the thing we will get the username age and others informations from here and I say you don't need to Define any information secret informations here actually so it's very important I would request you don't to set any sensitive information there okay so we have generate a token so now we can just move to the first one we'll verify the token so that's say the verify token okay so how you can just verify token if you have a token you must have to verify the token so that's why will Define conos verify J WT and here we'll have the three things we'll have a arror functions let me do it and inside here we'll have first request then response then then next so how to verify actually to verify this let me check if you scroll a little a little bit then here you can see we will have to defend do do sign method actually so this is actually the way to verify you can see verify actually using token so here is the process let me Define it so at the beginning we'll check conos authorization and here we'll get the authorization from the header when you send these actually token from here it's actually uh store on the headers so that's why we will get it from require do Heathers do authorizations after then we will have check if the authorizations token is not there what you have to do you have to Define you have to return a status so the status code will be 4001 and then we'll send error the error is uh the error will be let me just do this here inside this we can just Define a message the message will be invalid authentication so okay something like this or unauthorized token you can just Define any of this invalid authentications okay so after then we'll Define KOST we'll just get the token the token will have to do authorization this authorization we'll check we'll have to split it so that's why split actually BR tokens come with a br key so that's why we'll have to split it first split it and here we'll split based on uh you can see actually here so this is actually if you go headers authorizations and check maybe we'll just do that a little bit later but for now let me Define a space here and after then we will start the uh index number one I will show you a little bit later wait a minute and then we'll have to verify it so that's why JWT do verify and here we'll pass at the beginning we'll pass the token then we will pass the secret so that would be process do EnV do access secret then here will pass a function so here that would be anonymous functions and here we'll get an error and a decode you can just check that from here actually look you will get a payload that is decoded uh actually we're following this error decoded we'll have this decoded and if you get this decoded you can check if any error happens you can just Define a return a status similar status is here uh the code is will be 300 uh sorry 43 and here we'll Define for V access if the token is expired or something like we can just Define for B1 exess I'm just showing you actually the think wait a minute and then otherwise we'll decod it it and finally we'll call the next okay so how it actually working for example right now here uh this is an API for example if you just hit this classes and uh get the post request and send the token you can see you are getting all the results all the results but what if if you apply this zwt token on this here actually what is the classes route okay so this is actually classes out and inside here we'll Define the JWT verifications here and if you do this right now uh if you try to go to the classes section so Local Host here we'll go try to get classes then you can see invalid tokens anyone cannot access this without the token so you can see right the results so if you also check try to check it you can see unauthorized token that means without token anyone can be accessed okay how this will work so here we can generate a token let me generated token here and we will have to keep this token here we will have to keep this token on the authorizations here we'll choose BR token and we'll pass this token here if you do this and now hit then you can see you are getting all the results here without this token actually you cannot access the uh route so that's why it's one step securing so you can do use it and let me we don't use it actually here we'll use uh others places but where we can just use it we can just uh Define it on a another place so actually we can use it on users block so here is an user email and we can apply this token here and another thing we can just uh apply it from here and we will have others option but right now it's okay and now we'll do another medware so that we can just work with so we'll create some Mewes here so that we can verify uh either admin is uh try to delete users or just uh a instructor is there so we'll create two middleware here meder for admin and um uh instructor trctor only instructor can post the course and admin can approve so that's why we need two middleware so let's generate this two middleware for now and that will be the complete thing when we have done we can just use that middleware and everything will be uh complete our server will be ready for it okay so for now KOST we'll have at the beginning we'll have verify admin and here we'll have the same thing so in medal actually we will pass three value first one will be request then will be response then will be next so keep remember that when you are just defining a midle you will have to pass three uh things here okay so at the beginning what we will do we'll Define KOST email and that would be we'll get it from the require will decode it so decode email then we'll have conos query the query will be emails equal email then we'll have user and we'll Define here with then we'll have users collections then we'll just find one then we'll pass the query here here so we'll actually search a user based on this and here we'll have to Define as sync so we'll search a user first then we will try to MCH the the rule actually so that's why we will try to MCH firstly we will just get an user then we will try to MCH user. Rule Rule and we'll check if uh the rule is admin then we'll Define we'll call the next inside here otherwise we'll Define heels so here heels will be we just return a status that would be 4001 and we'll Define forbidden okay so that's it and this mle wire is there and then we'll Define another mle wire so the mle wire is for conos verify inra the same thing and inside here we will do the same thing first we'll just try to to const email decoded email then actually we'll require the email we'll find on the users collections then we'll check if the rule is instructor then we'll just call the next otherwise we'll Define unauthorized access on author rized access and actually the meaningful thing is that you can just Define unauthorized access so everything is fine and now we'll have to use so for example uh the users only here we use this actually on users we have use here where we actually use we can use for example only updated uh here we can use a mle so at first we will verify JWT so verify token to delete an users and only uh admin can use admin can just delete user so that's why we will call verify admin and then sorry we are actually using on the post we don't need to do that we will do inside it only here actually uh to delete an user at first you have to verify token then you have to verify uh if you admin so that would be verify admin so the first one is this one then here we use JWT token then we'll go to update users based on ID here we'll have to Define at first we'll Define VAR JWT token then we will Define verify admin okay then on the new classes we don't have to uh okay only uh who can uh create new classes actually the person only uh instructor can create new user so that new classes so that's why we call verify instructor actually look uh using this method we actually post a new class the class will post the instructor will post the class so that's why we will check the instructor verifications after then we'll have class emails so only class emails will be get by verify JWT token and verify instructor it's very simple actually then man classes don't requir change a status who can actually change the uh class status so at first admin only can change so that's why verify admin so the route will be verify admin and then who can approved classes who can see actually approved classes anyone can see approved classes then we will have updated classes and here we'll use verify zwt and then we'll have to use verify instructor can update a class then uh who can add to card actually registered user so that's why verify jwg token here then who can just see the items card items so only verify user so that's a JWT token here after then who can check the email verify users can check the email who can delete a cur item so this is cardr item only verified users so we'll Define verify users here and who can do payment informations so that would be obviously verify zwt tokens who can check the administers so uh only admin can check the admin starts so that's here we'll have verify JWT then we'll have verify admin and then uh in instructor we don't need to use here we'll have enrolled in instructor here we can just verify a uh sorry actually enrolled course so here we can just check a verifications that would be verify JWT and then we'll have as instructor we don't need to check okay I think everything is fine we have already done this so that is our actual database with JWT token Authentication