Coder Social home page Coder Social logo

ahmedalaahagag / go-bank-transfer Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gsabadini/go-clean-architecture

1.0 1.0 0.0 19.34 MB

Simple API for banking routines using a Clean Architecture in Golang. :credit_card: :moneybag: :money_with_wings:

License: MIT License

Shell 0.24% JavaScript 0.24% Go 96.79% Makefile 2.26% Dockerfile 0.47%

go-bank-transfer's Introduction

Welcome to Go Bank Transfer 🏦

Version Build License: MIT Build

  • Go Bank Transfer is a simple API for some banking routines, such as creating accounts, listing accounts, listing balance for a specific account, transfers between accounts and listing transfers.

Architecture

Clean Architecture

Example create account use case

Clean Architecture

Requirements/dependencies

  • Docker
  • Docker-compose

Getting Started

  • Environment variables
make init
  • Starting API in development mode
make up
  • Run tests in container
make test
  • Run tests local (it is necessary to have golang installed)
make test-local
  • Run coverage report
make test-report
make test-report-func
  • View logs
make logs

API Request

Endpoint HTTP Method Description
/v1/accounts POST Create accounts
/v1/accounts GET List accounts
/v1/accounts/{{account_id}}/balance GET Find balance account
/v1/transfers POST Create transfer
/v1/transfers GET List transfers
/v1/health GET Health check

Test endpoints API using curl

  • Creating new account

Request

curl -i --request POST 'http://localhost:3001/v1/accounts' \
--header 'Content-Type: application/json' \
--data-raw '{
    "name": "Test",
    "cpf": "070.910.584-24",
    "balance": 100
}'

Response

{
    "id":"5cf59c6c-0047-4b13-a118-65878313e329",
    "name":"Test",
    "cpf":"070.910.584-24",
    "balance":1,
    "created_at":"2020-11-02T14:50:46Z"
}
  • Listing accounts

Request

curl -i --request GET 'http://localhost:3001/v1/accounts'

Response

[
    {
        "id": "5cf59c6c-0047-4b13-a118-65878313e329",
        "name": "Test",
        "cpf": "070.910.584-24",
        "balance": 1,
        "created_at": "2020-11-02T14:50:46Z"
    }
]
  • Fetching account balance

Request

curl -i --request GET 'http://localhost:3001/v1/accounts/{{account_id}}/balance'

Response

{
    "balance": 1
}
  • Creating new transfer

Request

curl -i --request POST 'http://localhost:3001/v1/transfers' \
--header 'Content-Type: application/json' \
--data-raw '{
	"account_origin_id": "{{account_id}}",
	"account_destination_id": "{{account_id}}",
	"amount": 100
}'

Response

{
    "id": "b51cd6c7-a55c-491e-9140-91903fe66fa9",
    "account_origin_id": "{{account_id}}",
    "account_destination_id": "{{account_id}}",
    "amount": 1,
    "created_at": "2020-11-02T14:57:35Z"
}
  • Listing transfers

Request

curl -i --request GET 'http://localhost:3001/v1/transfers'

Response

[
    {
        "id": "b51cd6c7-a55c-491e-9140-91903fe66fa9",
        "account_origin_id": "{{account_id}}",
        "account_destination_id": "{{account_id}}",
        "amount": 1,
        "created_at": "2020-11-02T14:57:35Z"
    }
]

Git workflow

  • Gitflow

Code status

  • Development

Author

License

Copyright © 2020 GSabadini. This project is MIT licensed.

go-bank-transfer's People

Contributors

gsabadini avatar fabianoleittes avatar

Stargazers

Roman avatar

Watchers

James Cloos 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.