This project is a backend API for an e-commerce platform, built with Spring Boot. It includes features for managing products, categories, carts, orders, users, and authentication.
This backend application provides RESTful APIs to handle CRUD operations for products, categories, users, and order processing. It includes JWT-based authentication for secure login and access to resources.
-
Product Management: Create, update, delete, and retrieve products.
-
Category Management: Organize and retrieve products by category.
-
Cart Functionality: Add, update, and remove items in the shopping cart.
-
Order Processing: Manage user orders and order details.
-
User Authentication: JWT-based login for secure access.
-
Spring Security Integration: Role-based access control for endpoints.
-
Java 17
-
Spring Boot
-
Spring Data JPA for database interactions
-
Spring Security for authentication and authorization
-
JWT (JSON Web Token) for stateless authentication
-
MySQL as the primary database
-
Maven for dependency management
- Java Development Kit (JDK 8 or higher)
- Maven
- MySQL or PostgreSQL
-
Clone the Repository:
git clone https://github.com/Yogesh-chiluka/E-commerce-Backend-main
-
Navigate to the Project Directory:
cd E-commerce-Backend-main
-
Configure the Database: Open the
application.properties
file and set your database connection details:spring.datasource.url=jdbc:mysql://localhost:3306/your-database spring.datasource.username=your-username spring.datasource.password=your-password
-
Run the Application:
mvn spring-boot:run
To build the project, use:
mvn clean install
- Make sure your database server is running before you attempt to connect.
- If you encounter any issues, check the console logs for error messages—they can provide clues for troubleshooting.
- Consider using a
.env
file or similar for sensitive information like database credentials to enhance security.
If you have any specific questions or run into issues during the setup, feel free to ask!
- GET /products: List all products.
- POST /products: Add a new product.
- GET /categories: List all categories.
- POST /cart/add: Add an item to the cart.
- POST /cart/remove: Remove an item from the cart.
- POST /auth/login: Log in and receive a JWT.
- POST /auth/register: Register a new user.
- Entity Classes: Represent database tables (e.g., Product, User, Order).
- Repository Layer: Interfaces extending
JpaRepository
for database interactions. - Service Layer: Contains business logic for handling operations.
- Controller Layer: REST API endpoints for application interaction.
- DTOs: Used for data transfer between layers.
The project uses Spring Security with JWT-based authentication:
- UserSecurityService: Custom user details service.
- JWT Util: Manages JWT creation and validation.
- SecurityConfig: Configures security filters and endpoint restrictions.
- Users log in via /auth/login to receive a JWT.
- The JWT is included in request headers for authentication and authorization.
- Unit Testing and Integration Testing are employed to verify core functionality.
- Manual API testing is conducted using Postman.
If you have any specific questions about implementing these features or need further assistance, feel free to ask!