This is a e-commerce application built with Spring Boot for self study and exploring the technology. It provides a roust backend for managing products, categories, orders, user accounts, and more in an online shopping platform.
- Java 17
- Spring Boot 3.3.3
- Spring Data JPA
- PostgresSQL
- Maven
- Lombok
- JWT token Authentication and authorization
- User authentication and authorization
- Product management (CRUD operations)
- Category management
- Order processing and status updates
- Shopping cart functionality
- Wishlist management
- User profile management
- Address management
- Product reviews
- Admin dashboard
- Permission based access control
ecom-assign/
├── src/
│ ├── main/
│ │ ├── java/
│ │ │ └── com/
│ │ │ └── ecom_assign/
| | | ├── annotation/
| | | ├── config/
│ │ │ ├── constants/
│ │ │ ├── controller/
│ │ │ ├── dto/
│ │ │ ├── entity/
│ │ │ ├── exception/
| | | ├── filter/
│ │ │ ├── repository/
│ │ │ └── service/
│ │ │
│ │ └── resources/
│ │ └── application.properties
│ └── test/
│ └── java/
│ └── com/
| └── ecom_assign/
| ├── annotation/
| ├── constants/
| ├── controller/
| ├── entity/
| ├── filter/
| └── service/
└── pom.xml
-
Clone the Repository
-
Database Setup
Open PostgreSQL shell or pgAdmin and create a database named ecom_assign:
CREATE DATABASE your_db_name; -
Configure Application Properties
Open the src/main/resources/application.properties file and set the following configurations or you can add your configurations:
# Application Configuration spring.application.name=ecom-assign server.port=8080 # Database Configuration spring.datasource.url=jdbc:postgresql://localhost:5432/your_db_name spring.datasource.username=username spring.datasource.password=password spring.jpa.hibernate.ddl-auto=none spring.jpa.show-sql=false # JWT Configuration jwt.secret_key=lkjwsa2VjcmV0SakhfkhaenvlnbmluZ1B1cnBvc2VzMTIzNDU2Nzgkjsdfhsdferuh jwt.expiration_time=30000 jwt.refresh_expiration_time=900000 # Swagger Configuration springdoc.api-docs.path=/v3/api-docs springdoc.swagger-ui.path=/swagger-ui.html springdoc.swagger-ui.enabled=true -
Build and Run the Application
./mvnw clean install ./mvnw spring-boot:run -
Access the Application
The application will be running at: http://localhost:8080
Access Swagger UI for API documentation: http://localhost:8080/swagger-ui/index.html#/
To quickly set up the database and initialize the application:
- Create a new database.
- Run the script provided in the repository (
script.sql).
This script will:- Create all the necessary tables.
- Populate the database with initial data, such as roles, permissions, categories, and products.
- After running the script, create the
ADMINandUSERaccounts to access the APIs, as they require a JWT token for authorization.
Note: Ensure that the database connection details are correctly configured in the application before running the script.