This is a Spring Boot application designed to manage an ecommerce platform. It includes functionalities for different user roles such as Admin, Employee, and Customer, and provides various features like role-based authentication, product management, and order processing.
- Roles
- Technologies Used
- Concepts Used
- Public Functionalities
- Private Role-Based Functionalities
- Setup Instructions
- Environment Variables
- Running the Application
- Spring Boot
- Spring Security
- Spring Data JPA
- Hibernate
- Docker
- JWT (JSON Web Tokens)
- Lombok
- MySQL
- JUnit
- Mockito
To run this project locally, follow these steps:
-
Clone the repository:
git clone https://github.com/Pruthvik007/SampleEcommerceApplication.git cd SampleEcommerceApplication
-
Ensure Docker is installed on your machine.
-
Create a
.env
file in the root folder of the project and add values for the following keys:MYSQL_DATABASE=your_database_name MYSQL_USER=your_database_user MYSQL_PASSWORD=your_database_password MYSQL_ROOT_PASSWORD=your_root_password JWT_SECRET=your_jwt_secret ADMIN_NAME=your_admin_name ADMIN_EMAIL=your_admin_email ADMIN_PASSWORD=your_admin_password
-
Build and run the application using Docker Compose:
docker-compose up --build
The application requires the following environment variables to be set:
MYSQL_DATABASE
: The name of the MySQL database.MYSQL_USER
: The MySQL database user.MYSQL_PASSWORD
: The password for the MySQL database user.MYSQL_ROOT_PASSWORD
: The root password for MySQL.JWT_SECRET
: The secret key for JWT token generation.ADMIN_NAME
: The name of the admin user.ADMIN_EMAIL
: The email of the admin user.ADMIN_PASSWORD
: The password of the admin user.
Once the Docker containers are up and running, the application will be accessible at http://localhost:8080
.
You can use tools like Postman to interact with the API endpoints. Make sure to register a customer, log in, and use the JWT token for accessing protected routes.
- For customers, we need to register first.
- For all other roles (Admin, Employee, Customer), we need to log in first and send the JWT token under the Authorization tab as
Bearer <token>
for further requests.
The application includes custom exception handling for various scenarios such as:
UserException
OrderException
ProductException
CategoryException
These exceptions ensure that meaningful error messages are returned to the client.
The application supports the following order statuses:
CREATED
DELIVERED
CANCELLED
The application supports the following user statuses:
CREATED
VERIFIED
INACTIVE
For more details on the implementation, refer to the source code and the comments provided within the codebase.
Feel free to contribute to this project by submitting issues or pull requests. For major changes, please open an issue first to discuss what you would like to change.
Happy coding!