Table of Contents
The backend of a simple food delivery website.
Before cloning and using this application, you'll need to install these things on your computer:
- Java SE Development Kit 17: Of course you need to have Java installed to run a Java application. I used Java 17, but I think it works fine with the widely-used Java 8 (JDK 1.8), as well.
- Spring Tool Suite 4: an Eclipse-based IDE to develop Spring applications. It provides a ready-to-use environment to implement, run, deploy, and debug the application. It validates your application and provides quick fixes for the applications.
- Swagger 2: an open source project used to generate the REST API documents for RESTful web services. It provides a user interface to access our RESTful web services via the web browser.
- MySQL 8.0: an open source relational database management system that was originally released in 1995. MySQL is popular among all databases, and is ranked as the 2nd most popular database, only slightly trailing Oracle Database. Among open source databases, MySQL is the most popular database in use today and known as one of the most reliable and performative databases out there.
- H2 Database: an embedded, open-source, and in-memory database. It is a relational database management system written in Java. It is a client/server application. It is generally used in unit testing. It stores data in memory, not persist the data on disk.
- Power BI: a business analytics service provided by Microsoft that lets you visualize your data and share insights. It converts data from different sources to build interactive dashboards and Business Intelligence reports.
You can install this application by cloning this repository into your current working directory:
git clone https://github.com/theEmperorofDaiViet/eat-commerce.git
After cloning the repository, you can open the project by Spring Tool Suite.
Open the application.properties file in /src/main/resources to change the information about the datasource to fit your own settings. You can use H2 for testing in development, and use MySQL in production.
-
Configuration for MySQL:
spring.datasource.url=jdbc:mysql://localhost:3306/dbname spring.datasource.username=root spring.datasource.password=password spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver spring.sql.init.mode=ALWAYS spring.jpa.hibernate.ddl-auto=update
-
Configuration for H2:
spring.datasource.dbcp2.driver-class-name=org.h2.Driver spring.datasource.username=sa spring.datasource.password=password spring.jpa.database-platform=org.hibernate.dialect.H2Dialect spring.h2.console.enabled=true
Open MySQL or H2 and create a empty database with the name specified above.
- First, add the following dependencies in the pom.xml file:
<dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>2.9.2</version> </dependency> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger-ui</artifactId> <version>2.9.2</version> </dependency>
- Create Docket bean in SwaggerConfig.java to configure Swagger 2 for the application. We need to define the base package to configure REST API(s) for Swagger 2.
@Bean public Docket api() { return new Docket(DocumentationType.SWAGGER_2) .apiInfo(apiInfo()) .select() .apis(RequestHandlerSelectors.basePackage("com.educative.ecommerce")) .paths(PathSelectors.any()) .build(); }
- Finally, custom information about the API:
public ApiInfo apiInfo() { return new ApiInfoBuilder() .title("Ecommerce API") .description("API Documentation for Ecommerce") .version("1.0.0") .license("Apache 2.0") .licenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html") .contact(new Contact("theEmperorofDaiViet", "https://github.com/theEmperorofDaiViet", "Khiet.To.05012001@gmail.com")) .build(); }
- Step 1: Download and install Power BI Desktop
- Step 2: Open Power BI Desktop, select Get Data → More → MySQL
- Step 3: In the dialog appear, enter the hostname and the name of the database
- Step 4: Enter username and password of the DBMS
- Step 5: Select the tables which will be connect to Power BI.
↪️ Now you can visualize your data, uncover insights and make better decisions!
- Register
- Log in/Log out
- Browse products by name or category
- View product details
- Add a product to cart
- Place and pay an order (powered by Stripe)
- Ratings and comments
- View purchase history
- Add a product to bookmark
- Manage categories
- Manage products
- View all orders
- View statistics and data visualization (by Power BI)
You can contact me via: