This project implements a web application for an Online Marketplace using the Spring Boot framework for the backend and ReactJS for the frontend. The application utilizes Spring Security for authentication and authorization, Hibernate with JPA for database operations, and MySQL as the database.
The Online Marketplace application is designed to handle products, sellers, users, and their interactions, including features such as user authentication, product management, and favorite/blacklist functionalities. It distinguishes between Admin and regular users, with Admins having additional privileges.
- Admins and Users: Users can log in to the system.
- Admin Capabilities:
- Add, delete, and update products, users, and sellers.
- Search and filter products, sellers, and users.
- User Capabilities:
- View a list of products.
- Add/remove products to/from the favorite list.
- Add/remove sellers to/from the blacklist.
- Search products by name and filter by category and brand.
- Two user roles: Admin & End-user.
- Spring Security for authentication and authorization.
- Hibernate with JPA annotations for database operations.
- MySQL for database storage.
- ReactJS for the frontend with routing, API handling, and state management.
Below are some screenshots of the application to give you an idea of its user interface:
Admin Home Page |
Admin Management Tool |
User Home Page |
User Favorite Product Page |
User Product Seller's Page |
User Black List Page |
- Backend:
- Spring Boot
- Spring Security
- Hibernate with JPA
- MySQL
- Lombok
- Frontend:
- ReactJS
- React Router
- Axios
- React Hooks (e.g., useEffect, useState)
- Model: Entity classes representing database tables (e.g., User, Product, Seller).
- Repository: Interfaces for data access operations (e.g., UserRepository, ProductRepository).
- Service: Business logic and service layer (e.g., UserService, ProductService).
- Controller: Handles HTTP requests and responses (e.g., UserController, ProductController).
- DTO: Data Transfer Objects for communication between frontend and backend (e.g., UserDto, ProductDto).
- Mapper: Converts between entity classes and DTOs (e.g., UserMapper, ProductMapper).
- Exception: Custom exceptions for error handling (e.g., UserNotFoundException).
- Security: Configuration for authentication and authorization (e.g., WebSecurityConfig, UserAuthDetails).
Follow the steps below to run the Online Marketplace application locally.
Make sure you have the following installed on your machine:
- Java 11 or later
- Maven 3.6+
- MySQL
-
Clone the Repository
git clone https://github.com/your-username/OnlineMarketPlace.git cd OnlineMarketPlace
-
Configure the Database
Create a new MySQL database:
CREATE DATABASE : your-database;
Update the
application.yaml
file with your MySQL credentials:spring: datasource: url: jdbc:mysql://localhost:3306/your-database username: your-username password: your-password
-
Build and Run the Application
Build and run the application using Maven:
mvn clean install mvn spring-boot:run
The application will be available at
http://localhost:8080
.
Update the application.yaml file in the backend directory to configure database connection and other settings. Ensure that the spring.datasource.url, spring.datasource.username, and spring.datasource.password fields are set correctly.
Open the following URLs in your browser:
- Backend: http://localhost:8080
- POST
/api/v1/login
Description: Authenticate a user.
- GET
/api/v1/users/{userId}
Description: Retrieve the details of a specific user by their user ID. - POST
/api/v1/users
Description: Create a new user. - DELETE
/api/v1/users/{userId}
Description: Delete a user by their user ID.
- GET
/api/v1/users/{userId}/favorites
Description: Retrieve the favorite products of a user. - POST
/api/v1/users/{userId}/favorites/{productId}
Description: Add a product to the user's favorite list. - DELETE
/api/v1/users/{userId}/favorites/{productId}
Description: Remove a product from the user's favorite list.
-
POST
/api/v1/users/{userId}/block-seller
Description: Block a seller for a user. -
GET
/api/v1/users/{userId}/blocked-sellers
Description: Retrieve the blocked sellers for a user.
- GET
/api/v1/products
Description: Retrieve a list of products. - GET
/api/v1/products/{id}
Description: Retrieve a product by its ID.
- GET
/api/v1/users/sellers
Description: Retrieve a list of sellers. - GET
/api/v1/users/sellers/{id}
Description: Retrieve a seller by their ID.