Skip to content

a command-line java banking application with javalin rest api

Notifications You must be signed in to change notification settings

iannnop/banking-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Banking App

a java banking application with Javalin API

Installation

Clone the repository

git clone https://github.com/iannnop/banking-app.git

File Structure

├───.idea     # IntelliJ IDEA project settings
└───src   
    ├───main
    │   ├───java      # Java source files
    │   │   └───com
    │   │       └───revature
    │   │           ├───account       # Account model/dao/controller
    │   │           ├───jdbc          # JDBC ConnectionManager Singleton
    │   │           ├───exception     # Custom exceptions
    │   │           ├───transaction   # Transaction model/dao/controller
    │   │           └───user          # User model/dao/controller
    │   │
    │   └───resources 
    │   
    └───test
        └───java      # Java test files
            └───com
                └───revature
                    ├───account       # AccountTest methods
                    ├───jdbc          # ConnectionManagerTest methods
                    ├───transaction   # TransactionTest methods
                    └───user          # UserTest methods

Technologies

  • Java (Maven Project)
  • PostgreSQL
  • Javalin REST API

Maven Dependencies

  • Javalin REST API
  • Log4j
  • JUnit 4
  • Mockito
  • Gson (for parsing JSON strings in REST API request body)

Features

Customers

  • Customers of the bank should be able to register with a username and password and apply to open an account
  • Customers should be able to apply for joint accounts
  • Customers should be able to withdraw, deposit, and transfer funds between accounts

Employees

  • Employees of the bank should be able to view all customer information, including:
    • Account Information
    • Account Balances
    • Personal Information
  • Employees should be able to approve/deny open applications for accounts

Bank Administrators

  • Bank admins should be able to view and edit all accounts. This includes:
    • Approving/denying accounts
    • Withdrawing, depositing, transferring from all accounts
    • Canceling accounts

Javalin REST API

UserController Routes:

get-user

Get a user from the database

Route: /users/{username}

Method: GET

Response Body (JSON):

Successful response returns the JSON object of the requested User

{
  "id": 3,
  "role": "EMPLOYEE",
  "username": "npietrowicz6",
  "password": "o5MX1wqd2Z",
  "userCreated": 1651401461733,
  "firstName": "Nolan",
  "lastName": "Pietrowicz",
  "email": "npietrowicz6@slate.com",
  "phone": "913-886-9898",
  "address": "30924 Springs Road",
  "accounts": []
}
create-user

Creates a user account

Route: /users

Method: PUT

Request Body (JSON):

{
  "role": "CUSTOMER",
  "username": "johnsmith",
  "password": "123456",
  "firstName": "John",
  "lastName": "Smith",
  "email": "john@company.com"
}

Response Body (JSON):

Successful response returns the JSON object of the created User

{
  "id": 16,
  "role": "CUSTOMER",
  "username": "johnsmith",
  "password": "123456",
  "userCreated": 1651448905535,
  "firstName": "John",
  "lastName": "Smith",
  "email": "john@company.com",
  "phone": null,
  "address": null,
  "accounts": []
}
update-user

Update a user record in the database

Route: /users/{username}

Method: PUT

Request Body (JSON):

{
  "role": "EMPLOYEE",
  "password": "o5MX211353351Z",
  "firstName": "Nolan",
  "lastName": "Pietrowicz",
  "email": "npietrowicz2226@slate.com",
  "phone": "913-886-9898",
  "address": "30924 Springs Road"
}

Response Body (JSON):

Successful response returns the JSON object of the updated User

{
  "id": 16,
  "role": "EMPLOYEE",
  "username": "johnsmith",
  "password": "o5MX21351Z",
  "userCreated": 1651448905535,
  "firstName": "Nolan",
  "lastName": "Pietrowicz",
  "email": "npietrowicz2226@slate.com",
  "phone": "913-886-9898",
  "address": "30924 Springs Road",
  "accounts": []
}
delete-user

Delete a user from the database

Route: /users/{username}

Method: DELETE

Response Body (JSON):

Successful response returns the JSON object of the deleted User

{
  "id": 16,
  "role": "EMPLOYEE",
  "username": "johnsmith",
  "password": "o5MX21351Z",
  "userCreated": 1651448905535,
  "firstName": "Nolan",
  "lastName": "Pietrowicz",
  "email": "npietrowicz2226@slate.com",
  "phone": "913-886-9898",
  "address": "30924 Springs Road",
  "accounts": []
}

AccountController Routes:

get-user-accounts

Get all the accounts owned by the user

Route: /users/{username}/accounts

Method: GET

Response Body (JSON):

Successful response returns an array of JSON object of the accounts owned by the user

[
  {
    "id": 4,
    "accountCreated": 1651449818797,
    "status": "PENDING_APPROVAL",
    "balance": 200.99,
    "description": null,
    "transactions": [
      {
        "id": 8,
        "senderId": 0,
        "receiverId": 4,
        "transactionCreated": 1651449818873,
        "amount": 200.99,
        "type": "DEPOSIT",
        "description": "Starting balance deposit"
      }
    ]
  }
]
get-account

