Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.

README.md

Logistics

License: MIT Build status Quality Gate Known Vulnerabilities Docker Build status Docker Pulls Demo Application

The goal of the Logistcs application is find out the best route between two places within a map. Once created, add routes to the map, as following:

Origin Destination Distance (Km)
A B 10
B D 15
A C 20
C D 30
B E 50
D E 30

The best route is the cheapest one, considering the truck autonomy (Km/l) and the fuel price (l). Based on the routes above, if the truck has to go from place A to place D, its autonomy is 10 Km/l and the litre of the fuel cost $2.50, the best route will be A -> B -> D, because it's the cheapest one: $6.25.

Quality Assurance

The Logistics application has quality in its core. Beyond unit tests, the following projects were developed in order to validate the whole solution:

Project Test type Build status
logistics-test-arquillian Integration test Build status
logistics-test-restassured API test Build status
logistics-test-selenium UI test Build status
logistics-test-jmeter Load test Build status

Logistics' tests

Static code analysis

The application code quality is evaluated with SonarQube. If you want to run the SonarScanner for Maven in order to take a look at the static code analisys' results, firstly execute (requires Docker):

docker run --name sonarqube -p 9000:9000 -d sonarqube:8.4.1-community

And then, execute (requires JDK 11 and Maven):

mvn clean install sonar:sonar

After running the analysis, the Logistics application dashboard will be available in http://localhost:9000/dashboard?id=br.com.esign%3Alogistics.

The CI/CD Pipeline

Each push to this repository triggers the pipeline below:

  1. Travis CI clones this GitHub repository;
  2. After compiling and performing several unit tests in the application source code, Maven triggers the SonarQube static code analisys, and the results are sent to SonarCloud;
  3. Once generated the Java artifacts, they are deployed to Sonatype OSSRH, a Nexus Repository Manager instance Sonatype uses to provide repository hosting service to open source projects binaries;
  4. The application EAR file is deployed in a Wildfly instance avaliable at esign.com.br. From there, the Logistics application connects to a MongoDB instance hosted by MongoDB Atlas;
  5. Several tests are triggered asynchronously. Each one is performed against the Wildfly instance where the latest version of application was deployed.

Logistics' pipeline

Running with Docker

You can run the application as a Docker container. Install Docker and then run:

docker run --name logistics -p 8080:8080 -e MONGODB_URI=mongodb://username:password@host:port/logistics -d esignbr/logistics

The environment variable MONGODB_URI is mandatory and must set the MongoDB connection URI. Remember to replace username and password with your MongoDB credentials as well as host and port with the appropriate values, according with where your MongoDB instance is avaliable on.

The Logistics application can also be executed along with MongoDB by using Docker Compose. If you've already installed Docker and Docker Compose, clone the repository and then run:

docker-compose up -d

The application will be available through the URL http://localhost:8080/logistics in your browser.

Deploying to a local VM

Alternatively, you can deploy both the application and the database to a local VM, by using the Ansible playbook. If you want to know how it works, first install Ansible, VirtualBox and Vagrant, and then run:

vagrant up

Vagrant will download the codeyourinfra/docker Vagrant box (if it was not done yet), then will bootstrap the local VM and at the end will trigger the Ansible playbook execution.

Once the local VM is up, open the URL http://192.168.33.10:8080/logistics in your browser, and give the Logistics application a try.

Finally, if you want to cleanup everything, execute the command:

vagrant destroy -f && rm -rf .vagrant/

Deploying to AWS

If you've already installed Ansible, you can make the deployment in the cloud too. In spite Ansible has support to several Cloud providers, at the moment we only provide a playbook to deploy Logistics into an EC2 instance of AWS. Once you have your AWS credentials, run:

ansible-playbook deploy-to-aws.yml

Ansible uses Boto 3 in its Amazon modules. During the execution, the playbook creates all the infrastructure required for accessing the application through the Internet. The AMI used is codeyourinfra/docker, one of the Codeyourinfra's AWS AMIs.

Right after the deployment, check the output to find out what is the EC2 instance public IP address. You can get the IP from the inventory.yml file as well. Then, open the Logistics' URL in your browser, replacing the IP with the one you've just got. Finally, if you want to undo everything, just run:

ansible-playbook undeploy-from-aws.yml

Logistics API

The Logistics API documentation is generated through Swagger and can be checked by accessing the /logistics/docs endpoint, after deploying the application. In the Esign Consulting website, for example, the Logistics API documentation is available on http://www.esign.com.br/logistics/docs.

Feature toggles

The Logistics application has a feature toggles admin console that comes with Togglz. The console can be accessed through the /logistics/togglz endpoint, after deploying the application. In the Esign Consulting website, for example, the Logistics Feature Flags console is available on http://www.esign.com.br/logistics/togglz.

About

Demo application to create maps with routes in order to find out the best way to deliver products.

Topics

Resources

License

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  
You can’t perform that action at this time.