A fully distributed RESTful warehouse server following a microservice architecture.
This project was developed with the intention to learn technologies such as the microservice architecture, RESTful APIs, MongoDB (NoSQL database), message queueing using RabbitMQ and docker compose.
A warehouse management application provides the perfect use case to implement above-mentioned technologies at scale.
The system uses the following tech stack:
- Server side: Flask RESTful (Python)
- Database: MongoDB Atlas
- Message Queueing: RabbitMQ
- Deployment: Docker
The system consists of four client facing RESTful services: balance-service
, product-service
, location-service
, movement-service
.
When making a POST request to the movement-service
(localhost:8003
), i.e. creating a new movement of a product, request body is published to the movement_log
queue.
Upon publishing the message, the movement-log-consumer
service consumes this message, parses through the request body and allocates the product into the balance database by making RESTful calls to the balance-service
.
External URL: localhost:8001
A GET
request can be made to the given URL to view the list of products.
A POST
request can be made to the given URL to add a new product in the database.
The required fields in the request JSON body are product_name
and product_description
.
The post body must look something like below:
{
"product_name": "YOUR PRODUCT NAME",
"product_description": "YOUR PRODUCT DESCRIPTION",
.
.
.
}
External URL: localhost:8002
A GET
request can be made to the given URL to view the list of warehouse locations.
A POST
request can be made to the given URL to add a new location in the database.
The required fields in the request JSON body are location_name
, location_latitude
and location_longitude
.
The post body must look something like below:
{
"location_name": "YOUR LOCATION NAME",
"location_latitude": "YOUR LOCATION LATITUDE",
"location_longitude": "YOUR LOCATION LONGITUDE",
.
.
}
External URL: localhost:8003
A GET
request can be made to the given URL to view the list of product movements between locations.
A POST
request can be made to the given URL to add a new product movement.
The required fields in the request JSON body are from_location
, to_location
, product_id
and qunatity
,
where from_location
and to_location
are location IDs that are generated once locations have been added to the database and can be obtained while viewing locations,
and likewise for product_id
. The quantity
value must be of type integer and greater than 0.
The post body must look something like below:
{
"from_location": "LOCATION_ID",
"to_location": "LOCATION_ID",
"product_id": "PRODUCT_ID",
"quantity": "QUANTITY<int>"
}
Note: If the product is being added to a location, the from_location
can be empty.
If the product is being moved out of a location, to_location
can be empty.
If the product is being moved between locations, both from_location
and to_location
must be provided.
External URL: localhost:8000
Product balance in respective warehouses can be viewed by making a GET
request to the given URL.
Make sure to have Docker installed on your machine. Once docker daemon is up and running, navigate to the root directory of the project and run the following command:
docker-compose up
This will build and run the services with the configuration specified in the docker-compose.yml file.
Each service can be accessed externally using localhost:{PORT}
where PORT is specified under each service.