This repository contains my Test Project, thank you for taking the time to read this documentation. If you want me to implement some new feature, fix something or give any further detail don't hesitate on reaching me at chamatoscar@gmail.com.
The easiest way to test is to connect to the server provided in the email and follow easy-testing.md
- Assuming you have the repository cloned already
- In linux run
sudo chmod -R 755 hproperties/*
This is what you need to install in your computer
Docker
https://docs.docker.com/install — Install Docker for different operating system. See documentation.Docker Compose
https://docs.docker.com/compose/install/ — Install Docker Compose for macOS, Windows, and Linux
- Some configurations are dependant of the .env file. You need to rename the file ./.env.bk to .env keeping them in their own respective directory.
- The database you specify in the .env needs to exist and have the same data of the testing database
- To run the rest service just do ->
docker-compose up -d
-
If you want to test in a visual manner here is the url to the project in postman ->
- You can also see some examples of the urls.
-
In general in the
you can see how to run the rest application with curl
-
You can also review the tests that you run with:
docker-compose run rest-service python -m pytest
I implemented the test project as a Rest Api in Flask.
- Docker machines with an up to date installation.
- Docker compose files to make easier the use of Docker and the deployment.
- Design of the Database.
- Creation of the Rest Api in Flask.
- Creation of the Rest Api documentation in postman to simplify testing.
- Creation of the tests of the Rest Api in Flask to increase quality and understanding.
- Creation of a nginx production server for the rest-service in Flask to make it more secure and scalable.
- An installation in AWS is created, configuring the ports, billing alarms, proper users for the database for easy testing.
- The database is kept local and not in an RDS due to cost of the machines.
- Details; documentation, private variables and methods, custom error messages and providing tool to reduce the complexity of testing.
- There are two diagrams for easy modification: https://drive.google.com/file/d/17kkrtO9Zbq8PKwiK7um4zBZ57A9AYcXF/view?usp=sharing (but they have been generated in another tool)
- We expect you to send a variation this data to the url via GET parameters:
{
'status': 3,
'year': 2020,
'city': 'bogota',
'next': 0
}
- Which is in another words this url:
localhost:5000/property?status=3&year=2020&city=bogota&next=0
- The next parameter handles pagination and is optional (as all other parameters)
- The like functionality is designed by creating a many-to-many table between the user table, and the property table that way assuring that a registered user can like a property.
- updated_date is added to help with data mining tasks although those can be leveraged from the logs.
- The sql code is added in like_table.sql
- To increase the speed we added a column in property that points to the last record in status_history for the property so that the sql interior query is reduce from the normal:
select p.address, p.city, sh_max.status_id, p.price, p.description, p.year
from property p join
(select MAX(sh.update_date), sh.property_id, sh.status_id
from status_history sh group by sh.property_id
) as sh_max
where p.id = sh_max.property_id
and sh_max.status_id in (3,4,5)
to
select p.address, p.city, sh.status_id,
p.price, p.description, p.year,
sh.update_date, sh.property_id, sh.status_id
from property p join status_history as sh
where p.last_status_history = sh.id
and sh.status_id in (3,4,5)
Which can lead to a big decrease in running time given that the status of a property can theoretically change a lot.
- The sql code is added in reduce_queries.sql
- Having in consideration the modification is done after some data exist in the database the NOT NULL constrain in the new column is avoided but is something the programmers must have in consideration.
- Different notes of design provided in the file minor-notes.md
Thanks for reading this far, I wish you a good day, and I'm very looking forward to an interview with you.