Hello and welcome!
This is fabioaraujo121@gmail.com challange.
/answers
folder.
This projects uses Docker 🐳, straight forward, do the following:
- Building and running up:
docker compose up
- Connecting:
docker exec -it cloudwalk-web-1 /bin/bash
(or the container ID, if you will --docker ps
is helpful here) - Populating DB and trainning model
rails db:seed
- Done! ✅
- You can find the CSV with transaction in
db/seeds/transactional-sample.csv
. - The ML train happens while we do the seed.
- Validates if a transaction is trustful enough and return the recommendation.
To do so, we're using a "worst-case" based validation, which is simply a mix of rule-base and prediction-based validation. Whichever says the worst answer (deny) we take it as a deny.
- User cannot have any past Payment with chargeback.
- User cannot perform more than 1_000.0 amount in the past 24h (including the current payment).
- User cannot perform more than 1 payment in less than 5 minutes.
- Using Predictive Model to achive the goal. The train and validation data are based on the rule-based decisions above and from the list of payments available in the challange. We have a validation accuracy of 93.3%. Although, the train data is not the best one available, it shows and implements a possible path to the solution.
Creates the payment and returns the recommendation
Running with cURL:
curl -X POST http://localhost:3000/api/v1/payments -H "Content-Type: application/json" -H "AUTHORIZATION: Token secret" -d '{"transaction_id": 123, "merchant_id": 321, "user_id": 123321, "card_number": "434505******9116", "transaction_date": "2019-12-01T23:16:32.812632", "transaction_amount": 374.56, "device_id": 123321123321 }'
Example response:
{ "transaction_id": "123", "recommendation": "approve" }