Bank account opening - Code Challenge

Code challenge related to creating an API that supports requests for creating and editing accounts.

The API documentation can be found here

An example of the working API here

Stack

This project was built using the technologies and some gems below:

Getting started

After cloning the repository:

$ git clone git@github.com:apsferreira/code-challenge-bank-account.git

Access the folder created when downloading the repository:

$ cd code-challenge-bank-account

Build and deploy

It is necessary to initially rename the env_example file to .env and set the appropriate settings related to your local environment.

run the command below to install the gems configured in the project

$ bundler install

With Docker and Docker Compose

Assuming that the docker and docker-compose are installed, execute the command below:

$ rake up:dev

This command will configure and create all the necessary containers to start the project development.

After creating all the containers, the bank can be populated by running the command below:

$ rake db:seed

More commands here

With local rails configuration

For this case we will assume that the local environment is configured and reflected in the .env file. configured in the previous section, along with potgres and other settings.

rails db:create db:migrate 

then, to start the application run the command below

rails s -b 0.0.0.0

After installations, the API can be checked at:

 http://localhost:3000/api/v1/alive

Or execute the comannd on your console:

$ curl -i -H "Accept: application/json" -H "Content-Type: application/json" -X GET http://localhost:3000/api/v1/alive

Features

All the features requested in the challenge were implemented, as an improvement, it would add a greater amount of integration tests.

For the sake of time, I opted for a reasonable approach in the model of the account entity, assuming that encryption should only be performed when saving the record, I could use Active Record Callbacks (before_validate and before_save), but after several unsuccessful attempts, I opted for a simpler approach, and with that, I was not able to strictly follow the concept fat models and skinny Conrtoller.

For monitoring purposes, newrelic was integrated into the application, sidekiq (user: "root" and pass: "magnetis") were also integrated. Sidekiq for routine work processes and queues that require more time, leaving in the background, was considered sent to a confirmation or completion email account status (status completed), remained an idea for future implementations. was used as jwt to provide access to the application's endpoints. more information about the routes here. As another security measure, the rack-atack gem was used, where some solutions were configured, such as: not responding to the same ip after 5 simultaneous requests to the API. Thinking of a CI stream, travis was also configured in the application.

Newrelic

Alt text

Sidekiq

Newrelic

Tests

To start unit tests, execute the command below on the terminal:

$ rake test:all

To start watch unit tests, execute the command below on the terminal:

$ rake test:monitor

More commands

$ rake access:console   #access to rails console 
$ rake access:db        #access to psql 
$ rake access:logs      #access to logs of all containers
$ rake db:seed          #populate database
$ rake db:migrate       #run all migrations
$ rake db:reload        #run rails db:drop db:create db:migrate on database
$ rake down:dev     	#stop and remove all containers 
$ rake test:all     	#run all unit tests 
$ rake test:monitor     #run guard gem for watch all unit tests 
$ rake test:model   	#run unit tests of models
$ rake test:request     #run unit tests of requests 
$ rake up:dev 		#init and start all containers of dev
$ rake up:dev_monitor   #init and start all containers of dev with logs
$ rake up:reload    	#stop and start all containers
$ rake up:prd   	#build and push the last version of container application for prod 

License

Copyright Antonio Pedro Ferreira.

Released under an MIT License.