This project is a full-stack e-commerce website using React for the frontend, Spring Boot for the backend, and MySQL as the database. The application allows users to browse products, add them to the cart, and make purchases. Admins can manage the product inventory through CRUD operations.
- Product listing and details
- Shopping cart functionality
- Order management
- Admin panel for product management
- Responsive design
- Add, update, delete, and create products with images
- React
- Redux
- Axios
- React Router
- Spring Boot
- Spring Data JPA
- MySQL
- Node.js and npm
- Java 8 or higher
- Maven 3.6 or higher
- MySQL
-
Navigate to the frontend directory:
cd frontend -
Install dependencies:
npm install
-
Run the frontend server:
npm start
The frontend will start running at
http://localhost:3000.
-
Navigate to the backend directory:
cd backend -
Configure the MySQL Database:
Create a database in MySQL:
CREATE DATABASE ecommerce;
Update the
application.propertiesfile located insrc/main/resourceswith your MySQL database configuration:spring.datasource.url=jdbc:mysql://localhost:3306/ecommerce spring.datasource.username=your-username spring.datasource.password=your-password spring.jpa.hibernate.ddl-auto=update
-
Build and Run the Backend:
mvn clean install mvn spring-boot:run
The backend will start running at
http://localhost:8080.
-
Get All Products:
- URL:
/api/products - Method:
GET
- URL:
-
Get Product by ID:
- URL:
/api/product/{id} - Method:
GET
- URL:
-
Add a Product:
- URL:
/api/product - Method:
POST - Request Body:
{ "name": "Product Name", "description": "Product Description", "brand": "Brand", "price": 100.0, "category": "Category", "releaseDate": "2023-07-01", "productAvailable": true, "stockQuantity": 50, "imageName": "image.jpg", "imageType": "image/jpeg", "imageData": "<image byte data>" }
- URL:
-
Update a Product:
- URL:
/api/product/{prodId} - Method:
PUT - Request Body:
{ "name": "Updated Product Name", "description": "Updated Product Description", "brand": "Updated Brand", "price": 150.0, "category": "Updated Category", "releaseDate": "2023-07-01", "productAvailable": true, "stockQuantity": 60, "imageName": "updated_image.jpg", "imageType": "image/jpeg", "imageData": "<updated image byte data>" }
- URL:
-
Delete a Product:
- URL:
/api/product/{prodId} - Method:
DELETE
- URL:
-
Search Products:
- URL:
/api/products/search - Method:
GET - Request Params:
keyword
- URL:
backend
├── src
│ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ └── ravi
│ │ │ └── ecom_proj
│ │ │ ├── controller
│ │ │ │ └── ProductController.java
│ │ │ ├── model
│ │ │ │ └── Product.java
│ │ │ ├── repository
│ │ │ │ └── ProductRepository.java
│ │ │ ├── service
│ │ │ │ └── ProductService.java
│ │ │ └── EcommerceApplication.java
│ ├── resources
│ │ ├── application.properties
│ │ └── schema.sql
│ └── test
│ └── java
│ └── com
│ └── ravi
│ └── ecom_proj
│ └── EcommerceApplicationTests.java
├── pom.xml
└── ...package com.ravi.ecom_proj.model;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Generated;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
import java.util.Date;
@Entity
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Product {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
private String name;
private String description;
private String brand;
private BigDecimal price;
private String category;
private Date releaseDate;
private boolean productAvailable;
private int stockQuantity;
private String imageName;
private String imageType;
@Lob
@Column(columnDefinition="LONGBLOB")
private byte[] imageData;
}