Giter Site home page Giter Site logo

green-payments's Introduction

Green Payments

This project implements a bank system where users can transact money.

Project setup

If you don't have installed elixir and phoenix. Follow the next links to see how to proceed: elixir & phoenix

For those that used asdf I added the .tool-versions file with a pre-defined elixir version to use.

To start your Phoenix server:

  • Run docker-compose up
  • Create and migrate your database with mix ecto.create
  • Create and migrate your database for test case MIX_ENV=test mix ecto.create
  • Start Phoenix endpoint with mix phx.server

To keep code legible, mix comes with a built-in formatter. It is used during development and on CI to check if the developer ran it. * mix format * mix format --check-formatted --dry-run

To check code consistency, this project uses Credo as a static code analysis tool and is also used on CI. Credo can be run by the following command. * mix credo

For checking tests coverage, the library excoveralls is used. It can be called by running mix coveralls (results on console) and mix coveralls.html to generate a html page holding results and code points in ./cover/excoveralls.html.

Some files were ignored from testing, like phoenix-generated functions and test support functions. The are listed in coveralls.json, inside the key skip_files.

Now you can visit localhost:4000 from your browser.

Ready to run in production? Please check our deployment guides.

Learn more

About project configuration

This project follow some recomendation José Valim and an awesome team of developers releases

How to use the API

Here are the examples for calling the API

VERBS Endpoints
POST /api/v1/signup
POST /api/v1/login
GET /api/v1/accounts/:account_id/history
POST /api/v1/accounts/:account_id/transactions/withdraw
POST /api/v1/accounts/:account_id/transactions/transfer/:credit_account_id
  • Create an user and account:

{
   "account":{
      "id":3,
      "agency":1,
      "number":3,
      "balance":100000
   },
   "auth":"JWT-TOKEN",
   "error":null,
   "user":{
      "id":1,
      "first_name":"Marcelo",
      "last_name":"Jasek",
      "registration_id":"03323829077",
      "email":"[email protected]"
   }
}
  • Login to an account:

{
   "auth":"JWT-TOKEN",
   "error":null,
   "user":{
      "id":1,
      "first_name":"Marcelo",
      "last_name":"Jasek",
      "registration_id":"03323829077",
      "email":"[email protected]"
   }
}
  • Account withdraw

{
   "account":{
      "id":1,
      "agency":1,
      "number":1,
      "balance":100000
   },
   "error":false
}
  • Transfers between accounts

{
  "credit_account": {
      "id": 2,
      "agency": 1,
      "number": 2,
      "balance": 100343
  },
  "debit_account": {
      "id": 1,
      "agency": 1,
      "number": 1,
      "balance": 99602
  },
  "error": {
      "credit": null,
      "debit": null
  }
}
  • Retrieving an account history:

{
   "error":false,
   "history":{
      "items":[
         {
            "type":"credit",
            "amount":100000
         }
      ],
      "total_credit":100000,
      "total_debit":0
   }
}

Deployments

Application is currently hosted on Heroku at https://green-payments.herokuapp.com/.

green-payments's People

Contributors

marcjal avatar

Watchers

 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.