Skip to content

nejckorasa/transfer-money

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

transfer-money

Build Status

Sample app for money transfers between accounts. It supports account creation with initial balance and issuing money transfers between accounts.

It is build using Javalin with Guice and Kotlin. Hibernate with H2 in-memory database.

Tested with JUnit5 and REST-assured

It includes examples for both DB locking and Thread locking.

Running

Server starts on: http://localhost:7000

To start the server:

./mvnw compile exec:java

Or build jar and run it:

./mvnw package && java -jar target/transfer-money-1.0-SNAPSHOT-jar-with-dependencies.jar

REST API

Click to expand!

Accounts

  • GET /api/accounts
    Get all accounts
    Successful response: 200
    Example response:

    [
      {
        "accountId": 1,
        "balance": 200.00
      },
      {
        "accountId": 2,
        "balance": 100.00
      }
    ]
  • GET /api/accounts/:id
    get account by id
    Successful response: 200
    Example response:

    {
      "accountId": 1,
      "balance": 200.00
    }
  • POST /api/accounts
    Create account
    Request body:

    {
      "balance": 200.00
    }

    Successful response: 201
    Example response:

    {
      "accountId": 1,
      "balance": 200.00
    }

Transfers

  • GET /api/transfers
    Get all transfers
    Successful response: 200
    Example response:

    [
      {
        "transferId": 1,
        "sourceAccountId": 1,
        "destinationAccountId": 2,
        "amount": 50.00,
        "createdAt": "2019-09-30T20:57:02.15",
        "status": "SUCCESS"
      },
      {
        "transferId": 2,
        "sourceAccountId": 1,
        "destinationAccountId": 2,
        "amount": 50.00,
        "createdAt": "2019-09-30T20:57:03.102",
        "status": "FAILED"
      },
      {
        "transferId": 3,
        "sourceAccountId": 1,
        "destinationAccountId": 2,
        "amount": 50.00,
        "createdAt": "2019-09-30T20:57:05.397",
        "status": "REQUESTED"
      }
    ]
  • POST /api/transfers
    Create transfer
    Request body:

    {
      "sourceAccountId": 1,
      "destinationAccountId": 2,
      "amount": 50.0
    }

    Successful response: 201
    Example response:

    {
      "transferId": 1,
      "sourceAccountId": 1,
      "destinationAccountId": 2,
      "amount": 50.00,
      "createdAt": "2019-09-30T20:57:02.15",
      "status": "SUCCESS"
    }

About

Sample app for money transfers between accounts

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages