To run this app You'll need:
- Docker
- Docker-Compose
Navigate to ./ecommapp directory and run docker-compose up --build
After running this command an exchange "ORDER_EXCHANGE" & Queue "shipping_queue" will automatically be created. You can view this with RabbitMQ management UI in the browser at http://localhost:15672/
Currently we have no users in the database and we're not logged in. Let's try to make an order while in this state.
We're not logged in therefore we're not authorized to create an order
The code to determine the current user is abstracted away in a custom made npm library. This allows for consistency when working within a team.
Here's creating a user. You must provide email in a correct format. Once a user has been created, the password is hashed in case the database gets compromised. Then a cookie will be returned from server indicating this user is logged in.
Once signed up, we're logged in with a cookie. This cookie indicates the current user logged in for all microservices. We can sign out and sign in with a new user. Whoever is logged in will be the current user across our microservices. (Using regular integers for id value for demonstrational purposes)
Currently the "Order" & "Shipment" database are empty.
We're currently logged in as Sally Mae & her userId is 4. She wants to order a Playstation 5 and a Mountain Bike. All she needs to do is pass in the list of products and the total fee will be calculated. (Entered totalFee of $5.99 in request body from an earlier test but it isn't needed. Total fee is calculated and returned in the response)
The order is sent to RabbitMQ's ORDER_EXCHANGE. The ORDER_ECHANGE sends this order to all queues connected to it. The shipping_queue is connected to this exchange and recieves the order. The shipping_service saves this information to its database automatically and prepares shipment.
Now John Doe, who has a userId of 3, is going to sign in & then purchase a Nintendo Wii and a BMX Bike.
PDF needs to be updated. Specifically on the database design & RabbitMQ Integration. Omitting Foreign Keys and SQL Joins. EcommerceApp.drawio.pdf