Spring+Boot+eCommerce+Masterclass
Spring+Boot+eCommerce+Masterclass
com
3. Intellectual Property
All course materials are protected by copyright laws and are the intellectual property of Faisal Memon and EmbarkX. Unauthorized use,
reproduction, or distribution of these materials is strictly prohibited.
4. Reporting Violations
If you become aware of any unauthorized sharing or distribution of course materials, please report it immediately to
[[email protected]].
5. Legal Action
We reserve the right to take legal action against individuals or entities found to be violating this usage policy.
Thank you for respecting these guidelines and helping us maintain the integrity of our course materials.
Contact Information
[email protected]
www.embarkx.com
© Faisal Memon | EmbarkX.com
Internet Web
Server
Request
© Faisal Memon | EmbarkX.com
www.domainname.com IP Address
© Faisal Memon | EmbarkX.com
Thank you
© Faisal Memon | EmbarkX.com
What is a Client?
→ A device or application that requests
services or resources from a server
Characteristics of a Client
→ User Interface
→ Requests Services
Client
→ Receives Data
© Faisal Memon | EmbarkX.com
What is a Server?
→ A device or application that provides
services or resources to clients
Server
→ A Server is designed to handle requests
from multiple clients
Characteristics of a Server
→ Always On
Server
→ Handles Multiple Requests
→ Sends Data
© Faisal Memon | EmbarkX.com
Request
Response
Server
Request
Response
© Faisal Memon | EmbarkX.com
Examples
→ Web Browsing
→ Email
© Faisal Memon | EmbarkX.com
Thank you
© Faisal Memon | EmbarkX.com
Imagine you
are at a
Restaurant
© Faisal Memon | EmbarkX.com
Restaurant
Customer → Application
Waiter → API
Food → Response
© Faisal Memon | EmbarkX.com
Internet Database
Browser
API
Response
Server
© Faisal Memon | EmbarkX.com
API’s can be
Private
Partner
Public
© Faisal Memon | EmbarkX.com
The Need
→ Reduces manual effort
→ Automates everything
© Faisal Memon | EmbarkX.com
Thank you
© Faisal Memon | EmbarkX.com
GET Request
POST Request
PUT Request
DELETE Request
© Faisal Memon | EmbarkX.com
GET Request
→ Retrieve or GET resources from server
POST Request
→ Create resources from server
© Faisal Memon | EmbarkX.com
PUT Request
→ Update existing resources on Server
© Faisal Memon | EmbarkX.com
DELETE Request
→ Used to DELETE resources from Server
© Faisal Memon | EmbarkX.com
Thank you
© Faisal Memon | EmbarkX.com
REST is stateless
© Faisal Memon | EmbarkX.com
→ Stateless
→ Can be Cached
→ Uniform Interface
© Faisal Memon | EmbarkX.com
Common Methods
→ GET
→ POST
→ PUT
→ DELETE
© Faisal Memon | EmbarkX.com
Benefits
→ Simplicity
→ Scalability
→ Flexibility
→ Visibility
© Faisal Memon | EmbarkX.com
Thank you
© Faisal Memon | EmbarkX.com
http vs https
HTTPS is essentially
HTTP with security
© Faisal Memon | EmbarkX.com
Thank You
© Faisal Memon | EmbarkX.com
Request
Response
with status
code
Cloud Server
Request
Response
with status
code
© Faisal Memon | EmbarkX.com
→ 2xx (Successful)
→ 3xx (Redirection)
→ 201 Created
→ 204 No Content
→ 403 Forbidden
Thank you
© Faisal Memon | EmbarkX.com
Resource
→ A Resource is any piece of information that can be named or identified on the
web.
→ Can represent any type of object, data, or service that can be accessed by
clients
→ URIs are a broad category that includes both URLs (Uniform Resource
Locators) and URNs (Uniform Resource Names).
© Faisal Memon | EmbarkX.com
Sub-Resource
→ A Sub-Resource is a resource that is hierarchically under another resource.
→ It's a part of a larger resource and can be accessed by extending the URI of the
parent resource.
→ Sub-resources are often used in RESTful APIs to maintain a logical hierarchy of
data and to facilitate easy access to related resources.
→ Example: In a blogging platform, you might have a users resource identified by
a URI (/users). A specific user could be a resource accessible at /users/{userId}.
→ If each user can have blog posts, a post would be a sub-resource of that user,
identified by something like /users/{userId}/posts/{postId}.
© Faisal Memon | EmbarkX.com
→ Accessibility
→ Scalability
© Faisal Memon | EmbarkX.com
Thank you
© Faisal Memon | EmbarkX.com
What if…
→ You could have prefabricated components?
Django (Python)
Flask (Python)
Express (JavaScript)
Thank you
© Faisal Memon | EmbarkX.com
Introduction to Spring
Framework
History
→ Initially developed by Rod Johnson in 2002
Key Principles
Simplicity
Modularity
Testability
© Faisal Memon | EmbarkX.com
→ Spring Boot
→ Spring Data
→ Spring Security
→ Spring Cloud
© Faisal Memon | EmbarkX.com
Use Cases
→ Enterprise Applications
→ Microservices Architecture
→ Web Applications
© Faisal Memon | EmbarkX.com
Thank you
© Faisal Memon | EmbarkX.com
Tight Coupling
Loose Coupling
→ Scalability
→ Testing
© Faisal Memon | EmbarkX.com
Dependency Injection
Thank you
© Faisal Memon | EmbarkX.com
Loose Coupling
Loose Coupling is a design principle that aims to reduce the
dependencies between components within a system
© Faisal Memon | EmbarkX.com
Beans
Thank you
© Faisal Memon | EmbarkX.com
Spring Container
© Faisal Memon | EmbarkX.com
ApplicationContext
BeanFactory
© Faisal Memon | EmbarkX.com
Spring Container
© Faisal Memon | EmbarkX.com
Spring Container
Config
© Faisal Memon | EmbarkX.com
Configuration contains
bean definition
© Faisal Memon | EmbarkX.com
Thank you
© Faisal Memon | EmbarkX.com
Lifecycle of Bean
Beans
Beans
Bean Definition
● A bean definition includes configuration metadata that the container needs
to know to create and manage the bean
Bean Configuration
● Bean definitions can be provided in various ways, including XML
configuration files, annotations, and Java-based configuration.
● Beans are configured using XML files, where each bean is defined within
<bean> tags with attributes specifying class, properties, and dependencies.
● Beans can be configured using annotations like @Component, @Service,
@Repository, etc., which are scanned by Spring and managed as beans.
© Faisal Memon | EmbarkX.com
Lifecycle of Beans
Population of
Instantiation Initialization
Properties
Dependency Resolution
→ Dependency Injection
→ Autowiring
© Faisal Memon | EmbarkX.com
Thank you
© Faisal Memon | EmbarkX.com
Types
→ Constructor Injection
→ Setter Injection
© Faisal Memon | EmbarkX.com
Thank you
© Faisal Memon | EmbarkX.com
Constructor Injection
Constructor Injection
→ Dependencies are provided to the dependent class through
its constructor
→ Dependencies are passed as arguments to the constructor
when the dependent class is instantiated
→ Constructor injection ensures that the dependencies are
available when the object is created
© Faisal Memon | EmbarkX.com
Thank you
© Faisal Memon | EmbarkX.com
Setter Injection
Setter Injection
→ Dependencies are provided to the dependent class through
setter methods
→ Dependent class exposes setter methods for each
dependency that needs to be injected
→ Setter injection allows for flexibility as dependencies can be
changed or updated after the object is instantiated
© Faisal Memon | EmbarkX.com
Thank you
© Faisal Memon | EmbarkX.com
Introduction to Annotations
Annotations in Java
provide a way to add
metadata to your code
© Faisal Memon | EmbarkX.com
@Override
© Faisal Memon | EmbarkX.com
→ @Autowired
→ @Qualifier
→ @Value
→ @Repository
© Faisal Memon | EmbarkX.com
→ @Controller
→ @RequestMapping
→ @SpringBootApplication
© Faisal Memon | EmbarkX.com
Thank you
© Faisal Memon | EmbarkX.com
Understanding Components
and ComponentScan
Using XML
Using Annotations
© Faisal Memon | EmbarkX.com
Using XML
Using Annotations
import org.springframework.stereotype.Component;
Component scanning is a
feature helps to automatically
detect and register beans from
predefined package paths.
© Faisal Memon | EmbarkX.com
Using XML
Thank you
© Faisal Memon | EmbarkX.com
Review
Spring
Basics of Web Coupling
Framework
Xml &
DI and IoC Configurations
Annotations
© Faisal Memon | EmbarkX.com
Review
→ Explicit Bean Configuration
→ No Embedded Server
→ Component Scanning
→ Boilerplate code
© Faisal Memon | EmbarkX.com
Thank you
© Faisal Memon | EmbarkX.com
Offers a set of
pre-configured
Lots of steps involved in components or defaults,
setting up, configuration, and eliminating the need
writing boilerplate code, for a lot of boilerplate
deployment of the app code that was involved in
setting up a Spring
application
© Faisal Memon | EmbarkX.com
Spring Framework
+
Spring boot = Prebuilt Configuration
+
Embedded Servers
© Faisal Memon | EmbarkX.com
→ Auto Configuration
→ Starter code
→ Less configuration
→ Reduced cost and application development time
© Faisal Memon | EmbarkX.com
→ Fast, easy
Thank you
© Faisal Memon | EmbarkX.com
Structuring Thoughts
OUR APPLICATION
Controller Service
Response Back
SERVER
OUR APPLICATION © Faisal Memon | EmbarkX.com
Response Back
SERVER
© Faisal Memon | EmbarkX.com
Request Request
pageNumber,
Get Retrieve a list
/api/public/categories GET None pageSize, sortBy, CategoryResponse
Categories of categories
sortOrder
Update an
Update
/api/admin/categories/{categoryId} PUT existing Category categoryId CategoryDTO
Category
category
Delete an
Delete
/api/admin/categories/{categoryId} DELETE existing None categoryId CategoryDTO
Category
category
© Faisal Memon | EmbarkX.com
Request Request
pageNumber,
Get Retrieve a list
/api/public/categories GET None pageSize, sortBy, CategoryResponse
Categories of categories
sortOrder
Update an
Update
/api/admin/categories/{categoryId} PUT existing Category categoryId CategoryDTO
Category
category
Delete an
Delete
/api/admin/categories/{categoryId} DELETE existing None categoryId CategoryDTO
Category
category
© Faisal Memon | EmbarkX.com
Request Request
pageNumber,
Get Retrieve a list
/api/public/categories GET None pageSize, sortBy, CategoryResponse
Categories of categories
sortOrder
Update an
Update
/api/admin/categories/{categoryId} PUT existing Category categoryId CategoryDTO
Category
category
Delete an
Delete
/api/admin/categories/{categoryId} DELETE existing None categoryId CategoryDTO
Category
category
© Faisal Memon | EmbarkX.com
Request Request
pageNumber,
Get Retrieve a list
/api/public/categories GET None pageSize, sortBy, CategoryResponse
Categories of categories
sortOrder
Update an
Update
/api/admin/categories/{categoryId} PUT existing Category categoryId CategoryDTO
Category
category
Delete an
Delete
/api/admin/categories/{categoryId} DELETE existing None categoryId CategoryDTO
Category
category
© Faisal Memon | EmbarkX.com
Request Request
pageNumber,
Get Retrieve a list
/api/public/categories GET None pageSize, sortBy, CategoryResponse
Categories of categories
sortOrder
Update an
Update
/api/admin/categories/{categoryId} PUT existing Category categoryId CategoryDTO
Category
category
Delete an
Delete
/api/admin/categories/{categoryId} DELETE existing None categoryId CategoryDTO
Category
category
© Faisal Memon | EmbarkX.com
Request Request
pageNumber,
Get Retrieve a list
/api/public/categories GET None pageSize, sortBy, CategoryResponse
Categories of categories
sortOrder
Update an
Update
/api/admin/categories/{categoryId} PUT existing Category categoryId CategoryDTO
Category
category
Delete an
Delete
/api/admin/categories/{categoryId} DELETE existing None categoryId CategoryDTO
Category
category
© Faisal Memon | EmbarkX.com
Thank you
© Faisal Memon | EmbarkX.com
Your
Application Database
Computer Save Job
Add a Job
© Faisal Memon | EmbarkX.com
What is a Database?
Database is a place where data related to your users and product is
stored.
© Faisal Memon | EmbarkX.com
Databases Types
→ Relational
→ Non-Relational
© Faisal Memon | EmbarkX.com
Thank you
© Faisal Memon | EmbarkX.com
What is DBMS
Examples of DBMS
→ MySQL
→ Oracle Database
→ SQL Server
→ MongoDB
→ Cassandra
© Faisal Memon | EmbarkX.com
Types of DBMS
Thank you
© Faisal Memon | EmbarkX.com
Introduction to Relational
Databases Concepts
DBMS Terminologies
Table
Column
Row
© Faisal Memon | EmbarkX.com
DBMS Terminologies
Table
Column
Row
Primary Key
Foreign Key
Index
Query
© Faisal Memon | EmbarkX.com
Columns
© Faisal Memon | EmbarkX.com
Thank you
© Faisal Memon | EmbarkX.com
Overview of SQL
Faisal Memon
© Faisal Memon | EmbarkX.com
Database
© Faisal Memon | EmbarkX.com
SQL
Database
© Faisal Memon | EmbarkX.com
What is SQL
SQL stands for Structured Query Language. Used to retrieve,
manage and update data in Database
© Faisal Memon | EmbarkX.com
SQL Queries
Thank you
© Faisal Memon | EmbarkX.com
What is ORM?
Customer
id : Integer
first_name : String
last_name : String
id : 1 id : 2 id : 3
first_name : “John” first_name: “Stacy” first_name : “Mark”
last_name : “Trump” last_name: “Keiber” last_name : “Dsouza”
Customer in database
id first_name last_name
1 John Trump
2 Stacy Keiber
3 Mark Dsouza
© Faisal Memon | EmbarkX.com
ORM
→ Whenever there is a class, that class can be automatically
converted to a table with its attributes being converted to columns
→ So now the developer does not have to write queries for table
creation, it's created automatically
ORM
→ ORM as a concept makes developers lives easier and lets
developers focus on application logic rather than SQL queries
→ Because of ORM developers don’t need to learn how to write
SQL queries since the translation from application to SQL is
handled by ORM itself
→ It’s a powerful technique in programming which also minimizes
mistakes since developers are not writing queries on their own
© Faisal Memon | EmbarkX.com
Thank you
© Faisal Memon | EmbarkX.com
What is JPA?
class Category {
Long categoryId;
String categoryName;
}
categoryId categoryName
Thank you
© Faisal Memon | EmbarkX.com
OUR APPLICATION
Response Back
SERVER
OUR APPLICATION © Faisal Memon | EmbarkX.com
Response Back
SERVER
© Faisal Memon | EmbarkX.com
Thank you
© Faisal Memon | EmbarkX.com
AUTO
IDENTITY
SEQUENCE
TABLE
NONE
© Faisal Memon | EmbarkX.com
GenerationType.AUTO
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
© Faisal Memon | EmbarkX.com
GenerationType.IDENTITY
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
© Faisal Memon | EmbarkX.com
GenerationType.SEQUENCE
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE)
private Long id;
© Faisal Memon | EmbarkX.com
GenerationType.SEQUENCE
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE,
generator = "order_seq")
GenerationType.SEQUENCE
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE,
generator = "order_seq")
GenerationType.SEQUENCE
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE,
generator = "order_seq")
GenerationType.SEQUENCE
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE,
generator = "order_seq")
GenerationType.SEQUENCE
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE,
generator = "order_seq")
GenerationType.SEQUENCE
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE,
generator = "order_seq")
GenerationType.TABLE
@Id
@GeneratedValue(strategy = GenerationType.TABLE)
private Long id;
© Faisal Memon | EmbarkX.com
GenerationType.TABLE
@Id
@GeneratedValue(strategy = GenerationType.TABLE,
generator = "task_gen")
GenerationType.TABLE
@Id
@GeneratedValue(strategy = GenerationType.TABLE,
generator = "task_gen")
GenerationType.TABLE
@Id
@GeneratedValue(strategy = GenerationType.TABLE,
generator = "task_gen")
GenerationType.TABLE
@Id
@GeneratedValue(strategy = GenerationType.TABLE,
generator = "task_gen")
GenerationType.TABLE
@Id
@GeneratedValue(strategy = GenerationType.TABLE,
generator = "task_gen")
Thank you
© Faisal Memon | EmbarkX.com
→ @NotEmpty
→ @Size(min = x, max = y)
Example
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.Size;
Thank you
© Faisal Memon | EmbarkX.com
Use of ResponseStatusException
© Faisal Memon | EmbarkX.com
Thank you
© Faisal Memon | EmbarkX.com
DTO Pattern
What is it?
Design pattern used to transfer data between software application
subsystems
© Faisal Memon | EmbarkX.com
Data Transfer
JSON Category
Object
© Faisal Memon | EmbarkX.com
1. Request with
3. Get desired data
DTO
from the database
2. Converts DTO to
Entity
4. Data is passed
to server
Thank you
© Faisal Memon | EmbarkX.com
→ If you have a table for storing information about books, each book object
would be a row
→ JPA allows you to map these relationships using annotations in your Java code
© Faisal Memon | EmbarkX.com
Relationships
One to One
Many to Many
© Faisal Memon | EmbarkX.com
Example
Employee and salary account
Salary
Employee
account
Example
Customer and orders Order 1
Order 1
Customer
Order 1
Example
Customer and products
Customer 1 Product 1
Product 2
Customer 1
Customer 1 Product 3
Unidirectional Relationship
Bidirectional Relationship
Thank you
© Faisal Memon | EmbarkX.com
Example
User Profile
© Faisal Memon | EmbarkX.com
Optional data
Example
© Faisal Memon | EmbarkX.com
Thank you
© Faisal Memon | EmbarkX.com
Example
© Faisal Memon | EmbarkX.com
Before
After
Thank you
© Faisal Memon | EmbarkX.com
Example
→ Junction table
© Faisal Memon | EmbarkX.com
Example
© Faisal Memon | EmbarkX.com
Things to remember
→ Junction table may contain additional attributes
Thank you
© Faisal Memon | EmbarkX.com
Cascading
Cascading Types
PERSIST
MERGE
REMOVE
REFRESH
DETACH
ALL
© Faisal Memon | EmbarkX.com
FetchTypes
FetchTypes
FetchType.LAZY
FetchType.EAGER
© Faisal Memon | EmbarkX.com
Default FetchTypes
→ OneToMany: Lazy
→ ManyToOne: Eager
→ ManyToMany: Lazy
→ OneToOne: Eager
© Faisal Memon | EmbarkX.com
Thank you
© Faisal Memon | EmbarkX.com
OUR APPLICATION
Response Back
SERVER
OUR APPLICATION © Faisal Memon | EmbarkX.com
Response Back
SERVER
© Faisal Memon | EmbarkX.com
Metho Request
API Name Endpoint d Purpose Body Request Parameters Response
categoryId
Get Retrieves (PathVariable), ProductResponse
/api/public/categories/{categoryId}/prod
Products by GET products by - pageNumber, pageSize, (JSON), HttpStatus
ucts
Category category sortBy, sortOrder 200
(RequestParams)
keyword
Get Searches (PathVariable), ProductResponse
Products by /api/public/products/keyword/{keyword} GET products by - pageNumber, pageSize, (JSON), HttpStatus
Keyword keyword sortBy, sortOrder 302
(RequestParams)
Updates an ProductDTO
Update Product productId
/api/products/{productId} PUT existing (JSON), HttpStatus
Product (JSON) (PathVariable)
product 200
© Faisal Memon | EmbarkX.com
Metho Request
API Name Endpoint d Purpose Body Request Parameters Response
Multipart
Update Updates the ProductDTO
File productId
Product /api/products/{productId}/image PUT image of a (JSON), HttpStatus
(Form (PathVariable)
Image product 200
Data)
String (Status
Delete DELET Deletes a productId
/api/admin/products/{productId} - Message),
Product E product (PathVariable)
HttpStatus 200
Get
Retrieves Long, HttpStatus
Product /api/admin/products/count GET - -
product count 200
Count
© Faisal Memon | EmbarkX.com
Thank you
© Faisal Memon | EmbarkX.com
Introduction to Spring
Security
Security is important
© Faisal Memon | EmbarkX.com
Importance of Security
→ Privacy Protection
→ Trust
→ Integrity
→ Compliance
© Faisal Memon | EmbarkX.com
→ Spring Framework
→ Spring Boot
→ Spring Data
→ Spring Security
– Authentication
– Authorization
© Faisal Memon | EmbarkX.com
Authentication
Authentication is proving who you are.
Authorization
Authorization is about what you're allowed to do after you've proven who you
are.
© Faisal Memon | EmbarkX.com
Authentication
Scanning your ID badge to confirm your identity as an employee.
Authorization
After confirming your identity, determining if you're permitted to enter certain
restricted areas based on your job role or clearance level.
© Faisal Memon | EmbarkX.com
→ Secure by Design
→ Fail-Safe Defaults
→ Secure Communication
© Faisal Memon | EmbarkX.com
Hashing
What is Hashing?
© Faisal Memon | EmbarkX.com
programming
Hashing
$2a$12$JBtXfRbJBXD/lnskS7O/3eaT3hTAp/lSzdm0xaFTv7dS3SQ8tNyLW
© Faisal Memon | EmbarkX.com
Hashing
$2a$12$JBtXfRbJBXD/lnskS7O/3eaT3hTAp/lSzdm0xaFTv7dS3SQ8tNyLW
© Faisal Memon | EmbarkX.com
Hashing
$2a$12$xwHrcZF9BsDDoqF1JirbMu9h911nvqFUldZFcSvXE91MYTGwMLpYa
© Faisal Memon | EmbarkX.com
JWT Authentication
Without JWT
→ No advanced features like expiration time
2.Token
Generation
5. Token
Validated
Format
Authorization: Bearer <token>
© Faisal Memon | EmbarkX.com
Header
PAYLOAD
VERIFY SIGNATURE
© Faisal Memon | EmbarkX.com
© Faisal Memon | EmbarkX.com
Understanding
Implementation of JWT
JwtUtils
AuthTokenFilter
SecurityConfig
© Faisal Memon | EmbarkX.com
JwtUtils
JwtUtils
→ Contains utility methods
for generating, parsing, and
AuthTokenFilter
validating JWTs.
AuthEntryPointJwt
→Include generating a token
from a username, validating a
SecurityConfig
JWT, and extracting the
username from a token.
© Faisal Memon | EmbarkX.com
AuthTokenFilter
→ Filters incoming requests to
JwtUtils
check for a valid JWT in the
header, setting the
AuthTokenFilter authentication context if the
token is valid.
AuthEntryPointJwt
→Extracts JWT from request
header, validates it, and
SecurityConfig configures the Spring Security
context with user details if the
token is valid.
© Faisal Memon | EmbarkX.com
AuthEntryPointJwt
→ Provides custom handling for
JwtUtils
unauthorized requests, typically
when authentication is required
AuthTokenFilter but not supplied or valid.
SecurityConfig
JwtUtils → Configures Spring Security
filters and rules for the
AuthTokenFilter application
Authentication Controller
Metho Request
API Name Endpoint d Purpose Request Body Parameters Response
LoginRequest UserInfoResponse
Sign In /signin POST Authenticate a user -
(JSON) (JSON), HttpStatus.OK
SignupRequest MessageResponse
Sign Up /signup POST Register a new user -
(JSON) (JSON), HttpStatus.OK
MessageResponse
Sign Out /signout POST Sign out the user - -
(JSON), HttpStatus.OK
Retrieve the
Current String (username),
/username GET username of the - -
Username HttpStatus.OK
authenticated user
pageNumber
Retrieve a paginated UserResponse (JSON),
All Sellers /sellers GET - (Query
list of sellers HttpStatus.OK
Parameter)
© Faisal Memon | EmbarkX.com
Format
Authorization: Bearer <token>
© Faisal Memon | EmbarkX.com
Browser will
automatically send
cookies
© Faisal Memon | EmbarkX.com
2.Token
Generation
5. Token
Validated
2.Token
Generation
5. Token
Validated
2.Token
Generation
5. Token
Validated
Shopping Carts
Session-Based Carts
Cart's contents are stored in the user's session. If session expires, data is lost.
Cookie-Based Carts
Cart data is stored in cookies on the user's browser.
Database-Based Carts
Cart data is stored on the server side, within a database. This approach is
scalable, secure, and allows for advanced features like cart recovery, detailed
analytics, and cross-device accessibility.
© Faisal Memon | EmbarkX.com
→ Scalability
→ Enhanced Features
→ Security
→ User Experience
© Faisal Memon | EmbarkX.com
Thank you
© Faisal Memon | EmbarkX.com
OUR APPLICATION
Response Back
SERVER
© Faisal Memon | EmbarkX.com
Request Request
API Name Endpoint Method Purpose Body Parameters Response
productId:
Add Adds a specified
/api/carts/products/{product Long, CartDTO
Product to POST product and quantity to None
Id}/quantity/{quantity} quantity: (JSON)
Cart the user's cart.
Integer
List of
Get All Retrieves a list of all
/api/carts GET None None CartDTO
Carts carts.
(JSON)
productId:
Update Updates the quantity of
/api/cart/products/{productI Long, CartDTO
Product PUT a specific product in the None
d}/quantity/{operation} operation: (JSON)
Quantity cart.
String
Request Request
API Name Endpoint Method Purpose Body Parameters Response
productId:
Add Adds a specified
/api/carts/products/{product Long, CartDTO
Product to POST product and quantity to None
Id}/quantity/{quantity} quantity: (JSON)
Cart the user's cart.
Integer
List of
Get All Retrieves a list of all
/api/carts GET None None CartDTO
Carts carts.
(JSON)
productId:
Update Updates the quantity of
/api/cart/products/{productI Long, CartDTO
Product PUT a specific product in the None
d}/quantity/{operation} operation: (JSON)
Quantity cart.
String
Request Request
API Name Endpoint Method Purpose Body Parameters Response
productId:
Add Adds a specified
/api/carts/products/{product Long, CartDTO
Product to POST product and quantity to None
Id}/quantity/{quantity} quantity: (JSON)
Cart the user's cart.
Integer
List of
Get All Retrieves a list of all
/api/carts GET None None CartDTO
Carts carts.
(JSON)
productId:
Update Updates the quantity of
/api/cart/products/{productI Long, CartDTO
Product PUT a specific product in the None
d}/quantity/{operation} operation: (JSON)
Quantity cart.
String
Request Request
API Name Endpoint Method Purpose Body Parameters Response
productId:
Add Adds a specified
/api/carts/products/{product Long, CartDTO
Product to POST product and quantity to None
Id}/quantity/{quantity} quantity: (JSON)
Cart the user's cart.
Integer
List of
Get All Retrieves a list of all
/api/carts GET None None CartDTO
Carts carts.
(JSON)
productId:
Update Updates the quantity of
/api/cart/products/{productI Long, CartDTO
Product PUT a specific product in the None
d}/quantity/{operation} operation: (JSON)
Quantity cart.
String
Request Request
API Name Endpoint Method Purpose Body Parameters Response
productId:
Add Adds a specified
/api/carts/products/{product Long, CartDTO
Product to POST product and quantity to None
Id}/quantity/{quantity} quantity: (JSON)
Cart the user's cart.
Integer
List of
Get All Retrieves a list of all
/api/carts GET None None CartDTO
Carts carts.
(JSON)
productId:
Update Updates the quantity of
/api/cart/products/{productI Long, CartDTO
Product PUT a specific product in the None
d}/quantity/{operation} operation: (JSON)
Quantity cart.
String
Request Request
API Name Endpoint Method Purpose Body Parameters Response
productId:
Add Adds a specified
/api/carts/products/{product Long, CartDTO
Product to POST product and quantity to None
Id}/quantity/{quantity} quantity: (JSON)
Cart the user's cart.
Integer
List of
Get All Retrieves a list of all
/api/carts GET None None CartDTO
Carts carts.
(JSON)
productId:
Update Updates the quantity of
/api/cart/products/{productI Long, CartDTO
Product PUT a specific product in the None
d}/quantity/{operation} operation: (JSON)
Quantity cart.
String
Request Request
API Name Endpoint Method Purpose Body Parameters Response
productId:
Add Adds a specified
/api/carts/products/{product Long, CartDTO
Product to POST product and quantity to None
Id}/quantity/{quantity} quantity: (JSON)
Cart the user's cart.
Integer
List of
Get All Retrieves a list of all
/api/carts GET None None CartDTO
Carts carts.
(JSON)
productId:
Update Updates the quantity of
/api/cart/products/{productI Long, CartDTO
Product PUT a specific product in the None
d}/quantity/{operation} operation: (JSON)
Quantity cart.
String
Database Vendor
A database vendor is a company or organization that develops and
maintains a database management system
© Faisal Memon | EmbarkX.com
Types of Vendors
Oracle Database
MySQL
PostgreSQL
MongoDB
© Faisal Memon | EmbarkX.com
Scale
Performance
Security
Cost
Support
© Faisal Memon | EmbarkX.com
class Category {
Long categoryId;
String categoryName;
}
categoryId categoryName
H2 PostgreSQL MySQL
JPA Layer
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQLDialect
© Faisal Memon | EmbarkX.com
Thank you
© Faisal Memon | EmbarkX.com
Database Schema
Management
spring.jpa.hibernate.ddl-auto=update
© Faisal Memon | EmbarkX.com
Possible Values
none
validate
update
create
create-drop
create-only
© Faisal Memon | EmbarkX.com
Hibernate updates the database schema to match Use this in development and testing
the entities. It adds new columns and tables as environments where you want the
update
necessary, but it does not remove or modify existing schema to evolve with the entity
columns and tables. mappings without losing data.
© Faisal Memon | EmbarkX.com
Request Request
API Name Endpoint Method Purpose Body Parameters Response
Retrieve
Get All all List of AddressDTO
/addresses GET None None
Addresses addresse with HttpStatus.OK
s
Retrieve
Get Path:
an AddressDTO with
Address /addresses/{addressId} GET None addressId
address HttpStatus.OK
by ID (Long)
by its ID
Retrieve
Get the
AddressDTO with
Address /users/addresses GET logged-in None None
HttpStatus.OK
by User user's
address
© Faisal Memon | EmbarkX.com
Update an
Path:
Update existing AddressDTO with
/addresses/{addressId} PUT Address addressId
Address address by HttpStatus.OK
(Long)
its ID
Delete an Path:
Delete DELE Status message
/addresses/{addressId} address by None addressId
Address TE with HttpStatus.OK
its ID (Long)
© Faisal Memon | EmbarkX.com
Understanding Deployments
OUR APPLICATION
Database
REACT
Browser Controllers Services
APP Repositories
SERVER
SERVER
Response Back
Postman
© Faisal Memon | EmbarkX.com
OUR APPLICATION
Database
REACT
Browser Controllers Services
APP Repositories
SERVER
RDS
EC2
Response Back
Postman
© Faisal Memon | EmbarkX.com
OUR APPLICATION
Database
RDS
EC2
Response Back
Postman
© Faisal Memon | EmbarkX.com
If you think this course helped you, please do help provide an honest rating and
review of the course. Your insights help us improve and provide better content
for future learners.