How To Create Full Stack Text to Image Generator AI SaaS App Using React JS | MERN Project
FULL TRANSCRIPT
hello and welcome to another exciting
tutorial of great stack in today's video
we are going to build a full stack image
generator AI SAS application using
mongod DB Express react and nodejs so
let's see the project overview that we
are going to create in this tutorial so
this is the homepage where you can see
we have added the navigation bar with
logo and this login button then we have
these text and you can see these
contents are animated here we have this
button to generate the image using the
text prompt if I scroll down here we
have some steps to generate the image
then we have the description and then we
have the customer
testimonials after that we have another
button to generate the image and then we
have this footer so this is the homepage
and if I click here it will open the
price plan page so that user can buy
credits to generate the image after that
here we have the login button so let me
click on this login button so here we
have the option to login on this
application or we can use this sign up
link to open the signup form and user
can create an account on this
application so I already have an account
so I'll click here on login so I have
added the email ID and password and
click on the login button now we are
logged in let me go to
homepage so in this navigation bar you
can see it is displaying my name also hi
Greatest Tag then we have this user icon
and we have the logout button and here
in this navigation bar you can see the
credits left so right now two credits
are left so whenever you will create a
new account you will get five credits so
I have already used this credits to
generate the image so to generate the
image just click on this button
so it will open this page and here we
have the input field and in this input
field you can add any text to generate
the image using the text so in this one
let me add one prompt I will type a 3D
render of a small chibi style tiger in
forest and click on this generate button
so you can see the loading text here and
after completing this loading you will
see a AI generated image so now you can
see the image has been generated we can
also download this image using this
button so let me click here so this
image has been downloaded so our image
has been downloaded that we have
generated using text prompt now let me
generate another image so I'll click on
this button generate another and here
let me add the another prompt
so let me add 3D render of a small chv
style tiger in snow and click on this
generate button now our image has been
generated a tiger in snow and right now
you can see our credit is zero if I try
to create another image let's click on
this button generate another and here if
I type wolf in snow click on generate
button you can see we are getting the
notification no credit back balance and
we are rected to the payment page so now
we can buy more credits to generate more
images so let me choose any of this plan
so let's select the first one it will
give 100 credits we'll click on this
button and here we have added the
reserve pay payment gway so it is
opening this payment page and here we
have to add the card number so let me
add the card number and other details
now we have made the payment
successfully and after making the
payment you can see here we have the
notification createit added and in this
S Bar you can see the credit left 100 so
we have purchased the 100 credit now
again we can generate the image so let's
click on this generate button and here
we will add new prompt so let's add a 3D
tender of a small chibi style wolf in
snow click on generate button and you
can see the text
loading now you can see our image has
been generated so we will create this
full stack text to image generator AI
SAS application using mongod DB Express
react and nodejs step by step but before
we dive in I would like to thank our
video sponsor codex codx enables you to
build and deploy your react application
visually with just a few clicks with
codu you can create a complete react
application from a scratch or import an
existing react project you can also
start with beautiful pre-built templates
provided by codu that comes with many
reusable components making it easy to
build complex UI in less time it
provides visual tools to design Pages
create components and as style them
easily codu also integrates smoothly
with Wix headless services like its
e-commerce service powering over a
million online stores or any other
custom backend service that allows you
to build a fully functional react
application without hassle you can open
and edit code files in your favorite IDE
such as VSS code while previewing
changes in codu in real time plus you
can connect your project to GitHub to
collaborate seamlessly with other
developers to get started with codex
click the link in the description below
now let's start to create our text to
image generator project for that let's
come to desktop screen and here I will
create a folder so let's create a new
folder and I'll write the folder name
imagify that is our project
name now let me open this folder with vs
code editor so right click select open
with
code now our project folder is open in
vs code which is
imagify in this folder we have to create
two folders that will be for front end
and back end so first we will create the
front end so in this one let's create a
new folder and write the folder name
client where we will create the front
end application
now right click on this client folder
and select open in integrated
terminal so you can see in this terminal
we are in the imagify and client folder
now in this client folder we have to
create the react project using wheat
package so just
add npm create wheat at
latest so we have added npm create we at
latest press
enter so it will create a react project
here it is asking for the project name
so just add dot so it will create the
project with the name client press
enter here we will select
react then select
JavaScript after that we have to install
the dependencies for that just add end
PM
install press
enter after completing npm install let
me expand this client folder from the
left sidebar and you can see in this one
we have nodecore modules folder and we
have these
files right so now we have created the
react project to start this project we
will use npm run
Dev so in this terminal we have added
npm run Dev and press
enter so our project is running on this
URL Local Host Port 5173 so just open
this URL in any web
browser so now you can see our basic
react plus wheat project is running in
the web
browser next we have we have to clear
this default
project so let's come back let me hide
this
terminal and in this SRC you will
find app. CSS so right click and select
delete after that we will open
app.jsx just open this one and we will
clear this file and here we will use RAF
C
snipet and press enter so it will create
this functional react
component if this rafc snippet is not
coming for you then you have to install
one extension just go to extensions and
here search for
es7 react
Redux you can see it has 2 million
installs so you have to install this
extension then you can use the ra f c
snipet after that let's go
to index. CSS and we will clear this
file also next just go to
index.
HTML and here you can see we have the
title right so in this one we will
update the website title so it is
imagify Das greatest stack
after adding this if I come back to the
web page here you can see our project is
cleared and in this browser title you
can see imagify Greatest Tag next we
have to update this icon that is the
favicon icon you can see in the browser
tab so to replace this icon we have to
add the images and icons in our project
so let me just come back to the desktop
screen and here I have one folder called
asss you will find this folder download
link in the video description let me
open it so in this one we have some
icons images and one assets. JS file so
let me just copy
everything from
here and open our project
folder in the project folder you can see
we have the client then SRC and in this
one we have the assets so in this assets
just paste all the images icons that we
have just
copied correct now close it and come
back to the vs code so now in the left
side bar you can see we have
the assets folder expand it and in this
assets you can see we have all the icons
correct and in this one we have one
favicon do SVG also so we have to move
this favicon on. SBG we will paste it in
the public folder so let me just come
back to the project folder again and go
to client SRC assets and from here just
find picon SVG it is here just remove it
from
here and uh we will add it in the public
folder in this client folder you can see
public just paste it here and remove
this v.s
V after that if I come back to the VSS
code here you can see we have assets. Js
file also that you will get in the
assets folder so in this one I have
imported all the
images then I have created one object
called assets and using this object I
have exported all the images using this
export keyword so that we can easily use
the images in any component by using
this
object we don't have to add the Importer
statement for each image we will just
use the assets and we will use the image
after that we have the steps data that
we will use on our web page we will
display these data from this aray after
that we have one more aray called
testimonials data so in this are we have
added different object and each object
is representing one testimonial so we
will display these testimonial data on
our web
page after that we have plans here we
will create the price plan page so on
that page we have to display different
plans so here I have added one aray and
in this aray we have three object that
represents three different price plan so
let me just close this and uh close this
assets also and in this public we have
fabicon SVG so in this index.html file
here we have the link tag and in this
link tag we have v.svg
right so instead of this v.svg we will
add favicon do SVG that we have added in
the public folder save the changes come
back to the web page now you can see the
updated icon in this browser title so we
have updated the
favicon after that we have to create the
folder structure for our project for
that just come
back and in the left side
bar here we
have client folder in this client folder
we have SRC now within this SRC we will
create a
folder called
components so so we have created
components folder where we will create
different
components after that in this SRC folder
right click and select new folder and
here we will create a folder called
pages so in this one we will create
different
pages and in this SRC folder let's add
one more new folder and the folder name
is
context in this context folder we will
create a context file where we will
store all the states for this
application so we have created the
folder
structure now after creating the folder
structure we have to add the telin CSS
in this project to add the twiin CSS
just come back to the web browser open a
new tab and here we will search
for V plus tnd CSS
open this first
link and here we have the steps to
install telin CSS in whe project so you
can see the first step create your
project that we have already created the
next step is install telin CSS so here
we have two commands right so let me
just copy it one by one just copy the
first one come back to the VSS
code and just open the terminal
again so here we have the terminal right
so in this terminal we have to add
control C so it will stop the
project now paste the command that we
have just copied npm install and this
one press
enter after that let's copy the second
command and paste it here press
enter after completing it you will see
uh new file in this sidebar you can see
post css. config.js and one more file is
there Telvin config JS it means T.C
config.js
now just come back here and you can see
the third step configure your template
paths for that
just copy this entire code click here to
copy and go to T.C config.js
file so from this left side bar we will
open telin config
JS
and replace the code here just remove
everything from here and paste the code
that we have just copied save the
changes after that you can see the next
step is to add these lines in index. CSS
file so just copy it and and come back
open index. CSS where it is it is here
index. CSS and paste
it after that let's see the next step so
the next step is to start our project
using npm run Dev that's it and now we
can easily use the telin classes in any
HTML
element now let's close it and come back
to the vs code and here we can start our
project
using this terminal but before starting
this project we will install one more
dependencies in this project we have to
create multiple Pages like
homepage and uh price plan page then we
will display the result page so to
create multiple Pages we have to add the
react router so to add the react router
we will add the dependencies called
react router Dom so just add
npm
install
react router
Dom then press
enter and after that we will start our
project using npm run
Dev use this npm run Dev press
enter now again our project is running
on same URL now we will hide this
terminal come back to the web page and
you can see our web page is running and
it is completely
blank next let's see the figma design
what we have to create so let me open
the figma file in the new
tab here you can see we have four pages
in this application let me zoom in so
this is the homepage right in this
homepage we have to create this navig
ation bar with logo these buttons and
these featured text then some small
images then we have these steps how it
works then we have this description area
then we have testimonials and one button
and one footer so this is the homepage
then let's see the other page this is
the result page so that whenever we will
enter any prompt we will see this page
with our AI generated image next we have
to create this price plan page and then
we'll create this login sign up
component correct so let's start with
the first one so to build this homepage
first We'll add the Google font in our
project so that we can use this font
right so let's open a new tab and search
for outfit
font open this website fonts. go
google.com
outfit and just click on this button get
font now you can see this button get
embed code just click
here from here just click on this import
option and you will get this import link
just copy it and uh come back to the vs
code in this vs code just open index.
CSS
file and paste it at the top so we have
added this import statement correct
after that we have to add the font in
all the elements so just add the aster
symbols or start here we will add the
font family and write the font
family outfit that's it so by default
this outfit font will be applied in all
the
elements close it come back to the
browser close this tab also and now
let's start by building this
homepage so let's come
back we will come back to the vs code
editor and uh let's close this file also
and in this Pages folder we will create
three files
right so in this pages right
click and select new file and write the
file
name
home.
jsx the file name should start with the
capital name you can see I'm using
Capital H here we will add
RFC and in this one we will add the text
called
home within this div now let's go to
Pages folder again right click and
select new file here we will add the
file name by
credit do
jsx WR our
AFC here we will
add by
credit now right click on the pages
folder select new file and write the
file name
result do jsx
here we will add
rafc and write the text
here result
page that's it next we have to mount
these pages on app.jsx file so just open
app.jsx and here you can see we have
this div right so inside this div we we
have to add the routing and based on
routing we will display different pages
so for now let me add all the pages just
add opening
Arrow home select this from this
suggestion pages slome so you can see
this home component or home page has
been
imported close this tag now we will add
result select this from the
suggestion it has been imported now we
will add the third
page by
credit so by credit has been imported
save the changes and if I come back to
the web
page and here you can see we have
home result page and Buy credit because
we have mounted all the pages in this
app component correct next we have to
display different pages based on
different route for that we will set up
the react router so to set up the react
router first we will go to main. jsx
file and in this one just remove this a
strict
mode and before this app component let's
write browser router or let me import it
first so here after this react Dom
client let's add a space and here we
will
add import curly
Braes browser
router from react router Dom so we have
imported browser router from react
router Dom now we will use this
browser router before this app component
just add the opening
arrow
and add this tag and close this after
this app component so here we have the
opening tag and this is the closing tag
correct so now we have the support of
browser router in
the complete app component
correct after that let's go to app.js x
file and in this app.jsx file we have to
use the routes and Route so just import
that so here after this import react
let's
add
import
CES
routes comma
route
from react router Dom so we have
imported routes and route now using this
tag we will declare the routing path and
based on different routing path we will
display different pages
so in this div just add a space and here
we will add routes
tag use this routes
tag and move all the pages within this
routes now here just
add route use this route tag and this
route will be self closing like this let
me add a space so you can see clearly we
have added route and in this one we have
to declare the path so just add path and
the path will be slash that will be the
homepage so whenever the user will be at
SL path then we have to display the
homepage so just add element and in this
element just add the curly
bres and provide this home that's it
after that just duplicate this line here
we will add the path that is
result and from here remove this home
and here we will provide this result
page now duplicate this line and here we
will add buy or we can say Buy credit so
here remove this and within this we will
provide this by credit page now you can
see
clearly here we have one routes tag and
within this routes tag we have three
route and in each route we have added
different path this is the Home Path
this is the result and this is by path
here we will display homepage here we
will display result page and here we
will display Buy credit page so save the
changes and let's preview this changes
on web page so just open the web browser
and right now you can see we are at the
Home Path that's why it is displaying
home correct if I change the path so in
this URL if I type class
result so we have added Local Host 5173
SL result press enter now you can see
result page now if I add
Buy in this URL press enter now you can
see buy Creed it so this route is
working
fine correct so now we will start
building our homepage where you can see
home correct so right now it is
displaying home so let me add some cses
for this homepage so let me just come
back and uh here in this this app
component we will add some CSS that will
be applicable for complete application
so in this D let's add the class
name and here we will add the tent
classes now for the entire application
we will provide the padding from x-axis
it means padding left and padding right
so we will add the padding X for this is
for the Mobile screen now for the
smaller screen we will increase the
padding so it is is padding
X10 now for the medium screen we will
further increase the padding so we will
add MD colum padding X and it will be 14
now we will further increase the padding
for larg screen so just add LG and PX
28 that's it next we have to define the
minimum height of the application so
here we will add
Min
H
screen so here we are using these tnd
classes if you don't know about the tnd
I have a dedicated video about tnd where
you can learn the tnd CSS from beginning
I will provide that tutorial Link in the
description after this mean height
screen here we will change the
background color of the application and
in the application we will add the
gradient color in the background so just
add
BG
gradient
and to bottom so just add BG gradient 2
B it means to
bottom and here we have to provide two
color code so let's add the first color
code that is
from till
50 and now we'll add the second color
code with two so
two orange
50 so we have added this first color
code and second color code for the
gradient
background after adding this just come
back to the web page here you can see we
have some color in the background and
this is the gradient color
correct now let's come
back and in this figma design you you
can see here we have the navigation bar
in the homepage also then we have this
navigation bar in the result page also
and then this navigation bar in
this price plan page also so we have to
add the navigation bar in all pages for
that we have to place the navigation bar
in the app component so you can see we
have added
this app component in this app.jsx file
so before this routes we will provide
the navigation bar so that this
navigation bar will be visible in all
pages so first we have to create the
navigation component so here we have the
components folder so right click here
and here we will select new file and
write the file name
navard do
jsx and here we will use
RFC and here let's add the text
navigation bar save the changes and come
back to the
app.jsx and before this routes let's add
Navar select it from the suggestion so
the Navar has been imported correct
close this
tag so we have added this Navar save the
changes come back to the web page and
you can see we have the navigation bar
on homepage correct if I go to other
page
like bu credit here also we can see
navigation bar and then bu credit page
if I go to result page like this here
also you can see the navigation bar and
this result page so we have added this
navigation bar component in all the
pages so next we have to design this
navigation bar so just come back and uh
go to navb bar. jsx file
in this Navar component let me remove
this text and here we have this div So
within this div we have to add One logo
in the left side and we will add some
buttons and text in the right side So
within this div let's add the
image using the IMG tag and in this SRC
we have to add the image so we will get
the image from assets object that is
stored in the assets. JS file so first
we have to import that so here we will
add
import
CES
assets
from double
do/ assets folder assets
file now in this curly assess we can use
assets Dot and we can access any image
using this dot so let's add the image
name
Logo now for this image we have to add
some CSS properties so just add the
class name property and here we will
provide the classes so just add the
width 28 then we will add different
width for small device so just add
SM width
32 after that we'll add different width
for largest screen so just add LG then
width
40 save the changes if I come back to
the web page here you can see we have
this logo right now just come back and
on this image we have to add the click
feature so that whenever we will click
on the logo it will redirect us to the
homepage so to add the click feature
here we will add the link tag provided
by the react router Dom so here just
add opening
Arrow link select this from the
suggestion react router Dom so the link
has been
imported now just close this
tag and move this closing tag after
this IMG so you can see I have wrapped
this IMG tag using this link tag link
opening and Link closing tag in this
link tag we have to provide the two
property and here in this two we will
provide the path so just add forward
slash that will open the
homepage that's it after closing of this
link tag here just add the space and
here we will add the
div and in this div we will add the
content for the right side of the
navigation bar so if I go to the web
page and let's open the figma design
so in this design you can see we have
this navigation bar where you can see
the price and log out button in the
right side but if I go to different page
like this here you can see I have added
different buttons in the navigation bar
which is creit left then name and then
icon and whenever we will hover on this
icon it will display one logout button
so we have different content in the
right side of the navigation bar it is
because suppose user is logged out then
we have to display
these link pricing and login button and
if the user is already logged in then we
will display the users name icon and
available credit that's why we have
added different buttons in the
navigation bar so to display these
information we will create two div so
just come back to the vs code
and within this div let's
add div for the user which is logged out
user and here we will add one more div
this one this is for the logged in user
correct now we have to get to know
whether the user is logged in or logged
out for that here we will create one
state variable so before this return
just
add const
user set
user is equal to user
State and here we will add null so
initialize it with null it means the
user is logged out and when it is true
it means the user is logged in so here
we will add the turn operator so just
add the curly Braes and we'll write
user so if the user is available it
means if it is
true then what will happen we have to
display this
div correct and if the user is not
available it means user is logged out
then we will display this
div
correct so now you can understand the
erary operator if user is available then
the first div will be displayed and if
the user is not available then the
second div will be available so in the
second div we will add the button called
login and in the first div we will add
the details like users name we will
display the credit and we will add the
log out option also correct so now let's
start by adding content in this second
div because right now we have added null
it means the user is logged out so in
this second div we will add one text in
P tag so just add the P tag and here we
will add the text called pricing and
after that we will add the button so in
this button let's add the text
login save the changes come back to the
web
page here you can see we have the
pricing login and this home let me
remove this home
from home. jsx file let's come back and
remove this home and let's come back to
the navb bar. jsx file and we will add
the CSS properties in this first
div so in this first div let's add the
class name property and we have to align
the content side by side so for that we
have to use the flex layout so just
add
Flex item
Center justify
between and we will add the padding in y
AIS now you can see the logo in left
side and these text in the right side
pricing and
login now just come
back and uh here we have this
div correct so in this one we will add
the class name property here also we
will add
Flex I item
Center and we will provide the Gap two
then we will increase the gap for small
device so just add Gap
five now you can see these text are side
by side and here we have the Gap also
next we will add the CSS properties in
this button and let's add the CSS
properties in this pricing also so just
come
back and in this P tag let's add the
class name property and here we will add
the cursor
pointer correct and in this button we
will add the class name property and
here we have to change the background
color so just add
BG Jin
800 so it will be a dark background
color now we will add
the text White
after that we have to add the
padding then padding from five
AIS then we'll add different padding for
smaller
screen
py2 it will be
px2 after that we will add text a
small rounded
full after adding this if I come back to
the page you can see we have some
changes in this button but it is not
looking good so just come
back and uh
here let me add
px10 save the changes and come back to
the web page now this button is looking
good correct now we have to add the
click feature on this pricing link so
just come back and here here we have
this P right so on this one we have to
add the click feature so that whenever
we will click here it will open the
credit page so we have to import the
navigate from react router
Dom so before this return a statement
let's
add
const navigate is equal
to use navigate hook
from react router Dom you can see use
navigate has been imported from react
router Dom and now we can use this
navigate so scroll down and here on this
P tag we will add on click
property and in this onclick just
provide one Arrow
function and here just call the
navigate and in this one we have to
provide the path so just add forward
slash by that is the router path correct
now if I come back to the web page and
click on this pricing you can see it is
opening by credit
right and after that if I click
on Logo it will open the
homepage it's working next we have to
add these content which is createit and
this user name and this icon and we'll
add the log out link whenever we will
hover on this icon and it will be
displayed whenever the user is logged in
so just come back
and here inste of this null we will add
true correct and if I come back you can
see the right side is blank we don't
have anything in the right side so just
come back and here we have this first
div so whenever the user is available
this first di will be displayed so in
this one just add one
button and in this button we will add
the icon so just add the IMG tag and add
the curly Braes and in this curly Braes
we will add
assets dot createit a
star and for this button I mean for this
image we will add the class name so that
we can Define the width so we will
add width
five now after this icon we will add one
text also in this button so we will add
the text called credit
left like this and let me add any value
manually so let's add the credit left
50 correct now come back to the web page
and here you can see we have this icon
and this credit left
50 now just come back and after this
button we will add one text in P tag and
here we will add the users's name so
just add hi Greatest
Tag like this and after this text we
will add one profile icon and whenever
we will hover on that profile icon it
will display the log out button correct
so let's add one
div and in this div we have to add one
image and in this image we will add CES
assets
dot let's write user and after that we
will add class name properties so just
add the class name and here we will
Define the width so the width is 10 then
we will add
the drop
shadow correct and after this image
let's add one
div and here in this div we will add
class name property and this will be
absolute and in the parent div we will
add the class name property and it will
be
relative and on this one we have to add
the H effect also so here just add
group correct now in this div where we
have added the absolute this div will be
hidden by default so just add hidden and
after that it will be visible whenever
we will hover on the parent div so just
add group hover
and it will be block so that it will be
visible
again correct next we have to add the
positions so just add
top Zer then right zero then we will add
the Z 10 so that the Zed index will be
10 after that we have to add the text
color so the text will be black next we
will add
rounded and then we will add the padding
from Top that is
12 and inside this D we will add
the log out link so just add U Li and in
this Li we will add the log out text
like this save the changes come back to
the web page and here you can see we
have
this credit left High greatest stch and
we don't have any icon here so let me
just come
back go to Project folder
SRC assets and uh let me find the icon
so here we have the icon called profile
icon.png
so here we will
use assets
dot profile _ icon save the changes come
back to the web page now you can see
this profile icon also and if i h on it
here we have the log out you can
see when I hover on this profile icon we
are getting one log out link so next we
have to add CSS properties for the
content that we have added in the right
side so just come back here we have this
D that will be displayed whenever the
user is available so in this one just
add the class name property and here we
have to align the content side by side
so just
add flex and text Center then we will
add the Gap so just add the gap Gap two
and we'll increase the gap for smaller
screen so just add Gap
three correct now you can see it is
aligned side by side now just come back
and next we will add the CSS properties
in this button right so here in this
button we will add the class name
property and here let's add the same
thing Flex item
center after that we will add the Gap
two now we have to add the background
color so just
add BG blue
100 after that we have to add the
padding from
xaxis then we will add different padding
for the smaller screen
px6 then we will add the padding from y
AIS
1.5 and we will increase the padding for
a small width so just add
py 3 after that we have to add rounded
full next we will add the hover effect
so just add hover and here we will add a
scale it will
be
one5 then just add transition
all and dation simp
700 after adding this just come back to
the web page you can see this credit
left button is looking good and here we
have over effect also when I move cursor
on this one you can see the zoom in
effect
correct after that we will add the CSS
properties for this P tag so here just
add the class name and in this one we
have to add the text size so the text
will be extra small and for a smaller
screen we will add the text size a small
like
this and now we will add the font weight
so just add font
medium next we have to add the text
color so just add
text Gray
600 save the changes you can see this
text looks
good after that we have to add the C
properties for this textt where we have
added the users's name like I have added
High great stack so for this text just
add CSS properties in this P tag so in
this P just add the class name property
here we will add the same text color
that is here text Gray 600 then we'll
add the max a
small for the Mobile screen size we will
add hidden so it will be
hidden and then we'll add the
pl4 save the
changes now this text size is looking
good next we will add the CSS properties
for the users icon and for the logout
text that is displayed below this users
icon so just come back and here you can
see we have this div where we have added
relative and group and then we have this
image right and then we have this div
where we have added ul and lii so in
this UL we will add class name and for
this UL just add list
none then we'll add the
m0 and
P2 then we'll add background
white after that we'll
add rounded
medium then we'll add the
border and text a
small now in this lii tag we will add
the class name and here we will provide
padding from Y axis then padding from
xaxis then we'll add cursor
pointer and here we'll add the padding
from the right side 10 save the changes
come back to the web page now if I hover
on this profile icon here we have this
log out button correct right now when i
h on this one the entire navigation bar
is moving down so let me fix it here you
can see we have added the incorrect
spelling for absolute so just correct
it so just corrected this absolute now
just come
back now if i h on this one you can see
it will works fine when I H on this user
profile icon here we have the log out
option correct so this information will
be displayed whenever the user is
already logged in so now just come back
and here if I make it
null and save the changes so you can see
it is displaying the login button
correct now instead of adding this state
variable in this navigation bar we will
add it in the context file so that we
can store all our states and functions
in one place so let me just remove it
from here and remove this user State
also right and we will store it in one
store so in
this sidebar we have created one context
folder so in this context folder we will
create a new file file so write the file
name app
context do
jsx in this app context jsx we have to
create the context where we can store
the variables and functions and we can
use these variables and functions in any
component so here we have to add the
import a
statement so just add import
cly
Braes create context from react so we
have imported create context from react
correct Now using this create context we
will create a context variable so just
add
export const app
context equal to create
context now for this cont context file
we will create a context provider
function so just add
const app context
provider equal
to one Aro
function and here we will get the
props now in this one we can declare any
state variables or functions and we can
access it in any component so here let's
declare this
is user state so con user set user user
State null so we have declared it here
now here we will create one variable so
just add const
value equal to it will be one object so
in this one we can pass all
our variables and functions so we will
pass
this user
and set
user correct next we have to return so
just add return statement and in this
one just add app
context it will
be opening Tag app
context and here we will add app
context.
provider so you can see we have added
app context. provider and closing Tag
app context. provider here in this one
we will add value and provide this value
object correct and within this tag just
add curly
veres props do
children correct now what we have to do
we have to export this app context
provider so just copy this one and here
just add
export
default app context provider that's it
so now we have created the context and
from this context we can access the
variables and functions in any
component correct we have already
explained
this we have already explained this
context hook in a dedicated video where
I have explained all the react hooks I
will provide that video link in the
description
now after adding this we will come back
to
the main. jsx file so just
open main. jsx and here we have to add
the app context provider so first we
have to import that so here just add
import app context Provider from Context
folder app context. jsx file so we have
imported It app context provider and
after this browser router we will add
this tag just add app context provider
close this tag and we will move this
closing tag
here after this app component so you can
see what we have in this file first we
have the browser router and in this
browser router we have the app context
provider and in this app context
provider we have the app component now
in this app component we have the
support of this app context provider
right so we can access the context file
in this
app correct now let me remove this a
strict mode from here because we have
already removed
it after that we will come back to the
na. jsx file in this na. jsx file we
need the user so we will get the user
from Context so just add
const cly says
user equal
to use
context let's select this use context
from this suggestion so use context has
been
imported and in this use context we have
to provide the context that we have
created so we have
created app context select this from the
suggestion so this app context has been
imported now we have the user in this
file also and if you want to update the
user so you can go to this app context
and instead of this null we can make it
anything so if I come back to the web
page here we are getting some error so
let's inspect
it and go to console you can see we have
the error the a error occurred in app
context
provider user state is not defined so
let's come back and you can see here we
have
added user state but we have not
imported it right so just
add user State select it from here so
the user state has been imported from
react that's it save the changes again
come back to the web page and now you
can see here we have the navigation bar
with pricing link and login button
because the user is logged out now if I
come back and instead of this null we
will make it
true save the changes and come back to
the web page and you can see now we have
this credit left button then users name
and profile icon with log out link
correct so just come back and again make
it
null later we will connect the back end
so that we will get the status of this
user from our back end here in this navb
bar. jsx file you can see we have added
this button that is for the credit so
whenever we will click on this button it
should open the Buy credit page so here
also we can use the on
click and here just add the Aro
function and in this one use this
navigate and in this one just provide
the path forward
slby the same thing that we have added
here you can see we have added in this P
tag and here also we have added this
same thing correct save the changes and
you can see our navigation bar is
working now we have complete completed
the navigation bar and after completing
the navigation bar let's come back to
the figma design and in this one you can
see below this navigation bar we have
this header
section and in this header you can see
we have this small text with icon then
this welcome text a small description
one button and some
images correct so we have to create this
header section and this header section
will be displayed on
homepage so let's come back to the vs
code
editor
and let's open sideward and in this
sideward here we have the components
folder so in this components folder
right click and select new file and
write the file name header.
jsx here we will use
RFC right
header correct and after that we will
will
open home. jsx file and in this home.
jsx file we have this div and in this
div just add opening
tag header select this one from the
suggestion so the header component has
been imported close this tag save the
changes come back to the web
page here you can see we have the text
called header that is coming from this
component this one right so let me
remove this header and in this one we
have to add the text with one icon so in
this header let's
add one
div and in this one let's add one text
in P
tag let's move it in next
line and in this P we will add the text
so this is the text and after this text
we will add one star icon so just add
the IMG tag and here let's add
the curly bres assets dot start
icon and uh you can see the assets has
been imported correct save the changes
come back to the web page you can see
here we have the text and icon correct
now just come back and here we have the
first div so in this one we will add the
class name so in this one let's add the
Flix layout so just add Flex here we
will add flex and flex column so that it
will be displayed vertically then we
will add justify Center and items
center after that we have to add the
text
Center then margin from y AIS
20 correct now we have this div and in
this D we will add the class name
property and in this one we will add
text color so just add text a stone 500
this is the text color then we'll add
the inline
Flex after that text
Center then we will add the gap of two
then we'll change the background so just
add BG
white next we'll add the padding from x
axis that is six and padding from Y axis
one after that we'll add rounded full
next we'll add the border and then we'll
add the Border colors so just add
border neutral
500 save the changes come back to the
web page now you can see this text and
icons are looking good with this button
style after that we have to add a large
text so just come back and after closing
of this du we will add one title in
H1 so in this H1 tag we will add the
text turn text to image in
seconds so this is the
text you can see this text here correct
now for this title we will add the class
name and we have to increase the size of
this text so just add text 4
XEL after that we will add maximum width
that is 300
pixel then we'll add the different text
size for a smaller
screen then we'll add a small and here
we will
add maximum
width and we will add one custom width
here so let me
add 59 0
pixel correct and now we will add
the margin from the left side and right
side so just add MX
Auto then we will add the margin from
top 10 and text
Center save the changes come back to the
web page you can see this text in the
center and in large size next we have to
change the
color of some portion of this text
correct so just come back and here you
can see we have this text text turn two
and after that we have this image so let
me wrap this image in a span tag so here
just add opening Arrow
span close
it and close this a span tag after this
image
text now for this asan tag we can add
the class name property and here just
add the text color so just add text blue
600 that's it save the changes come back
to the web page and now you can see this
image text is in blue
colored now after this title text we
will add a small description in P tag so
let me just come back and here just
after this H1 let's add a space and and
we will add the P tag in this P tag we
will add one description text so this is
the description and here we will add the
class name also so in this one let me
add the classes we will add the text
Center then we will add the maximum
width and margin X Auto and margin top
five that's it save the changes and now
you can see here we have this
text
correct after this text let's come back
and here we have to display one button
so after this P tag we will add the
button
tag and in this button we will add the
button text that is generate images and
then we'll add the icon also so just add
the IMG tag let me move it in the next
line so it will look good so in this
image tag we have to add
the image so just add SRC
assets dot star
group come back to the web page here you
can see we have this generate image
text then we have these Stars correct so
we have to add the CSS properties for
this
button so let me just come back and uh
in this button let's add the class name
and here we will provide the
text size
for small device so just add text LG
then we'll add the text size then we'll
add the text
white after that we will add the
background so the background will be
black BG
black next we have to add the width
Auto and margin
top8 then we'll add the margin from x
axis that is 12 and padding from y that
is 2.5 then we'll add the flex so that
the icon and button text will be aligned
side by side then item
Center then we will add the gap
of
two then rounded
full that's it save the changes and come
back to the web page
you can see it looks like a button but
now we have to decrease the size of the
star icon so just come back and here we
have the image tag and in this one we'll
add the class name and just provide the
height height six save the
changes now you can see this generate
image button is looking good correct
after that we have to add some more
content so let me just come back to the
Fig design and in this one you can see
after this button we have these images
so we have total six
image correct and then we have one a
small text generated images from imagify
so we have to display six images and
this a small text in this header section
so let me just come back to the vs
code and after this
button let's add space and here we will
add one
div now in this div we have to display
multiple images so we will use one add a
so just add curly
presses add
a six so the added length will be six
then we'll add the
fill and it will be empty string then
we'll use the map
method now in this map
we can add the Aro
function correct and in this parameter
we will take
item and
index correct now in this one we have to
display the image using the IMG tag so
just add the IMG
tag and uh in this image tag we have to
display the images so just add the curly
Braes and here we can
use assets dot sample image 1 like this
and uh for this one we have to add the
key property so just add
key is equal to
index and then we will add the
width
and this width will be after this index
and in this width just add
70 now if I come back to the web page
you can
see we don't have the image here so
let's come back instead of this curly
bres we have to use the small
bracket here also we will add a small
bracket like this correct now just come
back and here you can see we have have
six images that is displayed vertically
correct now just come back and here in
this image tag let's add the class name
so here we will
add rounded then hover so whenever we
will hover on this one it should
increase the size so just add a scale
105 then we will add the
transition all then we will add the
duration 300 then cursor
pointer after that we will add
the max
SM width
10 and now here we have this div also so
in this div we will add the class name
property so that we can align all the
images side by side so in this div we
will add Flex
then Flex wrap then justify Center then
we'll add the margin from top 16 and we
will add the Gap
three now just come back to the web page
and you can see these images are aligned
horizontally correct now here you can
see the same image in all positions
right so now we have two images so I
will display the images in alternate
position first it will display the
sample image 1 then it will display
sample image two then again sample image
1 and Sample image two like that for
that here we will use the Turner
operator so let me add it in new line so
that you can see
clearly here in this SRC we have assets
do sample image 1 correct so instead of
adding this we will use the Turner
operator we will
add index percent
2 if it is zero then what will happen it
will display sample
image
two correct and here we will add colon
then provide assets. sample image 1 so
what is happening here if it is
divisible by two then it will display
sample image 2 and if it is not
divisible by two then it will display
the sample image one that's it save the
changes and come back to the the web
page
again you can see here we have the first
image second image then again first
image second image again first image and
second
image it looks good after this image we
have to display one small text so just
come back and here we have this array
and this div that contains all the
images so after this div let's add one P
tag and in this P tag we will add the
text
generated images from
imagify and in this one also we will add
the classes so just add the class name
property and we'll add margin from
Top text neutral
600 that's it save the changes and come
back to the web
page now you can see very small text
below this image so now we have
completed the header section of our
application
after completing this header section
let's come back to the figma
design and here you can see after this
header we have this content where you
can see the text called how it works and
here we have some steps describe your
vision watch the magic download and
share so these are the steps to generate
the image so next we have to create this
steps components correct so let's come
back to the vs code editor and in this
left side bar we will go to complaints
right click here and select new file and
here we will add the file name steps.
jsx in this one we will add
RFC and it will create this functional
component correct now in this one we
have to add the content from the assets
file you can see assets assets do JS and
in this one you can see we have
added a steps data so this is one aray
and in this aray we
have three
object
correct so we have to display the data
from this steps data
array now just come back and in this
steps. jsx file first in this div we
have to add the
title so here let's add the title in H1
tag and in this title we will add the
text called how it
works now in this H1 we will add the
class name properties so in this one we
have to provide some classes like text 3
XL then we will add
the text size for small screen device
then we'll add the font weight that is
semi bold and we will add the margin
from the
bottom
mb2 after this title there will be one
small text in P tag so here let me add
the
text transform words into a stunning
images and here let's add the class name
and here just add the text
large after that we'll add the text
color so just add text
gray
600 then we will add the margin from the
bottom
mb8 like this so we have added the title
and description in a small P tag after
that we have to add one div so after
this P tag we will add one div and in
this div we have to display the steps
data
so here let's add the curly bres
just add the steps
data select this from the snapit so you
can see the steps data has been imported
from the assets folder assets file so
this is one ad so on this ad we can use
the map method so let's add do
map in this one we have to add the Aro
function so just
add one Arrow function and here we will
use this small bracket
correct now in this parameter we will
add the
item then we will add
index now in this
one let's add one div so it will return
a
div and uh in this div we have to add
one image so just add the
image in this image let's add curly
Braes and H here we will use this
item because each object contains one
property called icon so just add item do
icon after that here let's add
div and in this D we will add the a
steps title and a steps description so
we will add the title in h2 tag so just
add the curly
Braes and here we will add the
item
dot
title after that we will add the P tag
and in this one we will add same
thing and instead of title we will
add
description like this and here we have
this div so in this div just add the key
property and in this key we will add
index like this see save the changes and
next we have to mount this steps
component
in homepage so just
open home and after this header let's
add a steps so a steps component has
been imported close this
tag save the
changes now just come back to the web
page scroll down and here you can see we
have the title how it works then a small
description then we have the icons for
different steps then a steps title
description correct so now we have to
provide the CSS for this element so just
come
back and uh first we have this div so in
this div just add the class name
property and here we have to add
Flex then we will add Flex column so it
will be displayed
vertically after that we'll add items
Center then justify
Center then we will add the margin y 32
correct after that here we have the
title in H1 so in this title we have
already provided the classes and in this
description also then we have the div
that contains a steps so in this div
let's add the class name property and
here we will add a space
y four then we will add the width
full then we will add the maximum
width and after that we will add the
text size so the text will be small
correct next we have this
D for IND individual item right so for
individual item let me add the class
name in this one we will add flex and
item
Center then we will add the gap of
for after that we will add the padding
five then padding x 8 then we will add
the background so BG
white/ 20 so the opacity will be
20% it means the background color
opacity now we'll add the
shadow
medium then we will add the
Border then cursor
pointer and after that we'll add the
hover effect so just add hover and just
add a
scale and in this scale we will add the
custom
value in this square bracket so we will
add
1.02 correct then we'll add the
transition all and duration
300 after that in
this image tag we have to provide the
width so just add the
width
40 then we have
this a small typ title and a small
description so in this h2 tag just add
the class name and here we have to add
the text size and font weight so I will
provide text Excel and font medium now
in this P tag we will add the class name
and here we will just add the text color
so the text color is gray 500 save the
changes and come back to the web
page now you can see these steps are
looking good
and here in these individual steps we
have to add the round corners right so
just come back and uh here in this
D after this duration 300 just
add
rounded
large save the changes and come back to
the web page now you can see these steps
are looking beautiful
correct so after completing this steps
section let me just come back to the
figma design and here you can see we
have the next section that is the
description section where we can add the
title small description and then we have
the content in two columns left and
right side in the left side we will add
the image and in the right side we will
add the description so just come back
and uh in the left side
bar open this SRC folder then right
click on this components folder and here
we will create a new file and write the
file name description.
jsx here just add
rafc and uh in this
one we have to add the
title so in this D we will add the title
in H1 so in this title we will add the
text
called create AI images after that we
will add the text in P tag that is the
small description so here just add the
text like this so in this div we have
added the title and a small description
now let's add some CSS properties so in
this one we will add the class name and
here we will add Flex Flex column item
Center justify
Center like this after that we have to
add the margin from y AIS then we will
add the padding and we will add the
padding X for medium screen size so we
have added
myy P6 then PX
28 after that we have the title and
description so let's add the CSS
properties for this one so in this H1
just add the class name and let's
increase the text
size text 3 XEL then for a small device
we will
add text for
Xcel
then font semi bold then we will add
margin bottom
two after that in this description we
will add class
name and for this one we will add text
Gray
500 and uh in this one we will add the
margin from the bottom
8 like this now save the changes and
after that we have to mount this
description component on homepage so
let's open
home. jsx and after this steps let's
add description component so description
component has been
imported close this tag now just come
back to the web page and if I scroll
this web page here you can see we have
the title create AI images and this a
small description after that we have to
add the content in two columns left and
right side so let's come back
open description. jsx file and after
this P tag let's add a
space here we will add one div and in
this div in the left side we will add
the image using the IMG tag and here
let's add the image from
assets
dot sample image
one after that we will add the class
name also so here for this image let's
provide the class name width
80 for Excel screen size we will add
width
96 after that we will add
rounded it will be
large then we will
add one
div so after this image we have added
one div that will will be displayed in
the right side now in this div we have
to add one text in the S2 tag so just
add S2 and write this text correct and
after this text we will add description
in P tag so let's add the P tag and in
this P we will add the
text correct and after that we'll add
one more text in P tag so just add
another P tag and and paste this
text correct so now we have the image
and text now just come back to the web
page here you can see we have this image
and we have these
text below this image so we have to
align it side by side so let me just
come
back and for this div we will add the
class name so in this div just add the
class name property and here let's
provide flex and Flex
column and GAP
five now we will add the medium a screen
size so for medium a screen size we will
increase the Gap so the Gap will
be
14 after that we will add medium screen
and for this medium screen size we will
add Flex row so that it will be
displayed side by side and for a small
and mile phone screen it will be
displayed
vertically correct after that we have to
add item
Center that's it save the changes and
come back to the web page now you can
see this image in the left side and this
text in the right side correct now just
come back and here we have this div
where we have added the H2 and P so for
this H2 let me add the class name and in
this one we have to increase the text
size so the text size will be 3 XL then
we will add the font medium so that the
font weight will be increased then we
will add the maximum width and after
that we will add margin from bottom
four after that here we have the P tag
also so in this P tag we will add the
class name and in this one we will add
the
text color and margin bottom so the text
color is gray 600 let me add the same
text color in the next
text that is next p tag so just add the
class name and provide this color that's
it now save the changes and come back to
the web page here you can see this text
are looking
good and if I come back to the figma
design you can see it looks
same correct
so now we have completed our description
section also and after this description
we have to display this testimonial
section to create this testimonial
section let me just come back to the vs
code and close this
file and let's open sidebar and in this
competence folder we will create a new
file with the name testim mon.
jsx here we will use rafc
snippit now we have to mount this
testimonials component in the homepage
so just open home. jsx and after this
description just add opening
arrow and
write testimoni
select this from the snapit so the
testimonial component has been imported
close this tag correct so we have
mounted the testimonials in this
homepage after that we will add the
elements in this testimonial component
so in this
one here we have this div and within
this div we have to add the title and
one text so let me just copy the title
from the previous section so let me just
open
description and from
here just copy the class name from the
first
D and paste it in this
one so here we have added Flex Flex
column item Center justify Center and in
this m y we will add
20 then we will add the padding
y
12 and remove this PX
correct after that we have added
this title and description in H1 and P
tag so just copy this one from the
description part and paste it
here
so we have added the H1 and P and in
this one we have to update the text so
first we'll update this title it is
customer testimonials and here we will
add the small text in P tag so we have
updated the text in P tag so here you
can see we have added text 3 XL then
text 4 XEL then font semi bold and
margin bottom two and in this one we
have added text Gray 500 and margin
bottom and we will make it 12 so margin
bottom is
12 after adding this if I come back to
the web page scroll down and and here
you can see customer testimonials and
this a small text after that we have to
display the testimonials in three column
and we have already added the
testimonial data in the assets so if I
open assets folder assets file so in
this one you can see we have one array
called testimonials data and here we
have added the testimonials in each
object so here you can see we have added
the testimonials array and in this array
we have three object that represents
individual testimonial data correct so
we have to use this data to display the
testimonial on our homepage so in this
testimonials. jsx file after this P tag
let's add one
div and for this div let me add the
classes also so just add the class name
property and in this one we will provide
Flex Flex wrap and we will add the gap
of six after that in this div we will
use curly bres and here just
use testimonials data from assets it has
been imported in this one we can use the
map method because it is an array and in
this map method we will add the Aro
function so just
add one Aro function and here we will
use the small bracket now in this
parameter we will add testimonial and
index so this is the individual
testimonial data and this is the index
number now in this we will add one
div and it will return this div and in
this div we have to add the key property
so in this key we will add the index
like this now within this div we have to
display the users image then users's
name then role and we will display the a
star rating then we will display the
testimonial text so we will display that
in one div so just
add div and uh in this div just add the
image and in this SRC just add
testimonial that is the single
testimonial data dot
image so we will get the image and for
this image just add the class name and
here just add rounded full so that it
will be Circle and we will add the width
14 that's it if I save the changes come
back to the web page here you can see we
have three users image because we have
total three testimonial data
right so right now we have just added
the image using this
map right and after this image we have
to add the name so we will display the
name in
H2 so in this H2 just add curly
presses and we will
add testimonial dot name so it will be
the user's name correct after that
duplicate this line
and we will make it
P closing P tag also and here we will
add testimonial.
roll correct and after that we have to
add one div so after this P tag let's
add one div and in this div we have to
add the star rating so let's add one
class name
here and in this class just add Flex
margin bottom
for now we will add one aray so just add
curly
Braes are a and uh in this one we have
to add this
testimonial
dot
Stars Then dot
fill and uh here we will add dot map
here also we will add the Aro
function with a small
bracket and uh in this map parameter we
will add item and uh
index now based on this index we will
display the start icons so in this a
small bracket we will add the IMG
tag and uh here just just add key
property in this key property we will
add
index and after that we have the SRC so
in this SRC just add curlys and we will
provide
assets dot rating
star like
this and after that we have to display
the testimonial text so after closing of
this div here we will add p tag and in
this P tag we have to display the
testimonial text so just copy this one
paste it here and instead of name we
will
add
text
correct now let's come back to the web
page and here you can see we have the
users image name
role a start rating and
this testimonial text so in all
testimonial you can see five star
correct so let me just come
back and uh
open assets and here you can see we have
the STS five five and five in each so
let me add four in this one in the
second one we will add four save the
changes and come back to the web page
now in this one you can see we have four
rest starts in this one we have five and
five correct next we will add the CSS
properties for this component so just
come back
and in this testimonials. jsx we have
one div where we have added all the
testimonials right then we have this div
where we have added the key property
correct so in this one we will add the
class
name let me make it in new line so that
we can see the text clearly so here we
have to add the background color so just
add BG white/
20 after that we'll add the padding 12
then we will
add
rounded it is large then we'll add
shadow shadow it will be
medium after that we will add border and
width so just add the border and the
width will be
80 then we'll add the margin Auto after
that we'll add cursor
pointer next we will add
hover and in this hover we will increase
the size so just add a
scale
1.02 then we'll add the
transition
all correct then we have this div
correct so in in this div we will add
the class name property and in this one
we will provide the flex Flex column and
item
Center like this next we have this image
and in this image we have already added
the class name then we have the title in
H2 so in this H2 we will add the class
name property and here we have to add
the text size font weight and margin
from the top so we will provide text
Excel font semi gold and margin top
three after that we have this B tag
where we have added the role so here
just add the class name property and in
this one we have to change the text
color and we will add the margin from
the bottom so we will add text Gray 500
and margin bottom for correct then we
have this div where we have added the
class name then we have this image for
start
rating then at the end we have this
testimonial text so in this one also we
will add the class name so just add
class name and here we have to add the
text Center then we will add the text
size a small then we will add the text
color so the text color will be gray 600
like this now save the changes and come
back to the web
page here you can see these testimonials
are looking good and here we have some
hover effect
so now we have completed the testimonial
section
also correct after that we will come
back to the figma design and here you
can see after this testimonial we have
to display this title and this
button so for this one we have to create
one component so let me add a new
component in this left side bar we have
have the components folder right click
and select new file and here we will add
the file name generate button.
jsx so we have added generate bn. jsx
because here we will add one button now
we will add RFC
snippet and after that we have to mount
this component in homepage so just open
home. jsx and after this testimonials we
will
add generate BTN so generate BTN
component has been
imported correct after that let's open
generate BTN
component and in this
one here we have to add
one
title So within this D let's add one
title in H1 and in this title we will
add the
text see the magic try now and after
this title we will add one button so
just add the button tag and in this
button we will add generate image text
and after that we will add one icon also
so just add the IMG tag and here in this
SRC we will add curly
Braes then assets
dot star
group correct and in this one we have to
add the height so let's add the class
name property and H six so the height is
six for this star group image after that
here we have this button and H1 tag so
for this H1 let's add the classes so we
will add the class name property and in
this one let me add these classes so for
this title we have provided text 2 XL
then text 3 XL then text 4 XL for
different screen size then margin top
font semi bold text neutral 800 padding
Y6 and padding y 16 correct after that
here we have this button so in this
button also we will add the classes so
here let's add the class name
property and in this class name we will
provide inline Flex items and Center Gap
two padding X12 padding Y3 round it full
then we will add the background color
black text color white then margin Auto
then we will add the hover effect so it
will increase the size whenever we will
hover on the button transition all
duration 500 correct after that here we
have
this div right so in this div also we
will add the class name and in this one
we will add the padding from the bottom
so just add padding bottom 16 and text
Center that's it after adding this let's
come back to the web
page here you can see we have this see
the magic text and this generate images
button correct now let's come back to
the figma design and here you can see
after this section we have the
footer correct
and this footer will be displayed in all
pages so we have to add this footer
component outside of the router so let
me just come back to vs
code and first we will create the footer
component so in the left side bar go to
components folder right click and select
new file and write the file name footer.
jsx
here we will use our
AFC and in this footer
component we have to add the class name
in this
div so in this div we will add the class
name and we will use the flex so that
the content will be aligned side by side
so just add Flex then item Center and
justify
between correct then we will provide the
Gap so the Gap will be
four after that we will add the padding
from y AIS that is three then we will
add the margin from top that is 20
correct now in this footer we will add
the logo in the left side so here just
add the IMG tag and in this one we have
to add the path or we will provide the
logo so just add
assets Dot
logo and for this image we have to
provide the width also so just add the
width and the width is
150 correct and after that we have to
add one text so after this image we will
add one P tag and in this P tag we will
add the copy text so this is the
text copyright greatest T Dev all right
reserved
now after this text we have to add some
links so we will use the div and in this
div we will add images so just add the
IMG tag and for this one we will add cly
bres assets
dot Facebook
icon and for this image we will provide
the width also so just add the width 35
correct now just duplicate it and
instead of Facebook icon we will add
Twitter icon now in the next one we will
add Instagram
icon correct now we have to align these
images side by side so here with this D
we will add the class name and we will
add flex and we will provide the Gap so
the Gap will be
2.5 then we have this P tag correct so
in this P also we will add the class
name and here let's add Flex one so it
will use the entire space available in
the row then we will add the Border
one then we will
add border color so just add
border gray
400 after that we will add adding from
left side so it is for then we will
add text a
small then we will add text color so
just add
text Gray
500 correct and for mobile device it
will be hidden so just add Max
SM it will be
hidden after adding this we have to
mount this footer component in the
app.jsx file so let's open app.jsx in
this one you can see here we have the
routes so after this routes let's add
opening Ado we will use footer and
select this from the snippet so this
footer component has been imported close
this
tag so here you can see we have added
this footer outside of this routes
that's why this footer will be displayed
on all the pages save the changes come
back to the web page scroll down and
here you can see at the bottom we have
this footer so in the left side we have
the image then copyright message and in
the right side we have these icons if I
go to figma design you can see it is
same as this
design here we have to add the vertical
line in the left side as you can see
here correct so let me just come back
and uh we have added it but it is not
visible if I go to footer. jsx you can
see we have added border it will be
border L it means border
left save the changes come
back and it will be border left let me
correct the spelling also it
is border L then border gray padding
left right save the changes and come
back to the web
page now you can see we have a vertical
line before this
text so now we have completed the
homepage of our
application after completing the
homepage next we will create the second
page so let me see this figma design and
you can see here we have the another
page that is the result page so that
whenever people will enter the prompt
then they can see the result image on
this page like this
correct so to create this result page
let me just come back to the VSS
code here we will come to left side word
and in this one we have result. jsx file
so let's open this file result. jsx and
in this one you can see we have this
text called result page and if I come
back to the web browser and in this path
if I type SL
result so it will display the result
page so in this page you can see the
navigation bar and footer it is already
there then we have this text called
result page so we will remove this text
and we will add these content like this
image this loading text this form where
user can enter the prompt and click on
this generate button correct so let's
come back and remove this
one and here in this div let's add one
another
div and within this div we have to add
one class name so let's add class
name and we will add the class name
relative
and within this we will add one
image so add the IMG tag and here we
will provide
the image so just add cly bres
assets
Dot and uh here we will
use sample
image sample image 1 so we have added
this image and in this image we will add
the classes so just add the class name
and for this one let's provide the
maximum
width it is a
small after that we will add the Border
radius so just
add
rounded correct after this image we will
add one asan tag and using this asan we
will display one horizontal line below
the image so let me add the self closing
tag like this now in this one we will
add the class name and here let's
provide absolute so the position will be
absolute then we will add bottom
0 left zero then we will add the height
one after that we will add the
background background blue
500 after that we will add the width
full and then we will add
the
transition
all then we will add the
duration and in the duration we will
add 10
seconds correct if I save the changes
and come back to the web page here you
can see
this image and this horizontal line
correct
now let me just come
back and
uh after this div we will add one text
so just add the P tag and in this text
we will add
the message
loading after adding this text just come
back and here you can see this text
loading below this blue horizontal
line after that we have to add one form
with here we will add the input field
and button so after this P tag and after
this closing div tag here we will add
another
div and we cannot return to div like
this so before this div here let me add
one form tag we will add this form
tag and close this form
here at the end
so we are just returning one form tag
and in this one we have the first
div and now we will create the second
div now in this second div let's add one
input field so just add input the typee
will be
text and after that we will add the
placeholder and in this placeholder let
me add describe what you want to
generate so this is the placeholder text
and after that we'll add the class name
property so let's add the class name and
here we will add the classes so let's
add Flex one background transparent
outline none margin left 8 and Max SM
width 20 correct and after that we have
to add one button so after this input
field we will will add one button
tag and in this button we will add the
text called generate correct and the
button type will be
submit and now in this button we will
add the class name so just add class
name
property and here we have to add the
background then we will add the
padding after that we will add the
padding for small screen device then
padding y then rounded full so we have
added this CSS properties in the button
after that you can see here we have this
input field where we can type anything
and here we have this button
correct next we will add one more thing
in this div we will add the class
name so in this div we will add Flex so
that it will be aligned side by side
after that we will add the width that is
full then we will add the maximum
width
Excel after that we have to add the
background and we will make the text
white so we have added the background
and text
white correct and now then we will add
the padding and margin top and Border
radius so we will
add text a small padding 0.5 margin top
and rounded full after writing this you
can see here we have this input field
with this generate
button now let me just come back and
here you can see we have added the form
tag so in this form also we will add the
class name so in this form tag we will
add the class name and here we have to
provide flex and flex column
then we will add the minimum
height and after that we will add
justify Center and item
Center save the changes come back to the
web page now you can see here we have
this image then this blue horizontal
line then loading and here we have the
input field and generate button correct
next we have to change the color of this
place holder text for that we have to
use a custom class
name in this input field we will add our
own class name so let's add placeholder
color just copy this class name and we
will
open index. CSS file here we will add
this class name and for this class name
we will provide the CSS properties so in
this one we will add the color and font
weight so we have added this color and
this font weight after that let's come
back to the web page page now you can
see the color for this placeholder text
and in this input field we can write
anything like
this after this input field and button
we will add two other buttons that is
generate another and the second button
name is download so just come
back and we will open
result. jsx file and here we have
this closing form tag so before this one
we will add a space and here let's add
one
div and within this div let's add the P
tag and in this one we will add the text
called generate
another duplicate it and in this one we
will add the text
called download
so instead of this P we will use the a
tag so let me just remove it and here we
will add one a tag and the link text is
download correct now let's add the CSS
properties so in this div let's add the
class
name and here let's provide these
classes we will
provide Flex Gap Flex wrap justify
Center text fight text a small then
padding zero then margin top top and
Border radius that is rounded full after
that we'll add the classes in this P tag
so just add the class name and here we
will
provide background transparent border
border 900 text black padding X
padding y rounded full and cursor
pointer after that we will add the class
name in this a tag so
here let's add class name and in this
one just provide
this class name background Jin 900 that
is the background color then padding
from X and padding from y AIS rounded
full cursor pointer correct now whenever
we will click on this link that is
download it should download the image so
here we have to provide the
image and here we have to provide one
more attribute that is download so just
add
download that's it save the changes and
open the web
page here you can see we have generate
another and download button
correct now just come back and uh you
can see here it is displaying this input
field also and this button also so what
we have to do we have to either display
this input field or this button so what
happens whenever we don't have any image
then we will display this input field so
that user can type something and
generate the image and after generating
the image it will hide this input field
and it should display the download
button so that user can download the
generated image or user can click on
this button to generate another
image correct so either we have to
display this one or this one so just
come back and
here before this return
statement let me add some State
variables so first let's add const we
will add image and set image this Setter
function name is set
image and in this one we will add user
state to create the EST State variable
we are using user State and here we will
add the image so just add
assets
dot sample image 1 now instead of using
this assets. sample image 1 in this IMG
tag here we can use this state so simply
add this
image like
this correct
and after that if I scroll down here we
have added the hdf correct so in this
hdf let's add the curly
presses and provide this image state so
that whenever user will click on this
download button it will download this
image because we have added the download
attribute in this a
tag
correct now here we will create another
estate variable so let's add
const and we will add the
name is image loaded and the seter
function name
is set is image
loaded and here we'll add user
State then we'll add the initial value
so initialize it with
false so it means initially the image is
not loaded so when the image is not
loaded then what will happen we have to
display this one we have to display
this input fields that is added in this
div you can see the entire div this div
contains one input field and one button
so this div will be displayed whenever
the image is not loaded so here let's
add we will add the curly braces and
here we will add not
of is image
loaded then we will add the end operator
and here we will provide this
div so what we have to do we have to
just remove this curly Braes from here
and paste it here after this
div so when it is true then only this
will be displayed and come back to the
web page still you can see it is
displayed here because here we have
added not of is image loaded so is image
loaded is false and we are using the not
operator so so it becomes true so if it
is true then this div will be
displayed now we will add condition for
this div so here also we will
add cly bres and here simply add is
image loaded it means the image is
already loaded so in in that case we
will display this div because the image
is already loaded then user can download
the image or user can click on the
button to generate another image so just
move this curlys
here like
this now just come back to the web page
and here you can see we have this input
field and if I change it suppose we make
it
true now you can see what happens here
we have this generate another button and
download button correct that input field
is hidden because the image is already
generated so we can download the image
and if I make it
false then you can see again we have the
input field and we don't have the
download button next we have to add the
feature for loading image so let's come
back and uh
here let's add another estate variable
const and we will add variable
name or a state name
loading and the setter function name is
set
loading is equal
to user State and write the initial
value false so initially loading is
false so when the loading is false then
what we have to do we have to hide this
one this text
is displayed by default so we have to
hide this one whenever the loading is
false so in this P tag we will add the
class
name and here just add curly Braes
now in this one we will
check not of
loading then what happens we will add a
class name called
hidden and if the condition is false
then we will add empty class name that
is empty
string that's it now just come back and
here you can see that loading text is
hidden and when I make it false or make
it
true it means the loading is true
correct so when the loading is true it
will display this loading text now just
come back and let me make it
false so it will be hidden now let me
come back to the web page and you can
see here we have the input field so let
me hide this input field so for that
here we have to make it
true so you can see the input field is
hidden and here we have the download
button that will download the image and
here we have the generate another button
so now we have to add the click
functionality on this generate another
button correct so just come back and uh
here we have
this button generate another in this P
tag so in this P tag we will add the on
click property so let's add a space here
and here we will add on
click and in this one we will add one
Arrow
function and uh here we will call the
setter function that is set is image
loaded and we will make it
false so whenever it is false then it
will display the input field so let me
just click on this button now you can
see here it is displaying the input
field Let me refresh
it click on this generate another button
it is displaying this input field so
this click feature on this button is
working fine correct so now again let me
make it
false so by default the input field will
be
displayed after that here you can see we
have added this
width full for this span tag so here we
will make the width zero and so whenever
the loading is true then the width will
be full and whenever the loading is
false then we will add the width zero
for that let
me remove this single quote and we will
make
it back
tis like this and we have to wrap it in
curly brushes
correct so we have wrapped this class
name in curly bres and we have added the
back Tex
also and after that you can see we have
added width full transition all dation
this one correct
so just remove it and here we will add
dollar sign curly bres we are using
template literal so just add loading and
we will check if the loading is true
then we will add these classes that is
width full transition and
duration after that here we will add the
colum if it is false then what will
happen it will add the width
zero so just add width
zero we have to add one single quote
here now it is
correct save the changes and come back
to to the web
page now you can see that blue
horizontal line is hidden and if I make
it true in this loading if I make it
true then you can
see this horizontal line is displayed
and this loading text is displayed and
if it is
false then that horizontal line is
hidden and that loading text is also
hidden correct next next we will create
one state variable that will store the
data that we will type in the input
field so here just add
const a state variable name is
input and the set function name is set
input equal to user State and initialize
it with empty
string now we have to link this
a state with the input field so let me
just copy this set input and scroll down
here we have this input field correct so
in this one let's add a space and here
let's add on
change we will use this on change
property and here just add e and we'll
add the arrow
function and then provide this set input
and in this one we have to provide the
value that is typed in this input field
so just add e do Target dot
value now we will add the value property
in this input field so just add the
value and here just add the state input
that's
it so now whatever we will type in the
input field that will be stored in this
input a state and using this input a
state we will generate the image after
that here you can see we have created
this form tag and here we have this
button to submit this form you can see
in this button we have added the type
submit so whenever we will submit this
form it should execute one function so
we will create one form submit Handler
function so here before this return
let's
add cons
we will add the function name on submit
Handler equal
to I in we will add the form submit
event it will get the event here and
then we'll create the arrow
function now we will complete this
function later whenever we will create
the back end of our application and next
we have to link this function with this
form tag so in this form tag we will add
onsubmit and in this clys just provide
this function on submit Handler that's
it so whenever we will submit this form
it will execute this function and we
will complete this function after
creating the back end of our application
so now let me just come back to the web
page and you can see we have completed
our result page now let me just come
back to the figma design and you can see
after completing
this result page we have to create this
price plan page correct so to create
this one let me just come
back and in this left side bar we will
come
to by credit. jsx file correct and in
this one we have added
this text called Buy credit so if I come
back to the web browser and here we will
add by in this URL path so it will
display this by credit then then header
and footer correct so just remove this
by creit text here in this div we have
to add some elements so let me just come
back to the figma design again and in
this one you can see first we have to
create this button called our plans then
we have to add this title then we will
display the price plan in three columns
and we have the details of this price
plan in the assets. JS file correct so
just come back and within this div let's
add one
button and in this button we will add
the button
text our plans and after that we'll add
the title in H1
so in this one we will add the text
called choose the
plan now we will add some CSS properties
so first in this div let's add the class
name and here we have to add the minimum
height then we will add text Center then
padding top and margin
bottom after that we'll add the classes
in this button so just add the class
name property for this button we will
add the classes so let's
add border border gray 400 padding X
padding y rounded full and margin bottom
six after that we'll add the class name
in this title so here just add the class
name property and in this one we have to
add text Center then we will increase
the text size 3XL then font medium
margin bottom and margin bottom for
small screen device after adding this
this save the changes and come back to
the web page and here you can see we
have this button our plans then we have
this title choose the plan correct next
we have to display different plans so
just come
back in the left side bar go to assets
assets. JS file and in this one here we
have one aray called plans and here we
have three object correct for three
different plans so we will use this
array to display the plans on our creit
page so here after this title that is
added in the H1 here we will add one new
div so just add the space and here let's
create one
div and uh in this one we have to add
the array so let's
add curly bres we will add the array
that is plans selected from the
suggestion so this plans has
been imported from assets file now on
this one we can use the map method so
just add
dot
map on this map we will add one addo
function and here we will use this a
small
bracket now here in this parameter we
will get individual
item and index
number and in this one we will return
one
div now in this div we have to add the
key property so just add key and
index correct now within this div we
have to add the image so just add the
IMG tag and here let's add
curly
bres assets
dot logo icon so we will add the logo
icon in the
image after that we will add the text in
P tag so let's add the P tag and here we
will
add
item. ID correct after that just
duplicate it and here we will add item
Dot
description correct and uh after that we
have to add the price also so here just
add the P
tag and in this one we have to
add item do price correct then we'll add
the forward slash and here we have to
display credit so just add item. credits
then we will add the
text credits correct after adding this
let's come back to the web page and here
you can see we have three plans
basic Advanced and business correct and
here we are getting 10 for 100 credits
50 for 500 credits let me add the dollar
symbol also so before this item. price
we will add dollar symbol
save the changes now you can see $10 for
100 credits $50 for 500 credits $250 for
5,000
credits here we are getting this lock
icon so let me just correct it yes here
we have added lock icon so instead of
this we will add logo
icon now we have these logo icon correct
if I go to figma design you can see we
have the same logo icon in all plan
correct so so now we have to add the CSS
properties to design the creit page so
after adding this content let's come
back and here we have added this div so
first We'll add the CSS properties in
this div so in this one let's add the
class name and we will provide Flex Flex
WP justify Center Gap six and text left
correct after that here we have this div
for the individual price plan so in this
div we will add the classes so just add
the class
name and we will provide background
white drop sideo small border rounded
large padding Y and padding X then we'll
add text color then we will add the
hover so whenever we will hover on it it
will increase the size then transition
all duration
500 after that we will add the CSS
properties for this P tag and before
that we have to add the width in this
image so in this image we will add the
width that is
40 now in this P tag where we have added
the item ID so let's add the class
name and uh in this one we have to add
some margin from the top and margin from
the bottom then we will add the font
semibold then we have this description
so in this description we will add the
class name
and we will provide text small correct
and after that we have this P tag where
we have added the price right so in this
P
tag let me add the class
name and here just provide margin top
six so it will add a space from the top
after that we have to wrap
this price in a span tag so so let's add
a
span and move this closing tag here
before this forward
slash correct now in this aspan tag we
will add the class name and uh
here let's
add text size 3 XEL and font
medium that's it save the changes and
come back to the web page now you can
see this price is looking good $10 for
100
credits correct after that we have to
add one button in all plans if I go to
figma design you can see we have one
button called get started right so just
come back and uh here after this a span
and
this P tag let me add one button
tag and in this button we will add the
button text called get started
correct now in this one we have to add
the class name so let's add the class
name
property and here let's
provide width full background gray 800
text color will be white margin top then
text a small rounded medium then padding
Y and minimum width correct after adding
this if I come back to the web
page this button looks like this
so let me just correct it here we have
to add the correct spelling
button now you can see it looks perfect
correct next we have to add different
text in this button suppose the user is
already logged in then we have to
display the button text called purchase
and if the user is not logged in then we
will display the text called get started
this one right for that we have to get
the user here in this Buy credit page so
if I open our app context you can see in
this app context we have already created
this user State correct so we can get
the user state from this context file in
this by credit page so before this
return statement let's
add
const curly presses
user and we will get this user
from use
context use context hook and here we
have to provide our
own context file that is app context so
you can see app context has been
imported and this use context has been
imported correct so now we have this
user and based on this user we will
update this button text so here let's
add Cly bres we will use this user we
will add turn operator if the user is
available then we will display the text
called
purchase like this and here we will add
the column so if the user is not
available then what will happen we will
display this get a started text so add
it in this code get started save the
changes come back to the web
page now you can see the text called get
started correct now just come back and
uh from this app context if I make it
pro in this user we will make it
true now you can see here we have the
button text called purchase
correct and if I make it
false or
null then you can see here we have get
started correct so now we have completed
our Buy credit page also after that we
have to create this signin and sign up
component to create that let's come back
to the VSS
code let's open the left side bar and
here we have this components folder so
in this components folder we will create
a new file and write the file name
login. jsx
here we will use RFC
snippet now we have to display this
login form on the complete web page and
there will be a dark layer on the
complete web page so in this div we are
going to add the class
name and in this class name we will
provide the position absolute so it will
be fixed at its position then we will
add left Z Top Z right Z and bottom
zero so it will cover the entire screen
after that we will add the J
index then backdrop blur small so the
background will be blur after that we
will add the background color and the
background color opacity is 30% then we
will add Flex justify Center and item
Center so that when we will add a form
within this div that form will be Ed in
the center of the web
page now within this div we have to add
a form so let's add a form
tag remove this
action now in this form we have to add
three input field that will be for the
user name email and
password but before that we have to add
one title also like sign in or sign up
or I can add the login also so in this
form tag let me add one title in
H1 and in this title let me add the
title
text login or instead of it we will
add sign
up correct and after that we'll add one
text also so let's add the P tag and in
this one we will add this
text so after this title and text we
have to add one div and within that div
we will add the icon and input field so
let's add one
div and within this div first we have to
add one icon so just add the IMG tag in
this SRC we will use the
assets assets is not available so let me
import
that
import assets
from dou
do/ assets SL assets file now from this
assets we can access any icon so let me
add the
icon user uncore
icon after this icon we will add the
input field so I'll add the input type
will be text and in this input field we
will add the placeholder so in the
placeholder we will type full name where
user have to enter their full name after
that we will add
required so this field will be required
to submit the
form after adding this if I save the
changes and come back to the web page
that form is not visible here because we
have not mounted this component so we
have to mount this login component in
this app component so in this app
component we will Mount the login
component so here after this navigation
bar let's
add login selected from the suggestions
so this login component has been
imported
and
let's close this tag so we have mounted
this login component in this app
component and after that if I come back
here you can see we have a background
layer on the complete screen and here in
the center we have the text sign up
welcome back please sign in to continue
and here we have the input field and
that icon is not visual yes it is visual
here it is in light color so we will
change the background color then it it
will be visible clearly now just come
back we will add some CSS
properties and uh let's come back to the
login. jsx file so first let's add the
CSS properties for the form tag so you
can see we have added the form tag here
so in this form tag we will add class
name and in this one we have to add
position relative then background then
we will add the padding then rounded
Excel so that the corners will be round
and after that we'll add text slate 500
that will be the text
color correct and after that we have to
add the classes in the title that we
have added in H1 tag so in this H1 we
will add the class name text Center we
will increase the text size text neutral
700 then font medium after that we will
decrease the size of
this text written in the P tag so here
just add the class name and we will
provide text a small after that we will
add the CSS properties in this div where
we have added the icon and input field
so in this one let's add the class
name and we will provide border padding
X padding y Flex item Center gap of two
pixel rounded full and margin top so
this icon and input field will be
aligned side by side now we have to add
the classes in this input field so in
this one we will add the class
name and here we will provide outline
none and text a small after adding this
save the changes and just come back to
the web
page now you can see we have this title
sign up then we have this text and after
that we have this small icon for user
then we have this text full name correct
that is the placeholder text so we have
added the first input field now we will
add two other input field also so just
come back and uh we will just duplicate
this
div so let me just copy and paste it
again
now in the second one we have to update
the icon so it will
be email icon and in the third one we
will add lock
icon so we have updated the icon and
after that we have to update the
placeholder text so in the second one we
will add the placeholder text called
email ID so here we have the the
placeholder text full name so instead of
that we will add the email ID now in the
next one we will add the placeholder
text called
password and we will also update the
input type so in the second one we will
add the input type
email and uh in the next one let's add
the input type
password correct now just come back to
the web page here we have three input
fields
we have to reduce the Gap so let me just
come back here in the first one we have
added margin top five so instead of that
we will add margin top four in this one
and in the third one also so we have
updated the space from the
top correct and after this input field
we have to add one text so we will add
the P tag and in this one we will add
the text called for password so that
user can click on this link if they
forgot the password now in this P tag we
will add the class name property and
here we have to add some classes so
let's add text a small then text color
that is blue 600 then margin Y and
cursor pointer after that there will be
one button to submit this form so we
will add the button tag and in this
button we have to add the button text so
let me add the button text create
account and in this button we will add
the class name also so just add the
class
name and here we have to provide the
background color for this button and we
will add the width so we have added blue
600 background then width full then text
white and we will add the padding after
that we have added rounded
full so after adding this let's come
back to the web page now you can see
here we have the forgot password and
create account button correct after this
create account button we will add the
message to switch this form from login
to sign up or sign up to login for that
just come back and uh after this button
let's add one P tag so in this P tag we
will add the text called don't have an
account so if you don't have an account
then there will one link for sign up so
just add a span
tag and in this as span tag we will add
the link text called sign
up correct now in this P tag we have to
add the class name and here let's add
the margin from the top and we will add
text
center after that we have to add the
class name in the span tag so here we
have the span tag and in this one we
will add the class name and we will
provide text color then cursor
pointer after adding this if I come back
to the web page here you can see we have
the message don't have an account sign
up correct now we will add one more
message so let's add a space and
duplicate this
line and in this one we will replace the
message so it will be already have an
account
correct and if we already have an
account then there will be a link called
login so we can change the form to
login correct after that if I come back
and you can see now we have two message
don't have an account sign up and there
is another link already have an account
login next we have to create the switch
option so that we can switch between
login and sign up form for that we have
to create one state
variable so let's come back and before
adding that switch let me add one close
icon also using that we can close this
form so here at the end let's add the
IMG tag and in this one we will add the
image from
assets assets
dot cross
icon and for this one one we have to add
the class name so just add the class
name and here we have to provide the
position that will be absolute then top
five right five cursor pointer that's it
save the changes and here you can see we
have a cross icon also that is not
working right now but we will add the
functionality so that when we click here
it will hide this form but before hiding
it let me add the switch option to
switch between login and sign of form so
whenever we will go to login form then
we have to hide this name input field we
have to enter the email ID and password
only to login into the account so there
will be two input field email ID and
password when we will switch to login
form so just come back and at the
top before
this
return here let's add one state aable so
I'll will add
const
estate set
State equal to user State user state has
been imported and here we will add the
initial Estate Value so the initially it
will be in the login
State login
correct now we will use this state to
change the message so let me just call
copy this estate and here you can see we
have added the message called sign up so
instead of sign up we will provide this
a state so let's add curly Braes and
provide a state here that is the state
variable correct after that you can see
here we have this div that is for the
name input field we have added the
placeholder full name so it will be
visible whenever the estate is sign up
or not equal to login so we have to wrap
this div in a clys like this and before
this div we will
add
State not equal
to
login question mark a state not equal to
login and operator so whenever the
estate is not equal to login then this D
will be displayed so after adding this
if I come back to the web page you can
see that name input field has been
removed and here we have the message
called
login correct after that let's come
back and uh here you can see we have a
button and in this button we have added
the message called create account
correct so instead of adding this
message create account we will use the
Turner operator so in this this button
also we will add cly
bres and we will
check state if the estate is equal to
login
then we will add the button text called
login correct and if the estate is not
equal to login then we will add the
button text called create account like
this so we have added this turn operator
after that here also we have two message
so we have to display only one message
based on the estate so let's wrap this
one in a
curlys and here let's add a
state equal
to login so if the estate is equal to
login then we will display this message
sign up correct and here we will add the
colum it means when the estate is not
equal to login then the second paragraph
text will be
displayed so we have added this turn
operator to display different paragraph
text correct save the changes and come
back to the web page now you can see
here we have this login form with email
ID password and login button then we
have this don't have an account sign up
correct so we have the login form so we
can switch from login to sign up using
this link but now we have to add the
functionality in this signup link so let
me just come back and here we have this
a span tag called sign
up correct so in this one we have to add
the click feature
so here let's add on click and in this
one we will add one add function
and here simply add set a state that
Setter function that will change the
estate value and here we will add the
estate called sign
up that's it let me just copy this
one and paste it in this second
paragraph also within this aspan
tag so
here after this class name let's add on
click equal to set a state and here we
will add the state called login so it
will change the state between sign up to
login now just come back and uh right
now you can see we have the login form
and if I click on this sign up link now
you can see the sign up form with three
input field name email and password and
here we have the message already have an
account then login here just click here
so it will open the login form so we can
switch between login and sign up
form next we have to add the
functionality so that when we click on
this cross icon it will hide this login
form and whenever we will click on the
login button it will again display this
login form and right now you can see if
I scroll this web page we are able to
scroll let me just come back to the
homepage right now we are at the
homepage and you can see if I scroll
this we can scroll this web page so we
have to disable the scrolling whenever
this login form is open for that just
come back scroll up before this return
statement and here let's add one use
effect in this one we will add the arrow
[Music]
function and after that we will add the
dependency
aray so this add of function will be
executed whenever the component gets
loaded now in this one we have to
disable the scrolling so here let's add
document. body. style. overflow
hidden and uh here we will
add
return then let's add Aro
function and in this one we will
add document. body. style do overflow
unset so after adding this use effect
Whenever there will be change like Mount
and unmount of this login component then
it will hide the Overflow it mean it
will disable the scrolling and it will
also enable the scrolling so just come
back and you can see right now if I use
the mouse wheel we cannot scroll this
web page because this component is open
this login form is open so we cannot
scroll this web page so we have disabled
the scrolling and whenever we will close
this component and this component will
be unmounted then we will be able to
scroll this web page again so now we
have to add the close and open
functionality for this login form so
just come
back and we have to add one state
variable and we will use that state
variable in different components that's
why we will declare that in the context
file so here we have added the app
context where we will store all our
context variables so here we have
already declared a user state so after
that let me add const so
login and here we will
add set so
login and initialize it with false
so by default this set so login will be
false it means the login form will be
hidden next to use this state and set
function in different component we have
to pass it using this value so let's
copy it and in this one we'll add the
comma and provide this one we will
provide the setter function also that
is set so
login now we can access it in any
component using the
context so let's come back to this
login. jsx again and here we have to get
that so login and set so login from the
context so here let's add const we will
get
set so
login and we will get it
from use context
select it so use context has been
imported and here we have to provide the
context name that
is app context so this app context has
been
imported now we will use this set so
login to disable or hide the login form
so after importing it let's scroll
down and we will come to cross icon so
you can see here we have this
image where we have added the cross icon
so in this image let's add the onclick
property and in this on click we will
add the arrow
function and provide this set so login
and here we will make it
false correct and before that here we
have this form so we have added the
click functionality on this cross icon
and here you can see we have this
login form now just come back and we
will come to app.jsx file and in this
app.jsx file you can see we have mounted
the login component correct now we have
to add the condition for this login
component so here also we need the so
login State variable so we have to get
it from the context so just
add
const CES
so
login and we will get it
from use context Hook and the context
name that is app context now we have the
so login and if this so login is true
then only we have to display this login
component correct so here let's add it
in the clys and we will
add so login
then we will add the end operator so
whenever this so login is true then only
this login component will be mounted now
save the changes and come back to the
web
page right now you can see that login
form is hidden correct now to enable
this login form we have to add the
functionality on this login
button here we have this login button
correct so let's come back and we will
go to navigation bar so here we have the
Navar component and in this Navar
component you can see we have added this
login button here it is so here we have
this login button now on this login
button we have to add the click
functionality that will make the set so
login State true so here also we need
the set so login from the context so you
can see we have already used the context
here we are getting the user from
Context so from this context we will get
the
set so
login now just copy it and here in this
login button we will add the on click
property and add the addo
function and provide this Setter
function and here we will make it true
so that this component that is the login
component will be
visual make it true save the changes and
come back to the web page now you can
see we have the login button and if I
click here it is displaying this login
component and we can switch between
login and sign up
form correct and now if I click on this
cross icon you can see it will hide this
login form correct the login form is
hidden and if I click on the login
button again it is visible and we cannot
scroll this web page and if I click on
cross icon now again we are able to SC
scroll this web page so now we have
created the login component also so now
we have created all the pages and
components for this app next we have to
add the animation for that we will use
the framer
motion to add animation let's open a new
tab and search for framer motion
open this
website then click on quick
start in the left side you can see we
have Js and react so let me click on
react then click on quick
start and here you can see we have the
steps to use the frame and motion in
your react project so scroll down and
here you can see the command npm install
motion just copy it and come back to
your vs code let's open the
terminal and here we have to stop this
project using crl C Y press enter now
use this command npm install motion
press
enter after that again I start the
project using npm run
Dev so our project is running now we can
hide this
terminal and let's see the next step
after completing this npm install motion
let's scroll down and here you can see
the next step is to import motion from
framer motion so you have to import this
Motion in the component where you want
to animate the elements so let me just
copy it and come back to the vs code and
I want to add the animation in header
section so let's open header. jsx file
and in this one here we will add this
statement import motion from framer
motion correct now just come back and
here you can see the next step is to use
this motion component so whenever you
using div component or any HTML element
then in that one you have to add the
motion if you are using div then it will
be motion do D if you are using UL then
it will be motion. UL if you are using
IMG then it will become motion. IMG
correct so let's come back and here you
can see in this header
component we have this div so we have to
add motion. div opening and closing tag
also so if you add the motion. div in
this opening div tag then you have to
add the same thing here in this closing
div tag motion. div so here I have added
one extension you can see in my
extensions we have one Auto rename tag
correct so whenever you will rename the
opening tag it will automatically rename
the closing tag so it makes your work
easy so let's come back and here if I
change the name of this div it means
I'll
add motion. div like this so we have
added motion. div
then it will automatically change my
closing tag you can see it is closing
motion. div done so it makes my work
easy now let's come back and you can see
what we can add further in this motion
component so we can add like this
animation
x00 let's just scroll down we can add
like this animation scale
transition we can add the initial value
animate
here you can see we can add the while
hover what will happen when we will
hover on this
element on H start while tab so we have
different properties for this motion
component let me scroll down here you
can see we have V in view
suppose the component is not visible but
when we scroll the web page then the
component becomes visible so in that
case we we have to add this while in
View and here we have the initials so we
can set the initial value for that
component like in this example you can
see initially the background color is
this one and the opacity is zero but
whenever we will scroll the web page and
this div will come into view then the
opacity will become one and the
background color will be this
one and we can also add the duration
so we will use these properties to
animate our component
so let me close it and just come back to
the vs code and here we have this
motion. div so in this element let's add
a
space and here let's add the initial
value so I'll add initial and here let's
add curly
brushes and initially we will add the
opacity so the opacity will be
0.2 then we will add
y so y will be 100 so initially the
opacity will be less and it will be
moved in the Y AIS then after some
duration like 1 second so here let's add
transition and in this transition we
will add d
so we will provide the duration of 1
second so after 1 second we will add
while in
view opacity 1 and y0 so it will be
visible clearly when we add the opacity
1 and we have added y0 so it will come
back to the original position initially
it will be moved by
100 after that we have to to add
viewport once
true so after adding this if I come back
to the web page and refresh
it now you can see the animation here by
default the opacity was less and it was
moved downwards and when we reload this
web page it comes into view and it moves
up correct and it's come to the original
position with the opacity
100% now now we will add the animation
in this text which is written in this
button right so here we have added this
another div so here we will change it
as motion
DOD correct and in this one also we will
add
the properties so let's copy everything
from here and here let's add a space in
this tag and here we will add the
initial and initially we will add the
opacity
0 and we will add y - 20 and here we
will
add animate so instead of this while in
view we will add animate and here we
will add
y0 and opacity will be
one and let me remove this
transition here you can see the initial
opacity is 0 and Y - 20 then animate
opacity 1 y0 correct and after that here
we will add
transition duration duration I will add
0.8 and here we will add the delay also
so just add
delay
0.2 so you will see this animation after
delay of 0.2
seconds so just come back and refresh
it now you can see we have some delay in
this
animation in this best text to image
generator correct now we will animate
the text that is written here in this H1
tag correct so just come back and here
for this H1 we will
add motion.
H1 now here let's add the
space in this H1 tag and here let's add
initial value so we will add initial
opacity zero correct now we will add the
animate so after animate the opacity
will be one then we will add transition
and here also we will add the delay and
duration 2 seconds correct save the
changes come back to the web page
refresh it now you can see we have some
delay in this animation that is the
title text correct after that we will
add the animation in this description
which is written in the P tag so here in
this P tag we will
add motion
dop and uh here in this P tag with the
motion we will add the properties for
animation so we will add initial opacity
0 y20 animate opacity 1 y 0 so it will
come to original position then we'll add
some DeLay So we are increasing the
delay you can see here we have added
delay 2 4 and 6 and the duration is
0.8 correct after that we'll add the
animation in this button so here in this
button also we will add motion do button
correct and in this button we will add
the properties for
animation so let's
provide while hover scale then while tap
scale then initial opacity zero animate
one then we'll add the transition
default duration. 5 opacity delay point8
duration 1 that's it after that if I
come
back refresh it now you can see we have
animation in the button also and you can
see the size increases when we take
cursor over this button or when we click
here it is also increasing the size
correct so it is happening because of
this framer motion now we will add the
animation on this div where we have
added all the images and we will add the
animation on individual image also so
just come back and here we have
this div right so in this div let's add
M.D now here let's add some properties
for the animation so we will provide
initial value then animate and
transition so we have provided initial
opacity zero animate opacity 1
transition delay one and duration one
after that we will add the motion in
this IMG tag so just add
motion do
IMG and uh here let's add V hover so
while hover we will add a scale and
duration that's it after that scroll
down and here we have another text in P
tag so in this one also we will add the
animation so just add
motion
dop and uh here we will add the
animation
properties so initially the opacity will
be zero then opacity 1 and we will add
the delay and
like this save the changes come back to
the web page Let me refresh it and you
can see we have the animation in all the
contents from this text this button this
image it looks
beautiful after that we have to add the
click feature on this button so that
when we click here either it will open a
login page or it will redirect us to the
result page suppose you user is already
logged in then it will redirect us to
the login page and if the user is not
logged in then it will open a login form
for that just come back and here you can
see we have added this button right
generate images correct so here we have
this button so on this button we have to
add the on click
property and in this on click we will
add one Handler function so let me add
the function on click Handler
and we have to declare this function so
scroll up and here before this return
statement we will add one function so
just add const on click Handler and it
will be one add function now in this one
we have to check whether the user is
already logged in or logged out and
based on that we have to redirect the
user on result page or we will open the
login form so for that we have to get
the user status and set so login from
the context so here let's add const we
will get the user and we will also get
set so
login and we will get it from Context so
just add use
context and provide the app
context now we can check we will
add
if if the user is available then what
will happen we will navigate the user on
result page for that we have to use the
use navigate hook so here just add
const
navigate equal to use
navigate and now we will use this
navigate function
here here we have to provide the path so
just add the path
result correct now we will add the else
condition it means when the user is not
logged in then it will open a login form
so here we have added this Setter
function so just add this Setter
function and we will make it
true that's it so after that if I come
back to the web page you can see here we
have these text and button so if I click
on this button it will open a login form
we can close it like this if I click
again it will open the loog form and if
the user is already logged in then it
will redirect the user on the result
page now let's scroll down and here we
have the other section that is steps so
we will add the animation in this steps
section so just come back to the vs code
and we will open a steps. jsx file and
uh in this one scroll
up here you can see we have this div so
in this div we have to add the animation
so first we have to use the import
statement so here let's
add import motion from framer motion
correct now in this div we will rename
the tag so just add motion. div now
after that we can use the animation
properties so here we will change the
initial value and value while in the
view so here just add initial capacity 2
and Y 100 so when we will scroll the we
page and we will and this element will
come to the view then the opacity will
be one and it will come to the original
position and here we will add the
duration of one then we put once true
now save the changes and come back to
the web page scroll up and you can see
here we have the header section and
whenever we will scroll the web page and
come to our a steps section then only
the animation will start let's
see now you can see when I scroll to the
web page then only the animation starts
and this steps section comes with some
animation correct now we'll add the
animation in this description section so
just come back and let me close
it close this headed also and here we
have this description. jsx file
here also we will add the import
statement so let's
add import motion from frame or motion
correct and after that in this div we
will
add motion. div and here we will add the
animation properties so in this one we
will add initial value then we will add
the transition then we will add while in
View and we
put one
true like this save the changes after
that we will add the animation in the
next section so after this description
let's see here we have this testimonial
section so just come back and we will
open testimonials so let me just copy it
and open testimonials.
jsx scroll up and here we will
add motion. div and here we'll add the
anim
properties and in this one we will add
initial then we will add transition
while in View and viewport once true and
after that we have to add the import
statement also so just add
import motion from framer
motion correct after that you can see we
have the another section that is this
one see the magic and this button so
here we we have created one component
called generate bn. jsx let's open it
and here also we will add the import
statement correct and in this one we
will add the motion in this
div motion. div and here also we will
add
the animation properties so here let me
add initial
then transition
then viewport so after adding this let's
come back and you can see if I scroll
the web
page all the contents are coming with
some
animation correct now we have to add the
click feature on this button which is
generate images so we have already added
the click feature on this button
generate images in the header so we have
to use the same thing in this one also
so let's come
back and uh let me just open header
again header. jsx is here so in this one
you can see we have added this and let's
copy it and we will come
to generate BTN and before this return
statement just add
this one we will get the user and set so
login from the use context app context
so we have to import this so just add
use context use context has been
imported then we will import this app
context so just add app context so app
context has been imported correct after
that we have to import this use navigate
so let me add use navigate so use
navigate has been imported corre
next we have to link this on click
Handler with the button that's it so
scroll down and here we have this button
correct so in this button where is the
button tag here so within this or let me
add it here only after this button we
will add on click and in this one we
will provide this onclick Handler
function that's it save the changes come
back to the web page
if I click here it should open the login
form but it is not visible and the
scrolling is disabled it is not visible
because the login form is at the top so
let me just come back and here we have
this login component so let's add
position
fixed save the changes and now you can
see this login form is visible if I
close it and click on this button again
again it is visible now we can aut
scroll the web page and if I close it it
is hidden correct and here also it
works it works with this login button
also
correct so we have added the animation
on this
homepage next let me just go to the
result page so just
add/ result so this is the result page
and here also we have to add the
animation so let's come back and we will
open
result. jsx
file and in this result. jsx first we
have to add the import statement to
import the motion from framer motion
like this after that here we have this
form so in this form we have to add the
animation so just
add motion.
form correct and in this motion. form we
have to add the animation properties so
here we will add the initial value
transition while in View and viewport
that we have already used in other
elements so we have added initial
opacity
100 transition duration 1 opacity 1 y 0
VIP put one's true so we have added the
animation for this one also after that
we have to add the animation
in credit page so let me click here so
it will open this credit page right so
in this one we have to add
the animation so let's come
back we will open by credit. jsx file
and here also we will add the import
statement so first we have to
import motion from framer motion correct
after that here we have this D
so in this div we will
add motion. div and we will add the
animation properties so we will add the
same thing initial transition while in
View and view
Port save the changes let's come
back now you can see this page is also
animated next we have to add the
animation in the login form for that
just come back and and we will open
login. jsx
file and in this one we have to add the
import statement first so here we will
add import
motion from framer motion correct after
that I scroll down and here you can see
we have this form tag correct so in this
form let's
add motion.
form then we will add add the animation
properties so here also we will add the
same thing but we will change the values
so just add initial transition while in
view viewport and here we will add the
duration of 3 and opacity is2 y50 and y0
correct save the changes and come back
to the web
page now if I open this
login form you can see this login form
comes with smooth animation let me close
it and click on this login button again
you can see the animation let me go to
home
page click on this button you can see
this login form comes with smooth
animation so now we have added the
animation also on our website so now we
have completed the front end part of our
application next we will add the back
end and using the back end we will add
the functional to login and register
users on this application and we will
also add the functionality to generate
the images using
AI so let's come back to the vs code
editor and here we have the left side
bar where you can see the client folder
let me collapse it and here let's right
click and select new folder and here in
this one we will create a folder called
server so now in this image F folder
that is our project folder here we have
a client folder and server folder and in
This Server folder we will create the
backend server of our
application now right click on this
server folder and select open in
integrated
terminal so in this terminal you can see
we are at server folder correct now here
in the left side bar in This Server
folder we will create a file so right
click and select new file and write the
file name
server.js so we have created this
server.js file after that in this
terminal let's add npm in
it then press
enter now it is asking for the package
name so the package name will be folder
name which is server so just press enter
nothing else
after that keep on pressing
enter the entry point will be
server.js by default it is added simply
press
enter again
enter now you can see in the left
sidebar in This Server folder we have a
file called package.json so in this
package.json you can see we have a
script
start node server.js and here we have
test script so let me just remove this
test script from here so whenever we
will type npm run a start in the
terminal then it will execute this node
server.js correct now in this one we are
going to use the import statement so
here we have to add the type
so in this one let's add double quote
type and here we will add type is equal
to
module like this save the changes and
after that let's come to this terminal
again and in this terminal we have to
install some packages for our backend
server so in the back end we will create
the app using Express package so let's
add npm
hi that is for install and here we will
install multiple packages so the first
one is
Express then we will add
course that will allow us to connect the
backend server with our front end next
we will install EnV using that we can
create EnV file and use it in the
backend
server so just add Dot e and
V Next we will install node modon
package using this package it will
restart the backend server whenever we
will make any changes in the code
file after that we will
add form
data then we will add Json web
token using that we will add the
authentication in our project
after that we will add
using this package we will connect
our backend server with mongod DV
database next we will add
exos it will help us to make the API
call after that we will add bcrypt
package using that we can encrypt the
password after that we will
add razor pay using this razor pay we
will add the online payment Gateway so
we have added these packages just press
enter so it will install all these
packages now all packages has been
installed let me hide this
terminal and in
the package.json file you can see here
we have the dependencies and in this one
you can see all the packages that we
have just installed
correct now just close this and
uh here in this server folder we will
create EnV file where we will store all
the secret keys and API keys so right
click on the server folder select a new
file and write the file name
EnV so in this one we will store the
secret keys
now in this server.js file we will
create a simple Express app for that
let's
add
import Express
from Express
package after that we will also import
course
from course
package we will
import do P
nv/
config after adding this UT let's add
the port number where we will run the
express app so just add
const Port equal to process.
EnV
dot Port so if the port number is
available in the environment then it
will use the port number from there or
or if it is not
available then we will use the or
operator and here we will add the port
number 4,000 after that we will add
const app and create the app
using
Express after that we have to add
the course in this Express app so here
let's
add app do use so we are using the
middle Wares in this Express app so we
are adding
app.use
course and before that we will also add
one more middleware that is Json so just
add
app.use
express.
Json so all the request will be passed
using Json method after that here we
will add
app
do get
method and here just provide the path
and here we will add one Arrow
function and in this parameter we will
take request and
response correct now here we will return
response dot
send and we will will send one message
called API
working correct so whenever we will hit
this path on the back end then it will
send this message Api working correct
next we have to start the express app
for that just add app do
listen here we have created this app so
in this one we are using app. listen and
here first we have to provide the Port
so let's add the port here after that we
will add addo
function and this Aro function will
return console.
log and here we will add one message
that will be displayed in the
terminal because we are using the
console.log in backend server so it will
display the message in terminal so here
let's add the message
server running on
Port then we will add the port
number so let's add
Plus Port that's it after adding this
save the changes so let's open the
terminal and in this terminal you can
see we are at server folder so here just
add npm run a start then press enter
now you can see this message server
running on
Port but it is not giving the port
number so let me check
it here we have to move this bracket
here after this
port correct save the changes and next
we have to stop this server using contrl
C yes and again I started using npm Run
start now you can see the message server
running on Port 4,000 correct so once
you see this message just open the web
browser and go to new tab and here we
will
type Local
Host colon
4,000 it is still loading it's not
opening so let's come back to the vs
code here we have used
app.use course so after this of course
we have to add this small bracket like
this just correct this line save the
changes and start the back end again so
crl
C yes
and again use npm Run
start server running on Port 4,000 just
come back yes it is working now you can
see on this URL Local Host colon 4,000
we are getting the message Api working
so now our simple Express app is working
at this URL so this is our backend URL
Local Host Port
4,000 correct now just come
back
and you can see whenever we make any
changes we have to stop and start the
backend server so to solve this one
let's come back to the package. Json
file and in this
one here we have one script for a start
correct so after that let's add one
comma and here we will add another
script so let's add the script name
server and here we will provide double
quote
node
server.js so it is not node here we have
to add node modon so we have already
installed the node modon package so we
can use nodon
server.js so whenever we will type npm
run server it will execute this command
nodon server.js correct so now let's
come back to the terminal and stop this
project using contrl C yes and now we
can use
npm
run
server we have added npm run server and
press
enter so again you can see the same
message server running on Port 4,000 and
if I come back to the browser this
backend server is working we are getting
the message Api working correct now if I
come back to
the server.js file and and if I make any
changes here
so instead of API working let's add API
working
fine so we have updated this message Api
working fine now you can see this
changes will reflect on the backend
server so just come back and you can see
if I refresh it we are getting API
working fine so we don't have to restart
the backend server when we are using
nodemon
correct so let's come back and make it
API working
only now we have to connect our project
with mongod DV so that we can store the
users data in the database for that we
have to create a mongod DB Atlas account
so let's open browser open a new tab and
search
for
mongodb or we will search for mongodb
Atlas correct now open this
website here just click on sign
in and here you have to create an
account you can click on this sign up
button and create your account using
email ID or you can also use the Google
account so I'll use the Google account
to sign in in my existing account
on this mongod DB Atlas just click on
create a
cluster here we have to choose
the server so I'm going to use this m0
that is a free server correct so we are
using this free
version here it is giving cluster zero
so let's keep it default so we have
three options AWS Google Cloud Aur so
let's select Google Cloud
here you have to select the nearest
reason so I'll select Mumbai now just
click on this create deployment
button now it is giving the username and
here we can create the password for our
database so the username is greatest tag
I will keep the username greatest Tack
and in the password I will
type greatest tack 1 2 3 never use at
theate symbol in this
password after that just click on
this create database
user now just click on this button
choose a connection
method here we will select this
Compass now select this option I have
mongod DB Compass installed just click
here here is taking some time so just
wait for 10 to 15 seconds
now it is displaying the mongodb
connection URL so let me just copy
it just click here to copy so here we
have the username and here we have the
password if you toggle this option so it
will display the password like this so
instead of this you have to provide your
password so let me just enable my
password and copy this string that's it
now click on this button done
and come back to the vs
code in this one just open EnV file and
in this one we will store the mongod DB
connection URI so here let's
add envirment
variable mongod DV UI and in the double
quote paste this string now at the end
you can see here we have forward slash
so remove this forward slash from here
correct so you can see we have added
this complete
URL like this in the double quote we
don't have the forward slash at the end
and here we have the username of our
database and this is the password that
we have created for the
database that's it save the changes now
just come back to the mongod DB Atlas
again and here we have to add the IP
address so let's come here and in
this network access in the left side bar
just click
here and in this one you can see it is
displaying my current IP address so let
me just delete it and here we will click
on ADD IP
address and click on this button allow
access from anywhere just click here so
it will add this entry
0.0.0.0 now just click on confirm button
so now you can see this
000000 IP has been added so that we can
connect our mongod DV database from any
IP address so you can see the status is
pending now it is active so now we can
connect the mongod DV Atlas database
with our Express app so let's close it
and come back to the vs
code and here in the left side bar we
have the server folder so in this folder
we will create a new folder called
config in this config folder let's
create a new file so write the file name
mongod db.
JS so here we will add the code to
connect the project with mongod DB
database so first we have to import
so just add
import from Mongo's package
correct after that we will create one
function
const connect DB that is connect
database it will be one async function
so just add asnc and add a
function now in this one we have to add
await do
connect and in this one we have to
provide our mongod DB connection URI so
we have already stored this mongodb
connection u in the envirment variable
so we will get it from the envirment
variable so here just add back Tex so we
can use the template literal so in this
one we have added the back Tex then
dollar sign and cly
bres and in this one we will add process
do EnV
dot involvement variable name that is
this one mongod dvore URI so just place
it
here correct now after this URI we have
to provide the database name so our
project name is imagify so after this
curly veres simply add forward slash
then write the project
name imagify
let me expand it so you can see in one
line we have
added doc connect and provided the
connection URL and at the end we have
provided slash and project name
imagy that's it now here we have to add
one event also so before this line let's
add
one event mongus
dot connection Dot
on so it will get the connection event
so here just
add connected so whenever the database
will be connected then this function
will be
executed so in this function we will
display one message so just add
console. log and here let's print one
message called database connected
correct so what will happen whenever the
database will be connected then this
event will be executed and whenever this
event will be occurred then this
function will be executed and it will
display this message database connected
in the terminal next we have to export
this connect DB function so that we can
use it in the other files so just add
export
default and function name connect DB
that's it now we can use this function
in server.js file so let's open
server.js file and here we have to
import that so here let's
add
import connect DV from single code. SL
config SL mongod dev. JS we have to
write the complete path with file name
extension mongod db. JS correct now we
have this connect DV function here in
this server.js file so just we have to
call this function so we will call it
here after this app.use just add
await and call this function connect DV
so it will connect our Express app with
the the mongod DV
database that's
it now if I come back to the
terminal so let me open the
terminal and now you can see in this
terminal we are getting the message
database connected and after that we are
getting the message server running on
Port 4,000 so it says our Express app is
connected with the
database so after connecting our project
with the database next we have to create
the schema and models for the DB
database so that we can store the users
information and other information on the
mongod DB
database for that here in the left side
bar we will create one folder called
Model So In This Server folder right
click and select new
folder and the folder name will be
models so using this models we will
store the data in the mongod DV database
so we have to store two types of data so
the first one will be user data and the
second one will be transaction data so
first let's create the models for user
data so in this models folder create a
new file with the name user model. Js
now in this user model. JS let's
add
import from
package now we have to create the user a
schema so just add
const user
schema equal to
new do
schema now in this one we have to define
the structure of our data that we will
store in the database so first we will
store the user name then we will store
the email password and we will also
store the credit balance for the users
so let's add
name and for this name let's provide
some properties so here we will provide
the type so for this data we will
provide the
type and the type will be string
now this data will be required to save
the data in the database so just add
required
true
correct now just add the comma and here
we will add the second data that is
email this will be the users's
email here we will add the type that is
a string and it is also required
like this and this email should be
unique so here we will add one more
property
unique and it will be
true so we cannot store any new user
with the same email
ID after that we have to store the
password so let's add
password and here we will add the same
thing type is equal to a string
and required true correct and after that
we will store the credit balance so
let's add the property createit balance
and the type will be number and the
default value will be
five correct so now we have created the
schema Now using this schema we will
create the user model so here just add
const
user
model equal to do
model and here we have to provide the
model name that will be
user then we have to provide the schema
that is user schema so using this schema
it will create a model with the name
user correct now what will happen it
will try to create the user model again
and again right so to solve this one
here let's add do
models right and here we will provide
dot
user then we will add the r
operator so what will happen first it
will search for the existing models
where the name is user right so if the
user model is already available then it
will use that user model if it is not
available then it will create the new
user model using this schema let me add
the spelling here user model correct
next we have to export this user model
so that we can use in any other file so
let's add
export
default user
model correct Now using this user model
we will create different apis and using
that user can create an account user can
login into existing account account and
user can log out from the account so
let's open this sidebar and here in this
server folder we will create a new
folder called
controllers in this controllers folder
we will create a new file called user
controller.js where we will create
different controller function for
user registration user login and user
log out so first we'll create the
controller function for registration for
that we need the user model so first
we'll import user model from user model.
JS file just write the file name
extension
also after that we have to
import
the
bcrypt so using the bcrypt we will
encrypt the password so just add
import bcrypt from
bcrypt correct after that we will add
the
import and we will import
JWT from Json web
token and using this JWT we will create
a token for user Authentication
so after adding this here let's add
const and we will add a controller
function so just add the function name
register
user now we will create one asynchronous
function so just add
async and create the arrow
function and in this parameter we will
take
request and response
correct now we will add the TR catch
block now in this try block we will find
the name email ID and password right so
to create an account we need the users's
name email ID and password and we will
get all these information from the
request body correct so just add
const
name email and password
then we will add request dot
body so from request body we will find
the name email and password next we will
check whether the name email and
password is available or not so just add
if and we will add not name it means the
name is not available
or not of
email so if the email is not available
or we will add not of
password so if the password is not
provided in any of this condition what
will happen we will return one response
so just add
return response and we will send the
response using
Json and here just add one object with
the success property false
then we will add the message also so
just add
message and here we will add the message
called missing details either email is
missing or name is missing or password
is
missing so if any of this is missing
then it will return this response with
success fails and the message is missing
details right now if all three things
are available then we will proceed for
the next step so the next step is to
encrypt the password that is given by
the user so here just add const and here
we will add one
salt is equal to
await and here we will add
bcrypt dot gen
salt here we will use 10 so it will add
the moderate encryption if we'll
increase the value it will be more
secure password but it will take more
time also so after that we will
add
const and here we will get the encrypted
password or hased password so just
add hased
password equal to
await bcrypt do has
and we will has the password that user
has provided in the body so just add the
original password then we will provide
the salt so with this password and salt
we will get one hased password correct
now we can store this has password in
the database correct so next we have to
create
one object where we will store all the
users data that will be stored in the
database so just add
const and we will add the user
data equal to one object so in this one
we will store the name that is available
in the body then we will store the email
it is also available in the body then we
will add password and in this password
we have to store the encrypted password
or hashed password
like
this correct so we have added three
properties name email and password so
now we have the user data next we have
to save this user data in the mongod DV
database so here let's add
const new
user is equal to
new user
model and in this user model we will
provide this data
correct so as you can see in this user
model we have added name email and
password then createit balance so we are
providing the name email and password
only because for this creit balance we
have already added the default value
five so let's come back to this page you
can see we are storing this data name
email and password and the by default
the credit Balance 5 will be added in
this new user
correct now we have the new user just
save this user in the database so just
add const user is equal to
await new user do save
method that's it so it will save a new
user in the database and we will get
that user here in this variable correct
now we will generate one token that will
be sent in the response so that we can
enable the login and registration in the
front end so here let's add
const token to generate this token we
will use JWT that is Json web token so
just add JWT we have already imported it
here right now here just add JWT do
sign and here we have to add the ID so
let's add ID and we will get the ID from
this user so whenever the user will be
created in the database it will
automatically generate one ID with the
property underscore ID so here let's
add user
doore ID that is autogenerated in the
mongod DV database so the ID will be
unique so using this unique data we will
generate one token and with this ID we
need one more thing so this will be
the
first argument and here we will add one
more so just add comma and here we have
to provide one secret key so we will
declare this secret key in the
environment variable so let me just come
back to the EnV file and here let's
add JW T secret equal to and uh here let
me add secret has text you can add
anything that's it now just come back
and here we will use that secret from
the EnV file so in this one we will add
process. EnV Dot and the variable name
that is JWT Secret place it
here like this so now we have this token
correct next we have to send this token
in the response so till now what
happened we have created a user data
from the response and in this user data
we have stored the encrypted password
now using this data we have created a
new user in the database correct now in
the database for this user one unique ID
will be generated so you using that
unique ID and our secret string we have
generated one token using this JWT sign
method now we will send this token in
the response so just add response.
Json and here we will send one object so
here let's add one success property that
is
true correct after that we will send
this token
also right now we will send
the user and in this user property we
will add the name only so let's add
name is equal
to user do
name so in the response we are sending
the Success Through then token and then
we are providing the user object and in
this user object there will be one
property called name
right now if any error occurs in the tri
block then this catch block will be
executed so in this catch block let's
add console log. error so it will
display the error message in the backend
terminal after that we will generate the
response also so just add response dot
Json and here also we will add one
object and in this object we have to add
SU Su and the success will be
false correct then we will add the
message also so let's add the
message and in this message let's add
this
error error do message from this error
object it will find the error
message that's it so now we have created
one registered user controller function
after creating this user
controller function next we will create
the user login controller function so
let's scroll
down and here let's add const login
user and it is also one asnc function so
just add as
sync and create the arrow
function here also we will add request
and
response now in this one just add the TR
catch
block now in this Tri block we will find
the email ID and password from the
request body because for user login we
need only email ID and password so let's
add
const email and
password and we will get it from
request do
body correct
now we have to find the user using this
email ID because the email ID is unique
so here let's add
const and user equal to
await to find the user we are going to
use the user model you can see we have
created the user model so using this
user model we have created user in the
database and to find the user we have to
use this user model only so here let's
add
await user model
dot find one method and in this one we
will provide
the email right so it will find the user
with this email ID provided by the user
from the request body correct so now we
will check if the user is available with
this email ID or not so let's add the if
condition and we will type not of user
so if the user is not available with
this email ID then what will happen we
will generate one response with success
Falls so here just
add
return
response and let me just copy the
response message from
here this one and paste it
here so return response success false
and in the message we will type user
does not
exist correct so if the user is not
available then we will return the
response with message user does not
exist suppose the user is available so
let's proceed for the next step so the
next step is to match the password so
here just add
const is match
is equal
to
await and here we will use
bcrypt and in this one we will
add compare
method so this bcrypt do compared will
compare the saved password and the
password provided by the request so just
add the password that is provided in the
request and here we will compare it with
the password say saved in the database
for this user so let's add
user do
password so if the password is matching
then this is match will be true if it is
not matching then it will be false so
here let's check
if AG match is
true then we will generate one message
with the success true and if it is is
not matching then we will add else
condition and here we will generate one
response with success false so let me
add this statement here return response
success false and in the message we will
type invalid
credentials like this and if it is
matching then here what will happen here
we have to generate one token and we
will send this token in the response so
to generate the token here we have
already used this sign method so just
copy
this and copy this one
also and here in this if statement let's
add cost token is equal to JWT do sign
ID is equal to user do ID right then
we'll add process do
env. JWT secret so it will generate the
token using the ID stored in the user
right so after generating the token it
will send the response so here we have
added response. Json and the success
will be true then we will send the token
and with this token we will send the
user's name also so we have sent the
user object and in this object we have
sent the name with the user.name
right so now we have created the
controller function but here we have the
catch block also so if any error occurs
in the tri block then the catch block
will be executed so just copy the
statement from the previous catch block
and paste it
here console.log error response. Json
success false and the message is error.
message so now we have created the
controller function for user login and
user
registration after that we have to
create the API so here in the left side
bar in This Server folder create a new
folder with the name
routes now in this routes folder we will
create a new file so right click and
select new file and the file name will
be user route
user
routes.js
now in this user routes.js we need that
controller function so let's add
import register user
and login user and we will import it
from double
do/ controllers
folder and user
controller.js file
correct so we have imported the
controller function that is register
user and login user and before that we
have to
import
Express from
Express correct now we have to create
the router so we will add
const user
router equal to express
dot
router correct now in this user router
we have to create the
endpoint and we have to provide the
controller function at that endpoint so
let's add user router dot post we will
use the post method and here we have to
provide the endpoint path it will be
registered like this and at this path it
will execute the controller function
that is registered user correct now just
duplicate it here also we will use user
router. poost method and it will be
login and here we will
use here we will use login user
controller function right after that we
have to export this router so at the end
we will add export
default and provide this user router
correct now we will add this user router
in our Express app so let's open
server.js file and in this one here
before this one let's add app.
use and here we have to add the path so
we will add SL API slash
user and at this path we will add the
router that is user router so we will
select it from the suggestion so this
user router has been
imported so we have added app.use API /
user and user
router after adding this what happens
whenever we will type the backend Ur
that is the Local Host Port 4000 then /
API / user and slash this register then
it will hit the register API endpoint
let me write it
here like
this Local Host colon
4,000 then slash this one/ API SL
user and after that we'll add
SL
register so whenever we will hit this
end point then it will execute this
registered user controller function and
whenever we will hit the another
endpoint that is this one login then it
will hit this endpoint and it will
execute this login user controller
function that will allow us to login
right so now we will test these
API so to test it we need one tool
called Postman so let's open web
browser and here we will search for
Postman
download open this link post man.com
downloads click here to download this
one after downloading just execute this
setup
file after that it is asking for the
sign up so let me sign up using my
account now we are at the postman tool
let me change the appearance so I'll
click on this gear icon or settings icon
then select settings from here I'll
select themes here it is showing the day
theme is active so let me click on this
button manual now select this
dark that's it close this popup now we
will create the collection so just click
on this plus icon so it will create a
new
collection and here we will use this
rest API
basic now click on this plus icon and
select blank
collection now just click on this
button here we will add the name imagify
now click on this link add a
request here in this field we have to
add the endpoint URL so you can see we
have already added it here so let me
just copy this register
endpoint and we will past it
here
HTTP Local Host 4,000 SL API SL
userregister and here we have to select
the method so the method will be post
correct now in this body we have to send
the name email ID and
password so in this body let me select
this
raw and here we will add one object and
here let's add name greatest
tag then we will add the
email greatest td@ gmail.com
then we will add the
password and in the password let me add
one 2 3 4 5
6 here we have to add it in a
string right after that just click on
this send button so here it is giving
some error right so let me just come
back to the vs code open the terminal
and in this terminal we are getting some
error user controller.js file does not
provide an export
named login user so let me check that we
will go to user
controller and uh scroll down yes we
have to export this one you can see we
have added user registered right and
this login user so we have to export it
from here so just add
export curly presses and we will add
register user and login user now we have
exported this controller function from
here after that just come back
again and click on the send
button now you can see we are getting
the status 200 okay right and in this
response we are getting success true
then we are getting the token and here
we have the
user and the username is greatest
tag correct so let me verify it with the
database also so if I come back to the
web browser and come to this mongodb
Atlas then click on this
clusters now click on this browse
collections
so in this one you can see we have one
database with the name imagify that is
our project name and in this imagify we
have the users collection so in this
users collection we have one entry you
can see we have one user called greatest
tack the email ID is greatest tack D at
Gmail and this is the encrypted password
and you can see the credit balance has
been added that is five so we have added
the default value for the credit balance
so this user registration API is working
fine right now let's test the user login
API so just come back and come to this
Postman and from here let me remove this
register and instead of that we'll add
login that is the
endpoint so we have added / API SL user
/ login and in this body we have to send
only email ID and password so remove
this name property and we are sending
the email ID and password so first let
me add the different email ID so I'll
add greatest tack Dev 1@gmail.com and
click on the send
button now you can see the response it
is giving false success is false and the
message is rest is not a function so
let's see the login API come back here
user controller and uh this login
controller function so in this one we
have used res right so here instead of
this res we will add rest do Json it
means response. Json and let's check
other code also here also we will add
response.
Json now it is correct correct let me
check the previous
code it is correct here we have used
response. Json now everything is correct
now just come back and again click on
the send
button and this time you are getting the
correct message that is user does not
exist in this response because we have
added the incorrect email ID now if I
provide the correct email ID like
greatest T Dev at gmail
that is the correct email
ID and now we will add the incorrect
password like this 1 2 3 4 5 6 7 8 that
is the incorrect password and click on
this send
button now you can see the message
success fals and the message is invalid
credentials because we have provided the
incorrect password now what happens when
we provide the correct password so here
let's provide the correct password 1 2 3
4 5 6 and click on this send
button now you can see we are getting
success true and it is generating the
token so we are getting the token also
in the response and we are getting the
name greatest tack correct so this login
and registration API is successfully
working next we have to create the API
for the user credit so let's come back
to the vs code editor
to create the user credit API first we
have to create the controller function
so in this file user
controller.js after this controller
function which is login
user here we will add a new controller
function so just add const and the
function name is user credits and it
will be asynchronous Aro function so
just add async and create the Aro
function
in this parameter we will take request
and
response and within this function first
we will add the try catch block now we
need the user ID to get the credit of
the particular user so we will add
const user
ID we will add it in curly
Braes equal
to request
do
body so here we have added the user ID
that we will get from request. body but
we will not send the user ID from the
body instead of that we will add one
middle Weare that will find the user ID
from the token and that will add the
user ID in the body so we have to create
that middleware
also so let me complete this controller
function first then we'll create the
middle whereare so here we have to find
the user using this user ID so we will
add
con user equal
to
await and we will find the user from
user model so just add user model dot
find by
ID and in this one we have to provide
this user ID correct so after getting
the user data next we will return one
response so just
add response dot
Json and here we will return one object
so in this object we will add the
success property that will be
true and after that we will add credit
so let's
add credits and in this credits property
let's add the this
user and here we will add
Dot credit balance in this user model
you can see we have added the property
called credit balance so we will add it
here user do credit
balance so in this response we will also
send the user's name so we will add
user and it will be one object and in
this object we will add the name and the
name will be be user.name
so in this response we will get the
user's name success true and we will get
the users
credits if any error occurs in this triy
block then the catch block will be
executed so let me add the same
statement in this cetch block also so we
will add console log error. message and
response. Json success fals and message
error do
message so we have added the controller
function for user
credits now in this user credits we need
the user ID in the body right and we
will provide the user ID in the body
using the middleware so in the left side
bar in This Server folder let's create a
folder called middle Wares
in this middleware folder we will create
a new file and the file name is
.js in this .js file we have to find the
user ID using the Json web token so
first we will import
JWT and we will import it from Json web
token right after that we'll create the
middleware function so we'll add
const user
o as sync and in this one we will get
request
response and after that we will add the
next so whenever the success will be
true then we will call the next method
that will execute the control
function so this middle we will be
executed before the controller function
whenever we will hit the API so in this
one we have to find
the token so first let's create this add
function and in this AR function we have
to find the token so we will add
const
token equal to
request dot
headers so in the header the token will
be added and we will find the token in
this middleware now from this token we
have to find the users's ID so here we
will
check if this token is not available so
we will add not of
token so in that case what will happen
we will generate one response so let's
right return response. Json success
Falls and the message will be not
authorized login again because the token
is not available right but if the token
is available then we will go for the
next step so here let's add the TR catch
block now in this Tri block we will
add
const and we will add the token decode
equal to
JWT do
verify and in this one we have to
provide this token that we are getting
from the headers and we will verify it
using the secret key that we have stored
in the involment variable to get that
secret key from the involment variable
we will add
process.
EnV do JW T
secret correct so now we have the
decoded token and in this decoded token
there will be one ID because we have
created the token using the ID right so
from this decoded token we will find the
ID and here we will add if token
decode do ID if this ID is available
then we will attach this ID in the
request
body with the user ID property so we
will add request do body and in this
body we will add one property called
user
ID and in this user ID we will provide
this decode do ID that's it so the user
ID will be added in request
body and here we will add the else
condition also suppose this ID is not
available now in this Elsa statement we
have to return one response so let me
add return response. Json success Falls
and the message is not authorized login
again suppose this ID is not available
then we will get the response success
fails and the message is not authorized
login
again and after that we have to call the
next method
so this next method will execute the
controller function that will return the
users's credit now if any error occurs
in the tri block then the catch block
will be executed so in this catch block
let me add
the response so just add response. Json
success false and the message is error.
message that's it so now we have created
the user o middleware that will find the
user ID from the token and it will add
that user ID in the request body so
after that we have to export this user o
middleware so just add
export
default user or after creating this
middleware let me just come back to the
user controller.js file again and here
we have created this user credits so we
have to export this one also so we will
add the comma and user credits so we
have exported this user credits
controller function next we have to
create the API endpoint so from the left
side bar let's open user routes.js
and in this one we will create one more
route so let me just duplicate this
line and in this one we will provide the
path so inste of this login let me add
credits
and here we have added
this login user controller function so
instead of that we will add user credits
controller function so user credits
controller function has been imported
here correct after adding this we can
hit the URL that is/ API SL user SL
credits then it will return the users
credit so now we have created this end
point and in this one we have added user
credits controller function but to
execute this user credits controller
function we need the user ID and to get
the user ID we need the middleware so
here before this one we have to add the
middle Weare so let's add comma and we
will
add user or so the user or has been
imported from this middle wees
.js file so we have imported this
middleware and added this middleware in
this endp point that is/ credits that's
it save the changes now we can test this
API end point that will return the
users's credit so to test it we will
come back to the postman
again and in this one we will create a
new request so just click on this plus
icon and here we have to select the post
method and in this one we have to
provide the
URL and it will be/ API SL user SL
credits and if I simply click on this
send button now we are getting the
message not authorized login again
because we have not provided the token
now let's provide the token in the
headers so from this request let me just
copy this
token this token will be generated
whenever we are logged in so just copy
this token and uh come here and in this
headers we will
add token and we will provide this value
here now again click on the send button
here we are getting the message cannot
read properties of null reading credit
balance so let me just find where is the
error if I come to user controller you
can see we are adding user ID from body
and in this
middleware we are adding this user ID in
the body but here we have added capital
D so let me make it a small D user ID
here and in this controller function
also you can see we have added the same
thing user ID with a small D save the
changes come back and now if I click on
this send button here here we have added
the
token and if I click on send button here
we are getting success true credits five
and the user object and in this user
object we have the name property and the
name is greatest tag so now we have
successfully created and tested the user
credits API that is returning the credit
balance of the particular user and to
get the credit balance we have to add
the token in the request headers after
after creating this user credits API
next we have to create the API to
generate the image using prompt so let's
come back to the vs code editor and here
we have created the controllers folder
so in this controllers folder we will
create a new file called image
controller.js now in this file we will
add One controller function so just add
const generate
image equal to a
sync and in this parameter we will take
request and
response and we will create this Aro
function we have to export this function
so simply add the export
keyword before this const correct now in
this one we will add the TR catch block
so we will add TR catch and in this
catch block we will add the statement
that will display the error message in
the console and will also return
the response so just add console.log
error. message and in the response we
will send success
fals message will be error. message
right now in this Tri block we will add
the logic to to generate the image using
prompt so in this Tri block let's add
const and cly presses here we need the
user
ID and we need the
prompt and we will get it
from request.
body so in the body we will send the
prompt but we will send the
user ID using the token and the token
will be converted into user ID using the
middleware and that will be added in
this body so we will find that user ID
and prompt in this Tri block after that
we have to find the user using this user
ID so to fetch the user we will add
const user is equal to await and we will
find the user using the user model
right we will add find by ID and just
provide this user
ID now we will check whether we have
this user or not so here let's add
if not user if the user is not available
or the prompt is not available so we'll
add not of prompt if any of this is
missing then we will return the response
so just add
return
response dot
Json and here we will send one object
with success
false and we will add the message
missing
details that's it so if the user is not
available or the prompt is not available
then we will send the response with the
success false and message is missing
details
suppose The Prompt is also available and
the user is also available then we will
check the user's
balance if the credit balance is zero or
less than zero then we will send the
response like no credit balance so we
cannot generate the image when the
balance is zero or less than that so
here we will add the if condition and in
this one we will
add user Dot credit
balance so if the user do credit balance
is equal
to0 or user
model do credit balance is less than
zero so in that case we will generate
the response so we will add
return
response.
Json and here we will send one object
with success false and we will add the
message no credit balance and with that
we will send the credit balance also so
to send the credit balance we will add
user. credit
balance that's it so if the user is not
available or prompt is not available
then this message will be sent in the
response if the balance is zero then
this message will be sent no credit
balance it will be sent in the response
if the balance is greater than Z
then we have to generate the image using
the API provided by clip drop so let me
search for clip drop on
Google so open a new tab and search for
clip
drop open this website clipd drop.
Co here you have to create an account so
let me click here and I will choose this
continue with Google option
on this clip drop website just click on
API here we have to create an account so
just click on this link sign in and here
we have to enter the email ID so let me
add the email
ID then click on this
button so it will send one email on your
email ID so let me check my email so
here we have received one email and here
we have a link sign in to clip drop API
so let's click on this
link and here we are getting the user ID
email ID and you can see the credit is
zero right but we can claim 100 free
credit so just click on this button
claim my 100 free
credits here we have to provide the name
and phone number so let me add the
name and here we will add the phone
number now just click on this claim my
credits after adding the OTP you will
get 100 free credits that is enough to
build and test this
application now we have to generate the
API key so just click on this reveal API
key button
so now the API key has been generated so
let me just copy this API key and we
will paste it in the envirment variables
so let's come back and open EnV file and
here let's
add clip drop
API and paste it in single or double
quote so we have added clip drop API in
the environment variable
after that here we will come back to the
same website and click on this
docs in this one you can see we have the
option called text to image in the left
side bar just click here and here scroll
down and you will find this URL so we
have to hit this URL to generate the
image using the prompt and in the post
method we have to send the data that is
the prompt data in this form data so to
generate the image using prompt we have
to hit this API end point this one and
we have to make the post request and in
this post request the prompt is
required right and we have to provide
this prompt in the multi-art form data
so we have to create the multiart form
data in that when we will add The Prompt
and we will make post request to this
API end point now in the response we
will get the
image and scroll
down here we have the option called
JavaScript so you can see in the request
we have to send the headers and in the
headers we have to send X API key and in
this API key we have to provide the API
key that we have added in the
environment variable so first we have to
create the multi-art form data that we
will send in the API request so just
come back to the VSS code and in this
image controller
function here we have to create the
multiart form data so we will add
const form data equal
to new
and we will use form
data let's scroll up and here we have to
import the form data so we will add
import form
data
from form data package we have already
installed this package while creating
the backend application right so now we
have this form data and using this form
data we will create this form data
variable right now in this variable we
have to append The Prompt so here we
will add this braet and after that we
will
add form
data do append
method and in this one we have to append
The Prompt so just
add
prompt comma and we will get get the
prompt from this
one just copy it and paste it here now
we have created the form data next we
have to send this form data on the API
so let's come back and copy the API end
point that is
here just copy and come back and here we
will make the API request for that we
will use the exos so we will add a wait
exos so you can see the exos has been
imported right now in this one we have
to make the post method so just add exos
do
post and here we will provide the API
end point this one and after that we'll
add the comma and we will provide the
form
data right again add the comma and here
we will add the curly
bres and in this one we have to provide
the headers as you can see
here this one so just copy this
headers add it here and in this headers
we have this x API key and here we have
to provide the API key so our API key is
stored in the environment variable so we
will add
process. EnV
dot clip drop
API now we have provided the clip drop
API key and here we have to add the
response type so we will
add response type and the response type
will be
arrayer like
this so now we have made the API call
and we will store the response here so
we will add
const CES data so in this data we will
store the response from this API call
right and now in this data we will get
the response as add a buffer and using
that add a buffer we have to convert the
image to base 64 so here let's add
const base 64 image
equal
to
buffer do
from and provide the
data and provide
binary and here we will make it as a
string so we will add two a
string and in this two a string method
we will provide base
64 and using this base 64 image we have
to generate the image URL so we will add
con result
image equal to we will add the back Tex
so that we can use the template literal
in this one we'll add data colum
image/
PNG colum base
64 comma we will add the dollar sign and
curly
bres and in this one we will provide
this base 64 image so now we have the
result image here now we have to send
this result image in the response and
before that we have to deduct the users
credit so first let's deduct the user
credit because we have already generated
the image so one credit will be deducted
so we will add await
user
model dot find by ID and update and in
this one we have to provide the user ID
so we will add user
doore ID correct then we will provide
CES here we will add creit
balance and in this credit balance we
have to update the balance so we will
add user
do credit balance minus
one like this so the users credit
balance will be reduced by one after
that we have to send the response so we
will
add response dot
Json and here we will add the object in
this object we will add the success
property that will be
true after that we will add the message
that will be image
generated next we have to send the
credit so we will add credit balance and
the credit balance will be user do
credit balance minus one right now we'll
add the comma and here we will send the
result image also we will
add result image so we will send the
result image in the response correct so
now we have have created
the controller function that will take
the prompt and it will generate the
image using that prompt and the
generated image will be sent in the
response that we can display on our
front end right next we have to create
the API Endo using this controller
function so just copy this controller
function and in the left side word you
can see here we have routes folder so in
this routes folder we will create a new
file
called image routes.js
in this one let's
add import Express from
Express after that we have to import the
image generate function so we will add
import
CES generate image that we have just
created we will import it from
double
do/ controller
SL image
controller.js right after that we have
to add router so just add
const image
router equal to
Express dot
router so we have created one router
using this express. router now in this
router we have to add the path and we
will provide the controller function so
that we can create the API end point so
we will add image router and here we
will use the post
method now in this one we will provide
the path so it will be SL generate image
so this is the API Endo generate image
after that we'll add the
generate image controller
function but if I come back to the
generate image controller function here
you can see we need the user ID from the
body so we will provide the user ID
using the middle Weare so here again
come back to the image routes and before
this one we will add the middle Weare so
we will add the
comma and here we will
add you user or middleware so this user
or middleware has been imported and we
have added this user or middleware that
will add the user ID in the body and
after that it will execute this generate
image controller function next we have
to export this router so here let's add
export
default and image
router that's it next we have to use
this image router in the server.js file
so let's open server.js file and let me
just duplicate this
line right and here we will add/ API SL
image right and here we will add the
router that
is image router so the image router has
been imported
correct so now we have added the
complete API Endo that that is/ API SL
image and
slash generate image correct after
adding this we have to test this API end
point so to test this API again open the
postman and here we will click on this
plus
icon right now in this one let's add
post method and provide the URL here we
will add/ API SL
image/ generate
image this one if I come back here you
can see we have generate image so we are
using the same end point / API SL image/
generate image correct now we have to
add the prompt in the body so in this
body let's add raw and here we will add
the object we will add
prompt and in this prompt let's add
flying
cat right now in this headers we have to
provide the
token and in this token we will provide
this token so let me just copy it and
paste it
here so in the headers we have provided
the token and in this body we have added
prompt after that if I click on this
send button here we have some error let
me come back to the VSS code and open
the terminal scroll down and here we
have some error in this terminal so
let's see cannot find module user model
that is imported from this image
controller.js so to fix this one let's
open image
controller.js and in this one you can
see we have added import user model from
models folder user model so here we have
to add the file name extension that is
user model.
JS add this save the changes and let me
hide this terminal and come back to the
postman and click on this send button
again so here we are getting the
response and in this response we are
getting success true message image
generated then we have the credit
balance for because the one credit has
been reduced for generating one image
then we have the result image and here
we have
this link so we can use this data to
display the image on our front end after
that if I come back to the database so
let's open this mongod DB database and
click on this refresh
button so now you can see the credit
balance has been reduced it is four
correct so now we have created the API
to generate the image so till now we
have created the API for user login
registration then we have created the
API for finding the users available
credit balance then we have created the
API for generating the image using
prompt now we will link these API with
our front
end to connect our backend apis with our
front end just come back to the vs code
editor and let me close all these
files and collapse This Server folder
right now expand this client
folder where we have added the front end
and in this one you can see we have
added the SRC and here we have the
context and app context. jsx file right
now in this one we have to get the
backend URL so we will store the backend
URL in the envirment variable so in this
client folder right click and select a
new file and here we will add the file
name
Dov right now in this environment
variable we will store the backend URL
so if I come back to the web
browser so you can see our back end is
running on this link Local Host Port
4,000 so just come back and here we will
add V
underscore backend
URL and add this URL in single or double
quote remove this forward slash at the
end so there will be no forward slash at
the end so we have added V backend URL
in this envirment variable after that we
will open app. context. jsx file and in
this one we will store the backend URL
in one variable so that we can access it
in any component so in this file
here before this
value let's
add
const backend URL is equal to import do
meta do
EnV
dot V backend
URL so we have added the backend URL in
this variable next we have to pass this
backend URL in other component so we
will provide it in this value object so
just add comma and provide this backend
URL in this
value right after that we have to add
the token State variable so that we can
store the token in the local storage and
we can also get the token from the local
storage and in that token variable we
will store the token generated from the
API so that we can enable the login and
registration featured on this
application so here let's add
const and we will add the state variable
name called token
and the setter function name will be set
token here we will use user
State and here we will initialize the
value using local storage of the web
browser so we will add local storage dot
get item and in this one we will provide
the key name that is token so if there
is any token available in the browser
local storage that will be stored in
this estate
variable so here we have the user then
we have the so login then we have this
token estate after that we will add one
more state that is credit so we will add
cost credit and we'll will
add set
credit is equal to use a
state and we will add
false after creating these State
variables we have to pass it through
value object so that we can access it in
any component so let's add it in this
value object we will add the comma and
paste it token and set token then again
add comma and we will pass this credit
and set
credit right save the changes next we
will add the login and registration
functionality for that let's
open components and go to login. jsx
file and in this one we will add the
functionality for login and registration
so in this one you can see we have added
different input fields for name email ID
and password so we have to store these
values in a state variable for that we
will create three state variable with
the name name email and password so
let's start with first variable here we
will
add
const
name set
name is equal to user state
and initialize it with empty string
let's duplicate it and here we will add
email it will be set
email now duplicate it this will be
password and it will be set
password right now we have to link these
state with the input Fields so scroll
down
and here we have this first input field
that is for the full name right so in
this one we will add the onchange
property like this and in this one we
will add
event and create the arrow
function and here we will use the seter
function that is set
name and in this one we have to provide
the value from this input field for that
we will add e do Target dot
value after that we have to provide the
value property so after this curly bres
let's add a space and we will add the
value property and in this one we will
add name State like this now let me just
copy this one and we will paste it in
this second input field that is for the
email so paste this on change and value
and here we will add set
email and here we will add e. target.
value and it will be
email now in the third one that is that
is for the password input field let's
add this on change just copy and paste
it and here we will add set password
and in this value we will provide
password now whenever we will enter
anything in these input field that data
will be stored in these State variable
right so now we have to pass this name
email and password on our API to create
an account and if you want to log to the
existing account then you have to pass
only email and password correct so now
we will create the function that will
either create an account or it will
login to the existing account for that
here in this
form it's
here we have this form tag so in this
form we have to add the onsubmit
property we will
add unsubmit and here we will add one
Handler function so we will add
on submit
Handler next we have to declare this on
submit Handler function so scroll up and
before this use effect let's add a
space and here we will create this on
submit Handler function so we will add
const function name and it will be as
synchronous function because here we
will add the API call here we will get
the
event and now we will use this event to
prevent the default functionality so we
will add e do prevent
default so after adding this it will
prevent the web page from reloading
whenever we will submit the
form after that we will add the TR catch
block for the API call so just add the
TR catch and in this one first we will
check for the estate here we have have
the estate so if the estate is login
then we will call the login API and if
the estate is sign up then we will
create the user registration API so here
in this Tri block let's
add if statement and we will add state
if the estate is equal to
login then what will happen we have to
call the login API so for calling the
API we will use the exos so we will add
await
exuse let me check whether we have added
the exos package or not so if I go
to package.json
in this
dependencies you can see we have the
motion react react Tom and react router
Dom so we don't have AOS here so we have
to install the AOS right
so let's close it and we will open the
terminal so this is the terminal for
backend server and if I click
here now it is the terminal for front
end so first we have have to stop it so
just add crl C yes now we will add
npm
install
exos after installing the xos package
here we can use await
xos dot post
method and we have to import this exos
in this file so scroll
up here we will
add import exos
from exos
package now here we will add exos dopost
method and in this post method we have
to provide the backend URL so our
backend URL is available in the context
file so we have already imported this
data from the context so in this one
only we will
add backend URL so the backend URL will
be imported from the context and we can
use it in this post method now in this
backend URL we have to provide the
complete path of the user login API so
we will concatenate the remaining path
so we will add slash API slash user
slash login that is the login end
point now in this one we have to provide
the email and password so we will add
the comma and we will add one object and
in this one we will pass
email comma
password right for the for the login we
need only email and
password after that we will get one
response so we will store that response
here we will add
con C lies
data so in this data we will get the
response next we will check for the
response so here let's add if statement
and in this one we'll check if the data
dot
success is true if the data. success is
true it means we are successfully logged
in so after login what we have to do we
have to get the token from the response
and we will set the token available in
this app context here we have added
token and set token so in this one we
have to find the set token using this
app
context now just copy it and here in
this if statement we will add set token
and provide
data.
token because we are getting the token
in the response after
login after that we have to set the user
also so here we have to get the user
from the context so we will
add set
user if I come back here you can see we
have set user which is null right so we
have added this yes so we have added
this set user in this login. jsx file
and here after adding the token we will
add set
user and in this one we will add data.
user correct after that we have to store
the token in the browser's local storage
for that we will add local storage
dot set item and provide the key name
token then provide our token that we are
getting from the response we will add
data dot
token next we have to hide the login
form so to hide the login form we will
use this set so login and we will make
it false so that the login form will be
hidden that's
it so if the data. success is true these
code will be executed but if the data.
success is false then we'll add the else
condition and here we will add one error
message and we will display the error
message in a toast notification so to
display the toast notification we need
a toasttify package so if I come back to
the web
browser and open a new tab and search
for
react toasttify open this
website so here we have the command to
install react toasttify in application
so just come back and open the
terminal here we are in the client
folder right so we have to WR contrl C
it is already stopped so here we will
just add npmi react toasttify press
enter
after that we will
add npm run Dev so it will again a start
our
project so our project is running on
this Local Host
5173 hide this
terminal now you can see the next step
to add this notification so we have
added
this npm install that will install the D
T5 package and after that we have to use
this import a statement
so just copy
it and come back to the app.jsx
file so in the client folder we will
open
app.jsx and here let's add this import
statement we have added
import toast
container and from here just remove this
toast it is not required and here we
have added import react toy. CSS correct
after that we have to add this toast
container component here in this return
so in this return we have this div so
before this navigation bar let's add a
space and we'll add opening tag toast
container and close this tag in this
toast container we can add the position
also so we will add the position and it
will will be bottom
right so the notification will be
displayed in the bottom right
side correct after that we will open
login. jsx file and here if I want to
add the toast notification then we can
simply
add toast click here so you can see the
toast has been imported from react
toasttify then we will add add the error
type so toast.
error and in this one we will add
data Dot
message so if any error occurs or if the
data do success is false then one eror
will be displayed in toast
notification so we have added the
functionality for login in this if
statement right so this if statement is
checking if the estate is login then
this code will be executed but if the
estate is not equal to login it means
the estate is sign up in that case we
have to call the registration API it
means the user registration
API right so here we will add the else
condition for this if
statement so we will add
else and here we will make the API call
so again copy this
one or let me just copy
everything from here we will copy
this and paste it here in this else
statement now in this else statement we
will add con data await exos dopost
backend URL and here we have to change
the API endpoint it will be / API SL
user SL
register register for the user
registration API endpoint right and for
the registration we have to send the
email password and we have to send the
name also so we will add name comma
email comma password right after that we
will get the response in this data and
we will check if the data. success is
true then we will set the token then we
will set the user and then we will set
the local
storage using this data token and we
will set so login false so it will hide
the registration page or login page
after that if this data. success is
false then the error message will be
displayed in the
notification to. error is equal to data.
message so now we have added the
functionality for this user login and
registration now if any error occurs in
this Tri block then this catch block
will be executed so in this catch block
simply add this toast.
error is it toast.
error error do
message that's it after adding this
let's come back to the web
page and we will open our
homepage and here if I click on this
login button it is opening this login
form right now let's create a new
account so just click on this sign up
button and here we will add the
name
abinas and after that we'll add the
email ID so let's add the email ID
here after that we will add the
password and click on this create
account
now you can see our account has been
created and we are logged in that's why
we are getting this navigation
bar with profile icon log out option and
this credit and this text right now
these text are a static so we have to
get this credit and this username from
the API and we will display it in the
navigation bar correct so for that let's
come back
and in
this app context. jsx
file here we have added this credit
right so we have to find the credit
using the
API to get the credit we will create a
function so
here before this
value let's
add const
load Credit Data or load credits
data equal to asnc
function and to get the credit we have
to call the API so we will add the TR
catch block and in this catch block we
will add
the
statement console.log error and toast.
error error. message so to get this
toast. error we have to import this
toast so let's select it from here so
this toast has been imported from react
toasttify
right now here in this Tri block we will
call the credits API and we will store
the data in this data variable so we
will add
const CES data
is equal to a
wait and we will use the
xos and in this xuse we will use the get
method and we have to import this xos
also so here scroll up and we'll
add
import exos
from exos package and in this one we are
using this get method so let me just
come back to the backend folder again
and uh in the server folder we have
created this routes and in this routes
we have the user routes.js so you can
see here we have added the post method
for user credits so let me change it I
will add get that's
it so we will add the get method now in
this load create this data we will call
the API using this get
method now in this one we have to
provide the backend URL so just
add backend URL and in this one we will
concatenate the end point so we will add
forward SL API
sluser SL
credits after that we will add the comma
and here we will add one object and in
this object we will add headers
and in this headers we have to provide
the token so we will add one object and
here just add token that's it so now we
will get the response in this data after
that we will check the response so we
will add if statement and we will check
if data dot
success is true if this data. success is
true
then we will set the credit so just add
set credit and here we will
provide data do
credits after that we will set the user
also so we will add set
user and it will be data do
user so we have added this function that
will load the the data from the API next
we have to execute this function so to
execute this function we will use use
effect so before this value let's
add use
effect select it from here so use effect
will be imported from react now in this
use effect we will add one Aro
function and we will add the dependency
array
and in this dependency are we will add
token so that whenever the token will be
changed then this addo function will be
executed so here just add the if
statement and it will check if token is
available right so if the token is true
then it will call this function that is
load credits
data so it will load the credits
data next we have to pass this load
credits data in this value object so
that we can access it in any other
component
also so we have added it here save the
changes and after adding this load
credits data we need to add one more
functionality that is log out so that
user can log out from the account so let
me add that feature also we will add
cons log out is equal to Aro
function and here we will add local
storage
dot remove
item and it will remove the item with
the key name
token after that it will set the
token with mt
string then we will set the user set
user it will be null
now we have to pass this log out
function also so here in this value
object we will add this log out save the
changes and now let's come back to
the nav bar. jsx file so in this nav
bar. jsx file you can see here we have
this user set so login now in this one
we need the log out function so just add
log out we will get it from App context
right after that we need the credit so
just
add
credit and here we have the user and set
so login that's it now using this credit
we will display the credit in the
navigation bar button and we will also
display the users's name using this
user after that we will link this log
out function with the button so scroll
down and uh here
you can see we have this credit left so
here instead of adding this value 50 we
will add curly braces we will add credit
State that's it after that here we have
this log out button so in this Li tag we
will
add on click and in this on click we
will provide this log out function
after that if I come here in this P tag
here we have added the name manually so
let me remove this name and here we will
add curly bres and we will
use
user.name
so we will get the name from the user
state after adding this if I come back
to the web
page and refresh this and click on this
login
here we will login with existing account
so let's
add we have added the name then we will
add the
password and click on this login button
so now we are successfully logged in and
here we have this name right and this
credit is not displaying here and let's
see this log out option we will click
here now we are logged out so this log
out feature is working registration is
working and login is working but the
credit was not displayed so let me login
again so let's see what's the error with
this
credit let's open login. jsx file and
here you can see we have added this
local storage. G get item so insteed of
this get item it will
be set item local storage do set item
token and here also we will add this
local storage set
item that's it save the changes and come
back to the web browser login
again still this cre is not displaying
so let me just come
back and in this app context. jsx file I
have added data do success but this
spelling is incorrect so we will correct
data do
success if it is true then set credit
and set
user save the changes and again come
back to the web page now you can see
here we are getting the credit left five
correct and here we have the users's
name and if I click on this log out
button we will be logged out from this
account so now we are logged out now
let's try to login with different
account so we will click on the login
button again and here we will add the
first account that is user. gr@
gmail.com then we will add the password
and click on login
button here it says user does not exist
so let's collect it user
dot user. creest
tack let me check the database refresh
it so here we have this email ID
greatest td@ gmail.com
so let me add this email ID in the login
form and click on the login
button now we are logged in and here we
are getting the available creit for and
here we have this name greatest tag
correct because in
this user data you can see the name is
greatest tag and this is the email and
here we have the credit balance for
correct so now we have added the the
login and log out functionality on this
application and we have displayed the
available credit also correct next we
have to add the functionality to
generate the image using prompt for that
we have to create a function that will
call the image generate API so let's
come back and we will come to app
context. jsx file and in this
one after this load credits data here we
will create another function we will add
const generate
image equal to a
sync and create the arrow
function and in this one we will take
the parameter
prompt because to generate the image we
need the prompt now in this one we have
to make the API call so we will use the
try catch
statement and here in this catch block
we will add
the error message in the notification so
just add toast.
error and we will add error do
message the toast has been imported here
right now now in this Tri block we will
call the image generate API that we have
created in our back end so let's add a
wait and we will use the
exos and here we will use the post
method and here let's add the backend
URL and in this backend URL we have to
concatenate the API end point so just
add/ API slash
image
slash generate
image we have already tested this API
right so we are so we are calling this
API and in this one we have to send the
prompt so after this API end point just
add the comma and add the CES and in
this one we will provide
prompt correct after that we'll add
comma and here we'll add one object and
in this one we will pass the
headers and in this headers we will
provide
token after that we will store the
response in one variable so just add
con calies data so we will store the
response in this data next we will check
this data so we will add the if
statement and here we will check if the
the data
dot success is
true in that case we will load the
credit so here you can see we have added
this load credits
data so that after generating the image
it will again display the avable
credit then we will
add return so it will return the result
image so we will add return data
dot result
image that we are getting from the API
response here we will add the elsea
statement also so if the data do success
is false in that case we will
add toast.
error and here we will display the error
message that we are getting from the API
response so just add data do
message after that again we will call
this load Credit
Data and here we will check
if
this
data
Dot credit
balance if this data do credit balance
is equal to zero if this credit balance
is zero then the user will be redirected
to the Buy credit page so to redirect
user on the Buy credit page we will use
the navigate function for that
here before this function let's add
const navigate is equal to use navigate
hook correct now just copy this navigate
and uh here in this if statement if the
data do credit balance is zero then we
will redirect the user on the Buy credit
page so just add navigate function and
we will provide the path that is
slash
by that's it after that let's come back
to the web
page after that we have to call this
generate image function whenever we will
click on the button so let's come back
to the result
page so here we have the result. jsx
file right so in this one we have to get
that function before that we have to
pass this function using this value
object so in this value object let's add
this function that we have just created
generate image now we can access this
function in any component correct after
that let's open result. jsx
file in this one we have to get the
function from the app context so here
let's
add
const generate
image equal
to use context use context has been
imported and here we will add the app
context this app context has been
imported right after importing it here
we we have this onsubmit Handler
function so this function will be
executed whenever we will submit the
form where we will add the prompt in the
input field and click on the submit
button then this on submit Handler will
be executed so in this one let's add
event dot prevent default so it will
disable the page reloading whenever we
will submit the form after that we have
to set the loading State true so just
add set
loading this set loading is already
available here right so we will make the
set loading
true correct after that we'll add if
statement and we'll check if the input
is available it means we have some
prompt in the input field so if the
input is available then we will add
const
image and we will we will add a weit and
we will call the generate image function
so just use this generate image function
here and in this one we have to provide
the prompt that is this input so we have
provided the input in this generate
image function so we will get the image
here right after that we will add if
statement and here we will check if the
image is available right then what will
happen we will set the image so just add
set image
loaded we will make it
true and after that we'll add set
image and here we will provide the image
that we are getting from the
response so the image will be added in
this state variable and we will set the
image loaded true after that we have
to disable the loading right so here
let's add
set loading
false that's
it after adding this let's come back to
the web
browser and we are already logged in now
just click on this generate image button
so it will open this page here we have
the default image and here if I write
any prompt so let me
write White
cat playing with
apple click on generate
button here it says request failed with
a status code for not
for
so let's check
it let's go to app context and uh
scroll up where we have added the
function for Generate
image here it is so in this one you can
see we have added the incorrect path so
it will be/
API SL image SL API SL image/ generate
image collect this API endpoint path
save the changes again come back now
let's add the prompt again
white cat playing with apple and click
on generate button now you can see this
loading
right and after loading you can see we
have the image generated according to
our
prompt correct now we can click on this
button to download this image so let me
click here so this image has been
downloaded right let me click here so
this image will be displayed
so you can see we have downloaded this
image that is generated using
AI now you can see the credit has been
reduced here we have the credit left
three correct here we have the button
called generate another so it will again
open this input field where we can type
another prompt and we can also go to
homepage and scroll down here also we
have this button so if I click on this
button it will again open this result
page right so here let's type another
prompt we will
add black cat flying and click on the
generate
button now you can see this
loading and after generating the image
the loading text is hidden and here we
have one image that is generated using
AI using our prompt so this image
generator is working fine and the credit
has been reduced you can see the credit
left two and if I go to database refresh
it and now you can see here we have the
credit balance to correct now let me
make it zero here we will make it
zero click on
update and refresh this
website now you can see the credit is
zero correct now if I enter any prompt
here we will
add white flying cat and click on this
generate
button now you can see this notification
no credit balance right because the
credit balance is zero and we are
redirected to the Buy credit
page so next we have to add the payment
Gateway on this application so that we
can purchase more credit to generate
images here I'm am going to use the
Razer pay payment gway that is very
popular in India for online payment
method but if you want to use a stripe
payment gway then you can check out the
source code link provided in the
description where I will provide both
Razer pay and a stripe payment
integration now to add the Razer pay
payment getaway in this project first
let's open the razerpay website so come
to this website Razer pay.com and here
you have to create an account so just
click on this sign up button and here
you have to provide your phone number or
email ID and click on this continue
button then complete your profile and
after completing your profile you will
come to the Razer pay dashboard and from
there you can copy the Reser pay secret
key and rer pay key ID so you have to
copy two things Razer pay key ID and
Razer pay key secret from the razor pay
dashboard so I have already generated
the razor pay key ID and secret that I
will use in this project so let me just
come back to the vs code and let's close
all these
files and from this left side bar we
will open This Server folder that is our
backend in this one we will open
controllers and go to user
controller and in this user controller
file we have to create a controller
function to initialize the razor pay
payment Gateway but before that we have
to store the secret key and secret ID in
this EnV file so let's open EnV file in
this backend and here let's add
envirment variable name Razer pay key ID
and here you have to store the Razer pay
key ID after that we have to store the
Razer pay key secret so just add the
variable name Razer pay key secret and
store the secret key here after that we
have to store the currency so we will
add currency and in this currency we
will add
INR because I have created my res page
pay account in India so I'm adding the
Indian currency INR and let me provide
the key
ID and key
secret so here I have provided this
razor pay key ID and key secret and
currency after that let's come back to
the user controller.js file and here we
will create the controller function but
before that we have to initialize the
razor pay so first we have to import the
Reser pay so just scroll up and here we
will
add
import RoR pay
from RoR pay we will add it in code
after that here we will
add
const razor pay instance
and we will create the instance using
the razor pay so we will add
new razor pay
and to create this razor pay instance we
have to provide the key ID and secret
key so just
add key ID property and in this one we
have to get the key ID that we have
stored in the environment variable so we
will get it from environment variable
just add
process dot
EnV Dot and the variable name is Razor
pay key ID correct let's add comma and
here we will add
the second property that is key secret
and here also we will add the value from
involement variable so just add this
process. EnV
Dot and the variable name Razer pay key
secret so just add it
here that's
it so we have added this Razer pay
instance now we will add the controller
function so we can make the Razer pay
payment so just add
con and the function name is payment
Razer
pay equal to a
sync and here we will get request and
response in this one we will add the TR
catch
block and in this catch block let me
add console
log and provide this
error after that we will add
response do Json
and in this response we will send one
object with success
fals and in the message we will add eror
do
message like this now we will add the
logic in this Tri block so in this one
first we need the user ID and the plan
ID for making the reserve pay payment
right so here let's add
const cly
say user
ID right next we need the plan
ID and we will get it
from request. body so we will
add request do body
after that we have to find the user
using this user ID for that we will add
const user data is equal to
await then we will use the user model to
find the
user user model do find by ID and here
just provide this user
ID correct now we have this user data so
here we will add one if statement that
will check whether the user data is
available or not and we will also check
whether the plan ID is available or not
so we'll add if
statement and here let's
add not of user if the user is not
available
or this plan ID is not
available so if any of this is missing
then we will add return
and here we will add the response so
let's copy this response paste it here
response. Json success false and in the
message we will add missing
details so let's add this
message missing details right now
suppose we have the user ID also and
plan ID also so in that case we will
create
some variables where we will store the
credit plan amount and date so here
let's add
let
credits then we'll add plan then we will
add amount and then we will add
date so in any transaction we will store
the credit and the plan name or plan ID
then we will store the amount and date
correct
now here we are creating the controller
function and in this controller function
we will get different plan right because
we have created three plans on our web
page if I come back and here you can see
we are getting basic Advanced and
business plan so we have to add the
switch statement that is switch case
statement so here we will
add switch case and here we will add the
plan ID
so we are getting this plan ID from this
request body correct So based on this
plan ID we will
add different plan credit and amount so
in this plan ID there will be three
condition like basic Advanced and
business and in the basic we will get
100 credit and the amount is $10 in the
advanced it will add 500 credit and the
amount is
$50 and in this business we have the
5,000 credits and the cost is
$250 correct so we have to add it in the
switch case statement so just come back
and here in this first case we will add
the plan ID that is
basic and in this basic plan we have to
add
the plan
basic credits 100 and amount 10 so in
this credits we will add 100 plan will
be basic and the amount will be 10 for
the first case right now let me just
duplicate this
one and here we will add
the second case that is
Advanced and in this one we will add the
plan name Advanced and the credit will
be 500 and the amount will be be 50 now
again duplicate
it and this will be the third case and
here we will
add business here also we will add
business plan and here let's add the
credit 5,000 and the amount is
250
correct now in this default we will add
return statement so let's add
return response.
Json and here we will return one object
so in this object we will add success
false and we will add the message plan
not found so if the plan is not equal to
basic Advanced or business then it will
return the response with message plan
not found and the success will be false
right
so now we have the credits plan and
amount for the transaction next we need
the date right so here after
this switch case let's
add date and in this one we will
store date do
now so it will store the current date
time
stamp right after that using
this variables we have to create one
object that will store all the
transaction data right so here let's add
const we will add transaction
data and it will be one object and in
this object we will store user ID
then we will store the
plan then we will store
amount then we will store
credits and we will also store the
date so now we have this transaction
data next we have to store this
transaction data in the mongod DB
database so to store this transaction
data in mongod TV database we need to
create one model so in the left side bar
we have the models folder and in this
one we'll create a new model file so
let's right click on this models folder
select new file and here we will
add transaction model do
JS and in this one we have to add the
mongod DB model so let me just copy the
model from user model let me just copy
everything from here and paste it in
this transaction model and here we will
update the name so let me update the
name like transaction schema right and
here we will
add transaction
model like
this and we will use this transaction
schema here
and the model name will be
transaction correct let me remove
everything from here so you can see here
we have created the transaction schema
using new do schema and using this
schema we are creating one transaction
model and uh here we will
add
transaction so first it will search for
the model with the name transaction if
it is not available then it will create
one model with this name transaction
using this transaction schema right and
after that we have to export this
transaction model using this export
default so we will export it here now in
this one we have to define the schema so
you can see we have added this
transaction data where we have the user
ID plan amount credits and date so we
have to store these things in the
database so in this schema let's
add user
ID and in this user ID we will add the
type so the type will be a
string correct after that we have to add
the required so the user ID will be
required to store any transaction so
just
add required
true correct let's add the comma and
duplicate this line here we will add
plan so this plan is also a string type
and the required will be true now
duplicate it here we will add
amount and in this one we will add the
type
number and it is also required true now
let's add one more line and here we will
add
credits and the type will be number
required true after that we'll add the
payment so just add
payment and the type will be Boolean
and here we will add the default value
so just
add default and the default value will
be false so here we have added the type
bullan so it can be either true or false
after that we need to add one more
property that is
date that will be the transaction date
so here we will just add the
type so the typee will be
numbered that's it so here we have
created this transaction schema and
using this schema we have created the
transaction model and the transaction
model is exported from this file so we
can access this transaction model in any
file and we can store the data using
this transaction model so let's come
back here in this user controller and in
this
one here we will
add
con new
transaction is equal to a
weit then we will add transaction model
that we have just created so this
transaction model is not coming in the
suggestion so we have to import it
so let's scroll
up and here we will
add import transaction model
from Models
folder transac model. JS file so now we
have imported this transaction model and
here we will use it to store the data in
the database so we'll add await
transaction model dot create
and in this one we have to provide the
transaction data that we have added here
so just add this transaction data so it
will store this transaction data in the
mongod DB
database so now we have this transaction
data that is stored in the mongod DB
database after that we have to create
one order using razor pay so to create
the order here we will add
await we will use the razor pay
instance dot
orders dot
create and in this create we have to
provide one
options and then we'll add
one Arrow
function and in this parameter we will
get the
error and and we will get
order so if any error occurs while
creating the order then we will get the
error in this parameter and if the order
will be created then we will get the
order in this
parameter correct now here we need the
options right so first we have to create
this options so just copy this options
and here before this RoR pay instance
order let's
add
const options and here in this options
we have to add the order amount so just
add
amount and in this amount we will add
the
amount we are getting this amount from
here you can see here we have the amount
right so after this amount we have to
add currency and order received but
before that in this amount we have to
multiply it with
100 like this just add comma here we
have multiplied it with 100 because when
you
add like
this
$155 then it will be considered as
$1.55 by Reser pay so to make it 155 we
have to multiply it with with 100 so it
will remove the decimal
point so after this amount we have to
add the currency so we will add
currency and in this one we will add the
currency from the envirment variable so
just add process
do
EnV Dot and let's add the environment
variable name
currency after that we have to add the
reip and the reip will be unique this
receipt is very important because we
have to verify the razor pay payment
later so in this one we have to add the
unique ID so whenever the transaction
will be created and stored in the
database so in this transaction data one
ID will be created by mongod DV so we
will use that ID in this recept so just
add new
transaction Dot uncore ID that is
autogenerated by mongod
DB so now we have this options and this
options will be used to create the
orders using this razor pay
instance right now here either we will
get the error or order so in this Aro
function let's add the if
statement and here we will add error so
if we get the error then we will
add console
log and provide this
error after that we will add the
response so just
add
return response.
Json and in this response we will add
success false and in the message we will
provide this error that's it suppose
there is no error then we will will get
this order right so we have to send one
response using Json method and in this
response we will
add one object and in this object we
will
send success
true and with that we will send this
order like this so now we have completed
this controller function that is
payment Reser pay correct after that we
have to export this function from this
file so scroll down and in this export
let's add the function name payment
Reserve pay and using this controller
function we will create the API
endpoint for that let's open this
sidebar and we will
open
this user routes.js file in this one let
me duplicate this route this
one and here we will make it
post and uh here we will
add the path so let me add the path
name pay razor
pay or let me write pay
rer after that we need this all Au user
for user authentication so this Au user
will add the user ID using the
token after that we will add the
controller function so here just add
this controller
function payment razor pay so this
payment Razer pay function has been
imported from this user controller.js
file in this line you can see it has
been imported
right and here we are using this payment
Reserve pay controller function and
before that we are using this middleware
that will convert the token into user ID
and here we have used this post
method so now we have created the API
endpoint for razor pay payment after
that we have to link this API endpoint
with our front end so let me just come
back and I'll close these files we will
collapse This Server folder and we will
open client
folder and in this one we will go to SRC
and here we have this pages and we will
open buy credit. jsx file correct and
here we have to create the function that
will initialize the Reser pay payment on
website but before that let's see the
res pay documentation so we will come
back to the Reser pay
website here it is and in this one we'll
go to resources and select developer
docs and in this left side bar just
click on the
payments then select payment
gway and in this one we will open web
Integrations then click on integration
steps scroll
down and in this one you can see here we
have one
script this one so we have to copy this
a script and we will come back to
the vs code and in this front end folder
that is the client folder we will
open
index.html file and we will paste this
script here before this closing body tag
so just paste the script that we have
copied from Reser pay
documentation after that let's come back
to the buy credits. jsx
file and in this one we need the backend
URL to make the API call to our API
endpoint and we also need the token and
we need the set so login then we need
the load Credit Data right and we need
the user so user is already available
and we are getting it from the context
so with this user we will get the
backend URL also from the
context then we will
get load credits
data we will get this function after
that we need the
token so that we will send this token in
the a API request after that we need the
set so login seter
function so we will get all these from
App
context correct after that we need the
use navigate hook that will help us to
navigate the users on homepage after
making the payment so let me add that
one also we will add
const navigate is equal to use navigate
so use navigate has been imported from
react router
Dom after that we have to create one
function that will be executed whenever
we will click on the payment button so
here let's add
const and we will add the function name
payment rasor
pay it will be as synchronous
function and create this Arrow function
and in this function we need the plan
ID correct now here we will add the TR
catch
block and in this catch block let's add
the error in toast notification so we
will
add toast so the toast will be imported
from react toasttify then toast. error
and in this eror we will add this
eror do
message correct now we will add the
statement in this Tri block so here in
this Tri block first we will check
whether we have the user or not so we
will add
if and we'll add not of user so if the
user is not available it means we are
not logged in then we will open the
login form for that we will use this set
so login and we will make it true so it
will open the login form right now
suppose the user is already logged in
then we will simply make the API call to
the Reser pay API that we have created
in our back end for that let's add a
wait and here we will at the exio
package so it is not available so we
have to import it so here let's
add
import exos from
exos and here we will use this exos and
here we will use the post
method in this one we have to provide
the backend URL and in this backend URL
we will concatenate the API end point so
just add SL API slash
user
slash
payer so we have created this API
endpoint in our back end correct now
with this one we have to pass the plan
ID so we will add the object and provide
plan ID after that we will add one more
object and in this one we have to
provide
headers and in this headers let's add
token so our middle bear will get this
token and find the user
ID so here we have added the API call to
our Reser pay payment API end point
right now we will get the response from
this API request so here just add
const data so we will get the response
in this data and after that we will
check so here let's add if statement and
we will add data do success
so if the data. success is true then it
will initialize the payment for that we
have to create one function that will
initialize the payment so before this
function let's add another function we
will
add
const and the function name will
be init
pay and it will be a synchronous
function
and in this one we need the
order let's add a space here and uh
create this Arrow
function correct so we will create this
init pay function that will initialize
the
payment right now we will call this init
pay function whenever this data do
success is true so here simply add init
pay and in this one we will
add data dot order because in the
response we will get the
order correct after that we have to link
this payment razor pay function with our
button so that when we click on the
payment button this function will be
executed so just copy this function and
scroll down and here we have this button
so in this button we will add on click
property and in this on click we will
add one Arrow
function and provide this function that
we have just created and here we have to
provide the
item dot ID that will be the plan
ID save these
changes after that scroll up and here we
have this init pay function so we have
to add logic in this init pay function
for that let's come back to the Reser
pay
documentation and here you can see we
have to create this options variable and
in this options we have to store the key
that will be the Reser pay key ID
correct then we have to store other
information like amount currency name
description and other details about the
order right and then we have to add this
new Reser pay and provide this option
for that let's come back to the vs code
and first we have to add the razor pay
key ID in the front end environment
variable so let me just copy the
envirment variable from
here that is Razor pay key ID just copy
this
one and uh let's come back and we will
open sidebar and here in this client
folder here we have the environment
variable where you can see backend URL
so in this one just provide this razor
pay key ID our front end is created
using wheat package so here before this
variable name we will add whe so it will
be Vore res pay key ID save the changes
now let's open by credit. jsx file and
here we will create the options so we
will add
const
options it will be one object and here
we have to add the key
and in this key we will add
import do
meta do
EnV Dot and the envirment variable name
we Reser pay key
ID like
this let's add the comma and here we
will add the order amount so we will add
amount and it will be
order that we are getting in this
parameter so we will add order do
amount after that we have to add the
currency so we will
add currency and it will be order.
currency then we need the name so in
this name let me
add credits payment because we are
buying the credits now we have to add
the description so let's add the comma
duplicate this line and here we will add
description so it is also credits
payment right after that we need the
order
ID and in this order ID we will add the
order that we are getting from this
parameter and from this we will find the
ID after that we need the rece so let's
add receip and we will get it from order
dot
receip after that we have to add one
Handler function so just add Handler we
are adding Handler and it will be as
synchronous
function and create this Aro
function now in this one we will get the
response so just add
response and in this Aro function simply
console log the response so we will
add console log and we will print this
response in the
console so here we have created this
options so after this
options
here let's
add
con razor pay or we can
write
rzp equal
to
new window Dot
razor
pay and here we have to provide this
option next simply
add
rzp do
open save the
changes now we have to test this
functionality so just come back to the
website and here you can see we have
different plans so let me click on this
Advanced click on this purchase
button so this click is not working so
let me just come back and we will open
vs code and open the
terminal let me go to the backend
terminal and here we are getting some
error path is required so
there is some error in
the mongod DB model so let's
open backend
folder that is server and in this one
we'll go to models and open transaction
model and here we have added this plan
that is the incorrect so just correct
it plan p n Save the changes and come
back to theb page again click on this
button now you can see it is opening a
window for razor pay payment here it is
asking for the phone number so let me
add a dummy phone
number click on
continue now here we have to provide the
card number so before that we will right
click and select inspect and we will
open the the console because in this
console we will get
the response right let me clear this
console and we will open a new tab and
here we will search
for razor
pay test card details then open this
website and here you will get the test
card numbers so scroll down and and here
we have this card number and in this one
we have to provide any random CVB number
and we can use any future date in the
expiry date so just copy this card
number and let's come back and provide
this card number
here then provide any future date so
let's
add this date then we'll add the CVB
number and we'll add the name on card so
let me add great
tag now just click on this continue
button here it is asking for the email
also so let's add any dummy email ID
test at test.com click on
continue click on maybe
later now we are getting the message
payment cannot be completed it says
international cards are not supp
supported please contact our support
team for help it means there is some
issue with this card number so let me
just close
it and press yes exit and now we will
try again with different card click on
the payment button and here let me add
the another card number this
one paste it here here we will add any
date then CBB number and name on card
then click on continue so it will open
this page here we can simulate this
payment either failed or success so let
me click on this success
button so now you can see the message
payment is
successful and in this console you can
see we have one response let me zoom
in and here you can see we have this
response and in this one we have the
razor pay order ID razor pay payment ID
and here we have the Reser pay signature
so using this response we will verify
the payment as you can see still the
credit is zero because we have not
verified the payment yet so using this
order details we will verify the payment
and then we will increase the credit so
to verify the Reser pay payment we have
to come back to the VSS code and we will
come to backend project so let's open
the sidebar and from here let me close
all these files here we will go for
Server folder then we will go for
controller folder and we will open user
controller.js file in this file here we
will create a controller function with
the name verify razor page so just add
const verify razor pay and create the as
synchronous Arrow
function here we will get the request
and response in this
parameter after that we will add the try
catch block and let me add the code in
the catch block so here we will add
console log error and we will send the
response with success false and the
message will be error do message message
so if any error occurs in this Tri block
this error will be displayed in the
terminal and we will send the response
with success false and error message now
we will add the logic in this Tri block
so here we have to find the Razor pay
order ID so we will get the razor pay
order ID from the razor pay payment
response right so we will add con
and here we will add
the razor pay order
ID if I come back to the browser you can
see here we are getting razor pay order
ID correct so we have to find this one
and we will get it
from request do
body correct after that we will add
const order info
and in this order info we will add a
wait and we will use the razor pay
instance and in this razor pay instance
we will add
orders and we will add
Fetch and in this fetch we have to
provide this order
ID so now we will get the order info now
from this order in before we have to
check the status of this order so here
we will add the if statement and we will
add order info.
status and if the status is
paid so here we will check if the order
info. status is paid then we have to
find the transaction data for this order
so we will add con
let's add
the variable name transaction data is
equal to
await and we will find the transaction
data using the transaction model so just
add transaction model
dot find by
ID and in this ID we have to provide the
order
info do re
so if I scroll up you can see here we
have added this receip and in this reip
we have added the new transaction ID so
to find the transaction data we are
using the transaction model and in this
we are using find by ID method and we
are providing the order info do received
so we will get the transaction data now
we will check with this transaction data
so here let's add the if
statement and here we will
add if the transaction data do
payment so we are checking the payment
property if it is true it means the
payment is already
verified if I save the changes and come
back to the web
browser and open the mongod DB database
refresh
it so here you can see we have one more
collection called
transactions if I open it so in this one
we have these transactions right so in
these transactions you can see we have
the payment Falls
right here also we have the payment
Falls so whenever we will verify the
payment we will make it true but here we
are adding the if statement
like if the transaction data. payment is
already true it means the payment is
already verified so in that case we have
to return one response so just add
return response.
Json and here we will add one object
with success false and we will add the
message called payment
failed so we are sending this response
payment failed because the payment is
already
verified now if the transaction data.
payment is false so in that case we have
to add the credit in users account or
user data so here let's add
con user
data and in this user
data we have to add a wait and we will
find the user data using user model so
just add user
model dot find by ID and
provide transaction data do user
ID so we will find the users data now in
this one we have to find the credit
balance and we will add the credit so
here let's add
const and in this one we will
add credit balance equal
to user data
Dot credit balance
plus transaction data dot
credits so it is
the current available balance of the
user and this is the credits that is
purchased using the pricing plan so if I
come back to the transaction data here
we have the credits value 500 like that
correct so here we are adding the
current balance current credit balance
and the credit that will be added after
purchasing the
plan after that again add
await and here we will use the user
model
dot find by ID ID and update
method and here we will find the user so
just
add user data
doore
ID and here we have to update the credit
balance so let me just copy it and paste
it here in this
object so here we have added this new
credit balance and this new credit
balance will be updated in the user data
using this user model so now we have
updated the credit after purchase right
next we have to update the payment
status also so in this transaction data
you can see we have the payment property
false so we have to make it true after
verification so just come back and here
let's
add await we will add transac
model do find by ID and
update and here we will
add transaction data doore
ID and comma we will add cly addes and
we will
make
payment
true so it will make the payment true
after that we have to generate one
response so just add response.
Json and in this one we will add one
object with success true and we will add
message credits
added that's it now we will add the Elsa
statement so here we have added the if
statement so here let's add else
statement and in this else statement we
will add the response so we will
response. Json success Falls and in the
message we will add payment
failed this
one that's it now we have created the
razor pay payment verification
controller function Now using this
controller function we will create one
API route so let's
open server folder then open routes
folder and in this one we have this user
routes.js file here we will just
duplicate this line that is user router.
poost and here we will provide the path
so in this one we will
add verify
razor that means verify razor
Pay Here we will use
this controller function that we have
just created so just add
verify Razer pay but first we have to
export it so let me just come back to
the previous file that is user
controller and here we have created this
verify razor pay function and we have to
export it from this file so here let's
add the comma and provide the function
name verify RoR pay that's it now in
this one we have to import that so here
in this statement import we will add
comma verify RoR pay so we have imported
this verify rer P from user controller
now here we will provide this controller
function at this path so now we have
created the API end point for Reser pay
payment verification that is verify
Reser now we have to link this payment
verification API with our front end so
let me just close these files and
collapse this folder and we will open
client folder then go to SRC then pages
and
open by credit. jsx file here we will
scroll this file and you can see in this
one we have added one Handler function
here it is so in this Handler function
we have added console log so just remove
it and in this one let's add the TR
catch block
block correct now in this catch block we
will add the error in toast notification
so we will
add toast.
error
and here we will provide error do
message correct now we will add the
logic in this Tri block so in this Tri
block let's add
const
data equal to and we have to make the
API call to our razor pay verification
API endpoint so we will add a wait then
we will use the exuse package for API
call here we will use the post
method and in this one we will add the
backend URL and in this backend URL we
have have to concatenate the API end
point so we will add/ API slash
user slash verify
deser after that in this one we have to
send the response which is here so this
response will be added in this API
request correct after that we have to
provide the headers so so just add the
curly bres we will provide headers and
in this headers we have to provide the
token correct after that here we will
add the if statement and we will check
the
response so we are getting the response
in this
data so let's add data dot
success so if the data do success is
true it means the payment is successful
verified so after verifying the payment
we will again load the credit so we will
add the load Credit Data
function correct and after that we will
redirect the user on home page so we
will use
navigate and we will provide the Home
Path after that we will send one
notification so just
add toast
dot success and here we will add the
message called credit
added like
this after adding this if I come back to
the web page
again
and let me close
this browser
console and right now you can see the
credit is zero correct and let me choose
the first plan which is basic click on
this purchase button so it should add
the 100 credit so let me just click
here here we will add the card number so
again copy this test card
number add any future month and
year CBB number and
name click on
continue now just click on this success
button so now the payment is
successful and after successful payment
we are redirected to the homepage and
here at the bottom right side you can
see the toast notification called credit
added correct and in this navigation bar
you can see the credit left 100 it means
the credit has been
added now if I go to mongod DV database
refresh
it scroll
down here still we have the payment
false so let me just come back
and we will
open
server controller and user controller.js
file and in this
one we have
added payment true
so let me correct this
spelling p a y m n t payment true save
the changes and come back to the web
browser again and let me make another
transactions right now you can see the
credit is 100 correct and now if I want
to purchase this Advanced plan that
gives 500 credits so just click on this
purchase
button provide the card number
and other card
details now click on success
button now the payment is successful and
after successful payment we are
redirected to homepage and you can see
the notification in the bottom right
side credit added and you can see the
updated credit balance which is 600 and
if I go to database refresh
it so now we have one new transaction
data here and in this one you can see
the payment is true and the credit 500
so in the last transaction we have
purchased the advanced plan with 500
credits and now the payment is true so
payment is successfully verified and the
credit has been added here correct now
we have this credit so we can again just
generate the images so let me just click
on this generate image button again so
it will open this result page and here
we have to enter the prompt so let me
add any other prompt so let's add white
dog playing with birds click on generate
button now you can see the image
generated using our prompt and you can
see the credit balance has been reduced
by one so this image generator is
working fine we can create an account on
this image 5 website we can log to the
existing account we can log out from the
account and here we have the credit and
we can also purchase more credits using
these plans and for this credit purchase
we have added the Razer pay payment gway
and if you want to add the a stripe
payment gateway then you can check out
the source code link given in the
description where I have added both
razor pay and a
stripe so finally we have created our
full stack image generated AI SAS
application that generates the image
from text using the AI so I hope this
video will be helpful for you if you
have any question you can ask me in the
comment section please like and share
this video
UNLOCK MORE
Sign up free to access premium features
INTERACTIVE VIEWER
Watch the video with synced subtitles, adjustable overlay, and full playback control.
AI SUMMARY
Get an instant AI-generated summary of the video content, key points, and takeaways.
TRANSLATE
Translate the transcript to 100+ languages with one click. Download in any format.
MIND MAP
Visualize the transcript as an interactive mind map. Understand structure at a glance.
CHAT WITH TRANSCRIPT
Ask questions about the video content. Get answers powered by AI directly from the transcript.
GET MORE FROM YOUR TRANSCRIPTS
Sign up for free and unlock interactive viewer, AI summaries, translations, mind maps, and more. No credit card required.