An inventory service use case with some basic endpoints and logic. Read UseCase.pdf for more details
Understanding and translating product needs. Considering performance and scalability.
1. /server
Inside this directory you fill find the project main code and logic.
2. /db
Inside this directory you will find the init.sql file which is the database schema of the project
Clone the repo
git clone https://github.com/MRmarioruci/inventoryService.git
Navigate inside the project directory
cd inventoryService
Build
docker-compose up
The server will restart a few times until the database has completed all operations and it connects succesfully
These steps follow the test case specified in the pdf file.
For testing ease I have added a phpmyadmin container so you can access the database quickly and easily
- Go to http://localhost:8080
- Username: user , Password: 1234567890
Table User
I have already added 3 users so that you can test quickly.
admin, counter 1 and counter 2.
Table ProductCategories
I have already added 2 categories, Food and Furniture
-
Endpoint to add Products.
-
Payload:
// Replace values accordingly { "username": "admin", "name": "AABB", "price": 1, "categories": [ 2 ], "subproducts": [ { "title": "A", "quantity": 2 }, { "title": "B", "quantity": 1 } ] }
{ "username": "admin", "name": "CC", "price": 2, "categories": [ 2 ], "subproducts": [ { "title": "C", "quantity": 1 } ] }
{ "username": "admin", "name": "DD", "price": 3, "categories": [ 1 ], "subproducts": [ { "title": "D", "quantity": 1 } ] }
-
Endpoint to build a CountPlan with a weekly schedule.
- Url: http://localhost:5000/addCountPlan
- Payload:
// Replace values accordingly /* Weekly Plan */ { "username": "admin", "name": "Weekly Plan", "repetition_type": "weekly", "repetition_interval": null, "day_of_week": 2, "start_time": "16:00:00", "start_date": "2023-05-27" }
-
Endpoint to build a CountPlan with a schedule of every 2nd Monday monthly (optional).
- Url: http://localhost:5000/addCountPlan
- Payload:
// Replace values accordingly /* Monthly Plan */ { "username": "admin", "name": "Monthly Plan", "repetition_type": "monthly", "repetition_interval": 2, "day_of_week": 1, "start_time": "09:30:00", "start_date": "2023-05-27" }
-
EXTRA Endpoint to build a CountPlan with a interval schedule. E.g every 10 days.
- Url: http://localhost:5000/addCountPlan
- Payload:
// Replace values accordingly /* Interval Plan */ { "username": "admin", "name": "Interval Plan", "repetition_type": "interval", "repetition_interval": 10, "day_of_week": null, "start_time": "14:15:00", "start_date": "2023-05-27" }
-
Endpoint to check the current CountPlan and start CountExecution if necessary based on the schedule.
- Url: http://localhost:5000/checkCountPlan
- Payload:
// Replace values accordingly { "username": "admin", "count_plan_id": 1 }
-
Endpoint to add UserProductCounts to CountExecution (allowed for admin and counter roles). (Make sure to go through phpmyadmin and get the relative barcodes. Simulates scanning a product)
- Url: http://localhost:5000/addCountToCountExecution
- Payload:
// Replace values accordingly { "username": "admin", "count_execution_id": 1, "barcode": "", "quantity": 3 }
-
Endpoint to end a CountExecution by changing its status to "end" (no more UserProductCounts can be added).
- Url: http://localhost:5000/endCountExecution
- Payload:
// Replace values accordingly { "username": "admin", "count_execution_id": 1 }
-
Calculate the pricing per Product based on the counted quantity in a CountExecution.
- Url: http://localhost:5000/getPricingPerProduct
- Payload:
// Replace values accordingly { "username": "admin", "count_execution_id": 1 }
-
Calculate the total pricing of all Products based on the counted quantity in a CountExecution.
- Url: http://localhost:5000/getTotalPricing
- Payload:
// Replace values accordingly { "username": "admin", "count_execution_id": 1 }
-
Calculate the pricing of Products by category in a CountExecution.
- Url: http://localhost:5000/getPricingByCategory
- Payload:
// Replace values accordingly { "username": "admin", "count_execution_id": 1 }