Welcome to the ShopWave Fusion E-Commerce Application Backend. This project is built using Spring Boot and incorporates Spring Security with JWT Token-based authorization for secure access. The backend serves as the core foundation for the ShopWave Fusion E-Commerce Application, providing the necessary functionality to manage products, orders, user authentication, and more.
This backend application can be integrated with any frontend UI application. You just need to follow few Steps.
- User and Admin registration and login with JWT authentication
- Password encryption using BCrypt
- Role-based authorization with Spring Security
- User Module
- Admin Module
- Java
- Spring
- Spring Boot
- Spring Security
- MySql
Clone this repository..
Here is the sample Javascript code..
async function fetchUserDetails() {
const username = 'admin@gmail.com';
const password = 'admin';
const authHeader = 'Basic ' + btoa(username + ':' + password);
try {
const response = await fetch('https://shopwavefusion-production.up.railway.app/auth/signin', {
method: 'GET',
headers: {
'Authorization': authHeader
}
});
if (response.ok) {
console.log(response.headers.get("Authorization"));
const user = await response.json();
console.log(user);
} else {
throw new Error('Failed to fetch user details');
}
} catch (error) {
console.error('Error:', error);
throw error;
}
}
https://shopwavefusion-production.up.railway.app/auth/signup
{
"firstName":"user",
"lastName":"user",
"email":"user2@gmail.com",
"password":"1234",
"mobile":"1234567890"
}
For other API request send the "Authorization Token" along with header
to get product
async function getproduct() {
let token = Stored Token from session Strorage or Local Storage
const myHeaders = new Headers();
myHeaders.append("Authorization", token);
const requestOptions = {
method: 'GET',
headers: myHeaders,
redirect: 'follow'
};
try {
const response = await fetch("https://shopwavefusion-production.up.railway.app/all", requestOptions);
if (response.ok) {
const data = await response.json();
console.log(data);
} else {
console.log("Response not OK:", response);
}
} catch (error) {
console.error('Error:', error);
}
}
There is a predefined admin credentials (email: "admin@example.com", password: "admin") in the config package with the class name AdminInitializer If you want you can use this admin as super admin also you can avoid this admin. Or you can change accordingly. if you don't want this then you can also delete this.
To add product into cart
https://shopwavefusion-production.up.railway.app/cart/add
according to the domain add /cart/add "PUT MAPPING"
{
"productId":2,
"size":"M"
}
Cart
http://localhost:8080](https://shopwavefusion-production.up.railway.app/cart/
according to the domain add /cart/ "GET MAPPING"
To add Product
https://shopwavefusion-production.up.railway.app/products/
{
"title": "Sample Product",
"description": "This is a sample product description.",
"price": 2999,
"discountedPrice": 2499,
"discountPersent": 20,
"quantity": 45,
"brand": "Example Brand",
"color": "Blue",
"size": [
{
"name": "S",
"quantity": 10
},
{
"name": "M",
"quantity": 20
},
{
"name": "L",
"quantity": 15
}
],
"imageUrl": "https://example.com/image.jpg",
"topLevelCategory": "Clothing",
"secondLevelCategory": "T-Shirts",
"thirdLevelCategory": "Men's T-Shirts"
}
To add multiple Product
https://shopwavefusion-production.up.railway.app/admin/products/creates
[
{
"title": "Sample Product 1",
"description": "This is a sample product description.",
"price": 2999,
"discountedPrice": 2499,
"discountPersent": 20,
"quantity": 100,
"brand": "Example Brand",
"color": "Blue",
"size": [
{
"name": "S",
"quantity": 10
},
{
"name": "M",
"quantity": 20
}
],
"imageUrl": "https://example.com/image1.jpg",
"topLavelCategory": "Clothing",
"secondLavelCategory": "T-Shirts",
"thirdLavelCategory": "Men's T-Shirts"
},
{
"title": "Sample Product 2",
"description": "Another sample product description.",
"price": 1999,
"discountedPrice": 1799,
"discountPersent": 10,
"quantity": 50,
"brand": "Another Brand",
"color": "Red",
"size": [
{
"name": "M",
"quantity": 15
},
{
"name": "L",
"quantity": 10
}
],
"imageUrl": "https://example.com/image2.jpg",
"topLavelCategory": "Clothing",
"secondLavelCategory": "Shirts",
"thirdLavelCategory": "Men's Shirts"
}
]
To get Product
https://shopwavefusion-production.up.railway.app/{product_id}
To place a order
{
"firstName": "John",
"lastName": "Doe",
"streetAddress": "123 Main St",
"city": "Example City",
"state": "Example State",
"zipCode": "12345",
"mobile": "123-456-7890",
"paymentMethod": "CREDIT_CARD",
"status": "PENDING",
"paymentId": "123456789",
"cardholderName": "John Doe",
"cardNumber": "**** **** **** 1234"
}
Only pass this object
For the all api's visit Swagger documentation
https://shopwavefusion-production.up.railway.app/swagger-ui/index.html
For Pagination and Sorting and Filtering Use this endpoint setValue as needed
https://shopwavefusion-production.up.railway.app/products/all?category&colors&sizes&minPrice=1&maxPrice=1000&minDiscount&sort&stock&pageNumber=1&pageSize=2