Get an account by account_id

Route: /accounts/{id}

Method: GET

Response Body (JSON):

Successful response returns a JSON object of the Account with the account_id

{
  "id": 4,
  "accountCreated": 1651449818797,
  "status": "PENDING_APPROVAL",
  "balance": 200.99,
  "description": null,
  "transactions": [
    {
      "id": 8,
      "senderId": 0,
      "receiverId": 4,
      "transactionCreated": 1651449818873,
      "amount": 200.99,
      "type": "DEPOSIT",
      "description": "Starting balance deposit"
    }
  ]
}
create-account

Applies for a user bank account

Route: /users/{username}/accounts

Method: PUT

Request Body (JSON):

{
  "startingBalance": 200.99
}

Response Body (JSON):

Successful response returns the JSON object of the created Account

{
  "id": 4,
  "accountCreated": 1651449818797,
  "status": "PENDING_APPROVAL",
  "balance": 200.99,
  "description": null,
  "transactions": [
    {
      "id": 8,
      "senderId": 0,
      "receiverId": 4,
      "transactionCreated": 1651449818873,
      "amount": 200.99,
      "type": "DEPOSIT",
      "description": "Starting balance deposit"
    }
  ]
}
update-account

Update the account with the account_id

Route: /accounts/{id}

Method: PUT

Request Body (JSON):

{
  "status": "ACTIVE",
  "balance": 200.99,
  "description": "My new active account!"
}

Response Body (JSON):

Successful response returns the JSON object of the updated Account

{
  "id": 4,
  "accountCreated": 1651449818797,
  "status": "ACTIVE",
  "balance": 200.99,
  "description": "My new active account!",
  "transactions": [
    {
      "id": 8,
      "senderId": 0,
      "receiverId": 4,
      "transactionCreated": 1651449818873,
      "amount": 200.99,
      "type": "DEPOSIT",
      "description": "Starting balance deposit"
    }
  ]
}
delete-account

Delete an account from the database

Route: /accounts/{id}

Method: DELETE

Response Body (JSON):

Successful response returns the JSON object of the deleted Account

{
  "id": 4,
  "accountCreated": 1651449818797,
  "status": "ACTIVE",
  "balance": 200.99,
  "description": "My new active account!",
  "transactions": [
    {
      "id": 8,
      "senderId": 0,
      "receiverId": 4,
      "transactionCreated": 1651449818873,
      "amount": 200.99,
      "type": "DEPOSIT",
      "description": "Starting balance deposit"
    }
  ]
}

TransactionController Routes:

get-account-transactions

Get all the transactions in an account

Route: /accounts/{id}/transactions

Method: GET

Response Body (JSON):

Successful response returns an array of JSON object of the transactions in the account

[
  {
    "id": 8,
    "senderId": 0,
    "receiverId": 4,
    "transactionCreated": 1651449818873,
    "amount": 200.99,
    "type": "DEPOSIT",
    "description": "Starting balance deposit"
  },
  {
    "id": 9,
    "senderId": 0,
    "receiverId": 4,
    "transactionCreated": 1651450688042,
    "amount": 0.01,
    "type": "DEPOSIT",
    "description": "My new transaction description!"
  }
]
get-transaction

Get a transaction by transaction_id

Route: /transactions/{id}

Method: GET

Response Body (JSON):

Successful response returns a JSON object of the Transaction with the transaction_id

{
  "id": 8,
  "senderId": 0,
  "receiverId": 4,
  "transactionCreated": 1651449818873,
  "amount": 200.99,
  "type": "DEPOSIT",
  "description": "Starting balance deposit"
}
create-transaction

Creates a transaction in the account

Route: /accounts/{id}/transactions

Method: PUT

Request Body (JSON):

{
  "senderId": 0,
  "receiverId": 4,
  "amount": 0.01,
  "description": "My deposit made through javalin banking rest api"
}

Response Body (JSON):

Successful response returns the JSON object of the created Transaction

{
  "id": 9,
  "senderId": 0,
  "receiverId": 4,
  "transactionCreated": 1651450688042,
  "amount": 0.01,
  "type": "DEPOSIT",
  "description": "My deposit made through javalin banking rest api"
}
update-transaction

Update the transaction with the transaction_id

Route: /transactions/{id}

Method: PUT

Request Body (JSON):

{
  "description": "My new transaction description!"
}

Response Body (JSON):

Successful response returns the JSON object of the updated Transaction

{
  "id": 9,
  "senderId": 0,
  "receiverId": 4,
  "transactionCreated": 1651450688042,
  "amount": 0.01,
  "type": "DEPOSIT",
  "description": "My new transaction description!"
}
delete-transaction

Delete a transaction from the database

Route: /transactions/{id}

Method: DELETE

Response Body (JSON):

Successful response returns the JSON object of the deleted Transaction

{
  "id": 9,
  "senderId": 0,
  "receiverId": 4,
  "transactionCreated": 1651450688042,
  "amount": 0.01,
  "type": "DEPOSIT",
  "description": "My new transaction description!"
}

About

a command-line java banking application with javalin rest api

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages