This document includes also design specifications that may help the reader to understand how the system was developed and thinked, for build instructions please scroll down.
It's a multi-module project, which includes model, interfaces, persistence, service and webapp modules. Made with Java (Maven, Spring, JUnit, Jersey, ...), designed to scale (in runtime and in functionality), and focused in reducing time complexity in all layers.
It is recommended to use:
AWS Elastic Beanstalk is an easy-to-use service for deploying and scaling web applications and services developed with Java (among others). For more information regarding how autoscale works in Elastic Beanstalk please visit: https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.managing.as.html (basically auto manages EC2 instances on demand based on triggers such as requests quantity that can be configured at Beanstalk's environments)
The API was stress tested with two tools:
And monitored via the AWS Elastic Beanstalk's monitoring tool, indicating expected behaviour for more than 1000 requests per second.
$ POST /mutants
Content-Type: application/json
{
“dna”:["ATGCGA","CAGTGC","TTATGT","AGAAGG","CCCCTA","TCACTG"]
}
Returns
Reponse Code | Description |
---|---|
200 OK | Is Mutant |
403 Forbidden | Is Human |
400 Bad Request | The input was invalid |
$ GET /stats
Accept: application/json
Returns
$ {
“count_mutant_dna”:40,
“count_human_dna”:100:
“ratio”:0.4
}
The following instructions will set the development environment in your local machine, as well as let you run locally an instance of the system.
-
Clone the repository or download source code:
$ git clone https://github.com/mgrabina/mutants.git
-
Install Maven
$ brew install maven
$ sudo apt-get install maven
-
(Optional) Install PostgreSQL, if you want to use a local database.
$ brew install postgresql
$ sudo apt-get install postgresql
-
Install artifacts:
$ cd <project-root> $ mvn clean install
Doing this will let you access all modules defined in the project scope.
-
(Optional) Configure custom database.
In /mutants-webapp/src/main/java/meli/webapp/config/WebConfig.java, changing the parameters of the dataSource().
-
Build project itself:
$ mvn clean package
This will create a .war (Web ARchive) file inside /mutants-webapp/target.
-
Deploy .war file in a web server
4.a This can be done locally (with a Tomcat server for example)
https://tomcat.apache.org/tomcat-8.0-doc/deployer-howto.html
4.b Also can be done in a cloud (heroku for a simple example)
Having a new app configured in heroku (less than 1 minute) we can run this command in the to deploy it at heroku.
$ heroku war:deploy mutants-webapp/target/mutants-webapp.war --app NAME_OF_APP_IN_HEROKU