Server application created for the Smart Cart TUM project during the Introduction to CPS course.
- System-specific Docker.
- Java SE Development Kit 17.
- Kubernetes Minikube.
- Gradle (Optional).
- Firebase instance, required to store the data.
- Ngrok account to expose the server to the internet.
- Tmux to run the server on the background and be able to access it at any time (Optional).
Everything is stored in the corresponding collection/document in the database.
Every request is done with the use of query parameters: cartId and itemId.
- Store the items in the cart.
- Update the items quantity in the cart. Increase the quantity for the POST request and decrease the quantity for the DELETE request, only if the item already exists.
- Delete the item from the cart if the quantity of the item is one.
- Retrieve the list of all items in the cart.
You should perform the following steps in your Firebase instance:
- Create an items collection, it will store the available items, this collection won't be changed by the server. Must be filled in manually or create a new class/method to do it automatically.
- Create a registered-items collection, it will store IDs of the existing carts, this collection won't be changed by the server. Must be filled in manually or create a new class/method to do it automatically.
- Create a carts collection, it will store the cart document, this document will include the collections of the carts items that actually contains the items documents. Updated by the server.
To run the server perform the following steps:
- Create a file named serviceAccount.json in the /src/main/resources/ folder that will contain Firebase admin credentials, see Admin SDK. It is required to access the database.
- Connect to your ngrok account, follow the official setup.
- Simply run the deploy.sh script, read the comments to understand what it does.
- To clean up run the cleanup.sh script, read the comments to understand what it does.
