Giter VIP home page Giter VIP logo

account-service's Introduction

Account Service

This project was created as some use cases (CRUD and Transfer Money) sample for hexagonal architecture.

Here, you can reach my Medium article about Hexagonal (Ports & Adapter) Architecture.

This project provides endpoints for account domain CRUD actions and to transfer money from one account to another.

The Account service provides data like below:

Account:

  • id
  • Account id
  • Account Name
  • Account Owner
  • Account Balance
  • Creation Time

Transfer:

  • Sender Account Id
  • Receiver Account Id
  • Amount
  • Result
  • Timestamp

Note:

If you like the solution, please don't forget to give a star ⭐ and follow me.

Thank you! ❤️

Endpoints

The service provides CRUD actions and money transfer endpoints

POST /accounts

Create a new account

Request:

{
   "accountId": "123456789",
   "name": "Main Account",
   "owner": "John Doe",
   "balance": 650
}

Response:

{
   "id": 1,
   "accountId": "123456789",
   "name": "Main Account",
   "owner": "John Doe",
   "balance": 650,
   "createdAt": "2020-10-11T20:56:59.606932Z"
}

GET /accounts

Retrieve a list of all accounts

Response:

{
   "accounts":[
      {
         "id":1,
         "accountId":"123456789",
         "name":"Main Account",
         "owner":"John Doe",
         "balance":650,
         "createdAt":"2020-10-11T20:56:59.606932Z"
      },
      {
         "id":2,
         "accountId":"123456788",
         "name":"Saving Account",
         "owner":"Jane Doe",
         "balance":750,
         "createdAt":"2020-10-03T20:41:16.517256Z"
      }
   ]
}

GET /accounts/{id}

Retrieve account by id

Response:

{
   "id":1,
   "accountId":"123456789",
   "name":"Main Account",
   "owner":"John Doe",
   "balance":650,
   "createdAt":"2020-10-11T20:56:59.606932Z"
}

DELETE /accounts/{id}

Deletes account by id

POST /accounts/transfer

Transfers money from one account to another

Request:

{
   "senderAccountId":"123456788",
   "receiverAccountId":"123456789",
   "amount":25
}

Response:

{
    "id": 1,
    "senderAccountId": "123456788",
    "receiverAccountId": "123456789",
    "amount": 25,
    "result": "SUCCESSFUL",
    "timeStamp": "2020-10-03T20:41:16.799826Z"
}

Libraries & Tools

  • Java 11
  • Maven 3.6
  • Spring Boot 2
  • Lombok
  • Flyway
  • H2 Database
  • Docker
  • SwaggerUI
  • RestAssured
  • Junit 5

Building Application

Always use the Maven wrapper to build the project from command line.

App runs default 8080 port. http://localhost:8080/

Useful commands:

mvn clean install

Fully clean and install dependencies

mvn test

Runs tests

mvn compile

Compiles application

mvn package

Creates package of application

Running Application

After you create package of the application, in the path of the application on terminal, write the command which is below to run application.

javac -jar target/account-service-0.0.1-SNAPSHOT.jar

Run with command:

mvn spring-boot:run

Starts application

Important Note:

  • This is a simple sample application.

  • When the application runs 2 dummy accounts inserting DB:

    • 123456788
    • 123456789
  • Some account service endpoints are created as example.

  • Only functional tests added.

account-service's People

Contributors

tugcekonuklar 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.