-
We can run our application on the localhost or in the cloud, using a RDS instance, for example. For a production environment, change the
analysis_config.yml
andstats_config.yml
, changing the database connection. -
We can simulate our application on localhost with docker-compose. Run the command:
docker-compose build
. We should have 3 images:
- mysql_image (optional): You can use this image if you want a localhost connection
- analysis_service_image
- stats_service_image
- We can run our applications with the command:
docker-compose up
. We should then have 3 running containers:
- mysql_image (optional): In a production environment, you could use a RDS instance, for example
- analysis_service_image: The service responsible for processing new Simian Analysis. (POST) => http://localhost:8080/simian
- stats_service_image: The service responsible for retrieving computed Simian Stats. (GET) => http://localhost:8090/stats
- You also can redirect your machine localhost to your container localhost with the following nginx setup on
sites-available
folder:
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
proxy_pass http://127.0.0.1:12345/;
}
}
- Run
mvn clean install
to build your application - Create a mysql schema, for example
ml_simian
- Setup your database configurations (mysql user, mysql password, mysql host and schema name) inside the
config.yml
- Run database migrations with
java -jar target/ml-simian-analysis-1.0.jar db migrate config.yml
ORjava -jar target/ml-simian-stats-1.0.jar db migrate config.yml
- Start application with
java -jar target/ml-simian-analysis-1.0.jar server config.yml
ORjava -jar target/ml-simian-stats-1.0.jar server config.yml
- To check that your application is running enter url
http://localhost:8080
There are unit tests in this project. You can run it with mvn clean test
Resources
are responsible for handling HTTP requestsServices
are responsible for handling the business logicDAOs
are responsible for database connections
- You can add a new DNA sequence with a
POST method
on the URLwww.grcampos.com/simian
:curl --header "Content-Type: application/json" --request POST --data '{"dna": ["ATGCGA", "CAGTGC", "TTATGT", "AGAAGG", "CCCCTB", "TCACTG"]}' http://www.grcampos.com/simian
- You can check the results with a
GET method
on the URLwww.grcampos.com/stats
:curl --header "Content-Type: application/json" --request GET http://www.grcampos.com/stats
- The project is running on an AWS EC2 server and a AWS RDS. Both are very small machines and may fail. Please, feel free to contact me if the server is not reachable or if you need to clear the database.
- For the coding algorithm, I assumed that the DNA sequence should be case insensitive. Besides, a sequence with more than 4 equal characters should still count as a single sequence
- Invalid DNA sequences does not sum up on the
count_human_dna
property, but both bad formatted DNA's and human DNA's, returns a 403 status
grcampos21@gmail.com | (11) 99117-6997