The Grocery Express Web Application satisfies the client's requirements. In addition, four significant architectual improvements were made:
- Performance: Utilized in memory database for better performance. The application is integrated with Redis cache, and minimizing the amount of network calls by using cache rather than sending request to the database
- Configurability: Built a front-end UI with thymeleaf. The web UI will make our application more user friendly.
- Authentication/Authorization: See Steps 6.
- Security: See Steps 6.
- MySQL Database
- Java 11+
- JAVA IDE: e.g., IntelliJ IDEA
- Maven 3.0+
- Redis 6.2+
- Spring Web: to build restful web app.
- Spring Data JPA: persist data in SQL store.
- MySQL Driver
- Spring Security: authentication, authorization, encryption
- Spring Data Redis: in memory database for better performance
- Thymeleaf: html template engines.
- Open the project in IDE:
- Under src/main/resources, change the application properties:
- Followings are the project default settings:
Change the default database username (spring.datasource.url=jdbc:mysql://localhost:3306/6310Team045?useSSL=false spring.datasource.username=root spring.datasource.password=password
root
), password (password
), and mysql server port (3306
) to match your own mysql server! - Create a database for the application:
- Open a terminal (command prompt in Microsoft Windows) and open a MySQL client as a user who can create new users.
- For example, on a Linux system, use the following command (replace root with your username):
$ mysql -u root -p
- To create a new database, run the following commands on mysql CLI:
mysql> Create database 6310Team045; mysql> Use 6310Team045;
- You can use the mysql GUI tool such as MySQL Workbench, just create a database
6310Team045
which the spring web application can run on.
- Start Redis server
- If Redis is not installed: Download from Redis website, or type
brew install redis
on command if using Homebrew for Mac and Linux. - Type
redis-server
orbrew services start redis
on command line to start the Redis server. The application uses the default Redis port of 6379. - Use
redis-cli monitor
in a terminal window to log Redis requests. - You can confirm the Redis cache is being utilized on repeated requests when there is no 'SET' invocation following the initial 'GET' request.
- If Redis is not installed: Download from Redis website, or type
- Run application:
- Run the spring application in IDE. Another option is run the jar file,
using the following command
mvn package
to first create the jar file, then run the jar file byjava -jar target/Team045-0.0.1-SNAPSHOT.jar
. - Homepage at
http://localhost:8080
- From homepage, you can login into the system as
USER
orADMIN
. Details see Steps 6 below. - Note: Only admin user has the authority to create customer user account in current version due to the
restriction on setting user
credit
.
- Run the spring application in IDE. Another option is run the jar file,
using the following command
- User authentication and authorization and password encryption:
- By default, there are two types of users:
ADMIN
andUSER
. The authenticating users information are stored inauth_user
table.- Customer users (
USER
) are allowed todisplay my orders
,start new order
,request item
,purchase order
, andcancel order
. - In addition to all
USER
's rights/privileges, admin users (ADMIN
) are allowed tomake store
,make pilot
,make drone
,stock item
,display stores
,display customers
,display pilots
,display items of a store
,display drones of a store
,display orders of a store
.
- Customer users (
- The authenticating user password is encrypted by
BCryptPasswordEncoder
. Details see BCryptPasswordEncoder documentation. - Once the application has started, you need to create a root
ADMIN
user (the username and password are bothadmin
):INSERT INTO auth_user ( username, password, role ) VALUES ("admin", "$2a$12$Qpk7f3lC63mOmqejFmPVZukoBVqEQp0CSSHunIYhPdtdLGVxhxwdO","ADMIN");
- By default, there are two types of users:
- When finished:
- Close the spring web server
- Shut down redis server:
ctrl + c
- Shut down mysql server if it is no longer be needed.