This project is a Ruby on Rails API that converts street addresses or places names to coordinates. This solution uses LocationIQ API, PostgreSQL is used as a database, Redis is used to cache api results and Swagger for API documentation.
There are two ways to run this project: with Docker or local.
Ruby version: 2.6.3
Rails version: 6.0.2
If you run this project local, you need to change config/database.yml
file, setting your own database configuration.
Example:
default: &default
adapter: postgresql
encoding: unicode
host: localhost
user: postgres
password: your_db_pass
port: 5432
After changes on database.yml
, you may run the script command sh start.sh
on the root project directory. This script file has all setup needed to install
dependencies, create database and run migrations, tests and also create a user showing a token that you need to consume the main api endpoint.
This project has a Dockerfile and docker-compose file to build all environment with two simple commands:
$ docker-compose build
$ docker-compose up
After installation, your API token will apear in terminal like this:
==============================================================================
YOUR BEARER TOKEN IS: eyJhbGciOiJIUzI1NiJ9.eyJlbWFpbCI6ImFkbWluQGFk ....
==============================================================================
Just copy that token to use on the API documentation: http://localhost:3000/api-docs
Click on the Authorize
button and paste your token to proceed.
After the token authorization, expand the endpoint item, and click on the Try it out
button, to show the parameter field to type an address or location name to find.
Example finding by checkpoint charlie
location name:
If you would like to run tests manually, in a local installation, just run in your terminal (root project directory):
$ bundle exec rails rspec
A test coverage report will appear on the end.
Coverage report generated for RSpec to /app/coverage. 105 / 105 LOC (100.0%) covered.
I chose to get data from API directly using a rest client instead of using the ruby solution for LocationIQ because LocatinIQ didn't test that solution. It is not a good practice to leave the master.key file in the project directory, but I did because of I still this repository private.