user-balance-transfer-service

In the context of banking, the term "debit" typically refers to a transaction that reduces the balance of an account or increases debt. On the other hand, the term "credit" typically refers to a transaction that increases the balance of an account or reduces debt. Therefore, it can be said that a debit is a withdrawal of money while a credit is a receipt of money.

To-Do

  • Add unit tests
  • Implement transfer between banks
  • Implement transfer from user to bank and vice versa
  • Implement refresh token
  • Implement limit of only 1 session per user
  • Improve clean code

API Documentation

Below are the available API endpoints for the project:

Migrations and Seeds

  • To run migrations, execute make migrate.
  • To initialize user data, run make seed-user.
  • To start the server, run make run.

Authentication

To log in, send a POST request to localhost:3000/auth/login with the following body:

{
    "email": "johndoe@mail.com",
    "password": "123456"
}

User Balance

Add balance

To add balance to a user's account, send a POST request to localhost:3000/user-balance/add with the following JSON body:

{
    "balance": "10000",
    "author": "irvan"
}

If successful, the API will return an OK response.

Get balance details

To get the details of a user's balance, send a GET request to localhost:3000/user-balance/. The API will return a JSON object with the following structure:

{
    "id": 80,
    "user_id": 1,
    "balance": 10000,
    "balance_achieve": 40000,
    "created_at": "2022-12-17T07:26:28.27784Z"
}

Transfer balance between users

To transfer balance between users, send a POST request to localhost:3000/user-balance/transfer/ with the following JSON body:

{
    "to_user_id" : 2,
    "balance": "100000",
    "author": "irvan"
}

If successful, the API will return an OK response.

Bank Balance

Create bank account

To create a bank account, send a POST request to localhost:3000/bank-balance/create with the following JSON body:

{
    "code":"ABCDE12345"
}` 

If successful, the API will return an OK response.

Add balance to bank account

To add balance to a bank account, send a POST request to localhost:3000/bank-balance/add with the following JSON body:

{
    "code": "ABCDE12345",
    "balance": "10000",
    "author": "irvan"
}

If successful, the API will return an OK response.