Giter Site home page Giter Site logo

trading_api's Introduction

Trading API

This project is a Ruby on Rails API for UN/LOCODE search.

The project download locodes zip file from UNECE, then unzip csv files and import all content to a PostgreSQL database.

The API endpoints could be checked with an Swagger documentation at the /api-docs endpoint.

Getting Started

There are two ways to run this project: with Docker or local.

Running 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 ,run migrations, tests and also download and import locodes to database.

Running with docker

This project has a Dockerfile and docker-compose file to build all environment with two simple commands:

$ docker-compose build

$ docker-compose up

API documentation: http://localhost:3000/api-docs

Running with local kubernetes cluster (docker-desktop)

Is possible to deploy this project into a local kubernetes cluster, using the following command in the project root directory:

docker stack deploy --compose-file docker-compose.yml trading-api

After deployment, whe project will take some time to download whe zip file, unzip and then import all data from csv files.

screen

If you want to follow the import proccess, is possible using the logs action on the menu below:

screen

.

screen

.

API Documentation

Is possible to test the API endpoints using the button "Try out" inside each endpoint on http://localhost:3000/api-docs.

screen screen

Running the tests manually

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.

Final considerations

It is not a good practice to leave the master.key file in the project directory, but I did because I leave this repository private.

The Postgres instance inside a docker container is not a good practice for production environments, just for testing.

There are a lot of possible improvements to this project, for example, using Redis for caching and writing more test units. But the main point was to show some skills that I have working in a backend project.

trading_api's People

Contributors

tobiaseggers avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.