Skip to content

An application based on microservice architecture that implements a simple bank system

Notifications You must be signed in to change notification settings

Matheus-Soares/matthew-bank

Repository files navigation

Matthew Bank Project

This project uses Quarkus, the Supersonic Subatomic Java Framework.

If you want to learn more about Quarkus, please visit its website: https://quarkus.io/ .

The project

The goal of this project is to simulate a simple bank. In this project we have three services: user-service, account-service and transaction-service.

These services communicate with each other using HTTP Requests.

Each bank user can have one or more Account.

The user can do the following operations in the account:

  • Deposit
  • Transfer
  • Withdraw

A simple architecture of this project is shown below:

Simple Architecture

TODOs

  • Change the transaction-service to use RabbitMQ instead of HTTP
  • Add Grafana to use with Prometheus
  • Create a simple interface
  • Improve the database use
  • Add Unit Tests and Integration Tests

Starting the infrastructure

This project uses a couple of services, such as Prometheus and Postgres. You can start them using the docker-compose.yaml, located in the infrastructure folder:

$ cd infrastructure
$ docker-compose up -d

You can stop them using:

$ docker-compose down
$ docker-compose rm

Running the application in dev mode

You can run your application in dev mode that enables live coding using:

$ ./gradlew account-service:quarkusDev
$ ./gradlew user-service:quarkusDev
$ ./gradlew transaction-service:quarkusDev

NOTE: The Quarkus Dev UI is available in dev mode at http://localhost:{port}/q/dev/

NOTE 2: The Swagger UI and OpenAPI Documentation is available in dev mode at http://localhost:{port}/q/swagger-ui/

Ports

Each application are accessible on its own port:

Packaging and running the application

The application can be packaged using:

$ ./gradlew account-service:build -x test
$ ./gradlew user-service:build -x test
$ ./gradlew transaction-service:build -x test

It produces the quarkus-run.jar file in the build/quarkus-app/ directory. Be aware that it’s not an über-jar as the dependencies are copied into the build/quarkus-app/lib/ directory.

The application is now runnable using java -jar build/quarkus-app/quarkus-run.jar.

If you want to build an über-jar, execute the following command:

$ ./gradlew build -Dquarkus.package.type=uber-jar -x test

The application, packaged as an über-jar, is now runnable using java -jar build/*-runner.jar.

Building and Running inside Docker

After packing the application, you can build the docker image running the following commands:

  • To build a Account Service Docker Image and run the docker container:
$ cd account-service
$ docker build -f src/main/docker/Dockerfile.jvm -t quarkus/account-service-jvm .
$ docker run -i --rm --net=host -p 8080:8080 quarkus/account-service-jvm
  • To build a User Service Docker Image and run the docker container:
$ cd user-service
$ docker build -f src/main/docker/Dockerfile.jvm -t quarkus/user-service-jvm .
$ docker run -i --rm --net=host -p 8080:8080 quarkus/user-service-jvm
  • To build a Transaction Service Docker Image and run the docker container:
$ cd transaction-service
$ docker build -f src/main/docker/Dockerfile.jvm -t quarkus/transaction-service-jvm .
$ docker run -i --rm --net=host -p 8080:8080 quarkus/transaction-service-jvm

Related Guides

  • RESTEasy Reactive (guide): A JAX-RS implementation utilizing build time processing and Vert.x. This extension is not compatible with the quarkus-resteasy extension, or any of the extensions that depend on it.
  • Kotlin (guide): Write your services in Kotlin

Provided Code

RESTEasy Reactive

Easily start your Reactive RESTful Web Services

Related guide section...

About

An application based on microservice architecture that implements a simple bank system

Topics

Resources

Stars

Watchers

Forks