We will setup a movie streaming platform, where one API (`inventory`) will have information on the movies available and another one (`billing`) will process the payments.
In this exercise you will need to install Node.js (with Express, Sequelize and other packages), PostgreSQL, RabbitMQ, Postman, VirtualBox (or any equivalent software such as VMWare) and Vagrant.
While it may seems overwhelming at first there is a lot of resources available both on official website and on community blogs about setting up those tools.
Also the specific configuration details may change from platform to platform so don't hesitate to play around with it and be sure everything is installed correctly before to move on.
In order to test the correctness of your API you should use Postman. You could create one or more tests for every endpoint and then export the configuration so you will be able to reproduce the tests on different machines easily.
The Gateway will take care of routing the requests to the appropriate service using the right protocol (it could be HTTP for the Inventory API or RabbitMQ for for the Billing API).
The Gateway should be able to send messages to the API2 even if that API is not running. When the API2 will be started it should be able to process that message and send an acknowledgement back.
Good documentation is a very critical feature of every API. By design the APIs are meant for others to use, so there have been very good efforts to create standard and easy to implement ways to document it.
As an introduction to the art of great documentation you must create an OpenAPI documentation file for the API Gateway. There is many different ways to do so, a good start could be using SwaggerHub with at least a meaningful description for each endpoint. Feel free to implement any extra feature as you see fit.
> You must also create a `README.md` file at the root of your project with detailed instructions on how to build and run your infrastructure and which design choices you made to structure it.
Vagrant is an open-source software that helps you create and manage virtual machines. With Vagrant, you can create a development environment that is identical to your production environment, which makes it easier to develop, test, and deploy your applications.
Your VMs will be structured as follow:
-`gateway-vm`: This VM will only contain the `api-gateway`.
-`inventory-vm`: This VM will contain the `inventory-app` API and the database `movies`.
-`billing-vm`: This VM will contain the `billing-app` API, database `orders` and RabbitMQ.
> Vagrant is designed for development and should not be used in production environments.
##### Environment variables
To simplify the building process it is a common practice to store useful variables in a `.env` file. It will make very easy to modify/update information like URLs, passwords, users and so on.
> For the purpose of this exercise the `.env` file must be included in your repository, though usually in public and production projects the `.env` file is never included in repos to avoid sensitive data leaks.
##### Configuration of the VMs
- You will have a `Vagrantfile` which will create and start the three VMs. It will import the environment variables and pass them through each API.
- You will have a `script/` directory which will store all the scripts you may want to run in order to install the necessary tools on each VM. Those scripts may also be very useful for setting up the databases.
Your configuration will work properly for the following commands (executed from the root of the project):
When testing and before to automate it through the VM build you should be able to start the API Gateway and the two APIs by using the command `node server.js` inside their respective directories.
If you decide to use a different structure for your project remember you should be able to explain and justify your decision during the audit.
For clarity autogenerated files and directories like `node_modules` and `package-lock.json` have not been included in that tree.
> As a best practice it is strongly advised to add `node_modules` to your `.gitignore` in order not to upload useless files into your git repository (they will be autogenerated during the build process).