A retail store website (Backend) This Spring Boot based for a retail store website that do discount operations.
This project provides an API for login, registration and calculate bill .
The server handles requests to calculate bills by applying this discount cratieria:
- If the user is an employee of the store, he gets a 30% discount.
- If the user is an affiliate of the store, he gets a 10% discount.
- If the user has been a customer for over 2 years, he gets a 5% discount.
- For every $100 on the bill, there would be a $ 5 discount (e.g. for $ 990, you get $ 45 as a discount).
- The percentage based discounts do not apply on groceries.
- A user can get only one of the percentage based discounts on a bill.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
You need the following installed and available in your $PATH:
• Java 17 or newer
• Maven
• Docker
git clone https://github.com/anasdallah/store
cd store
./build-script.sh
You could find it inside sonar-report directory.
Once the container is running, you can import the postman colletion called "store.postman_collection.json"
Please note that there's alrady 4 users in the mongo db, with all types of users (Customer, Employee, Affiliate)
And All the passwords are same: "pass12345"
Usernames: affiliate employee customer_3_years customer_1_year
The system will generate JWT, to be used in calculate bill.
POST localhost:8080/auth/login
{
"username": "employee",
"password": "pass12345"
}
To register: POST localhost:8080/auth/register { "username": "anasdallah98", "password": "pass12345", "roles": [ "ROLE_CUSTOMER" ] }
To calculate bill, please take the JWT and pass it in with Bearer prefix.
Post localhost:8080/bill/calculate { "item_ids": ["1","2"] }
Note: There's mongo-express image if you want to see the data in mongo: http://localhost:8081/ admin:pass