Bank Microservices

Bank Microservices

Table of contents


Bank Microservices is my own approach to a bank application, with a microservices-based architecture and using the MERN stack, which can handle creating, updating, and deleting accounts, customers and loans, store data on-chain and make predictions about potential loan defaults.

Technical details

The bulk of this application is made up of (i) smart contracts, which are written in Solidity using Hardhat, and tested using Foundry, (ii) back-end code, written in TypeScript using Express.js and Python using Flask, and (iii) front-end code which is mostly written in TypeScript using Next.js, a React.js framework.

Both, back end (all the APIs but that of the Flask web service) and front end, are implemented based on a hexagonal architecture .

Also, a scikit-learn pipeline has been developed that includes a Skorch neural net binary classifier that wraps a Pytorch neural net. A hyperparameter optimization of both, model and training, evaluated by cross-validation is performed in a Jupyter notebook.

Finally, data can be queried from a local TheGraph node using GraphQL. The subgraph that is used is set to support multiple networks, relevant deployment data will be shared accordingly.

All of the microservices have their own Docker images.


  • packages/*: npm packages that contain code and configuration files that are used by other packages or services.
  • services/*: microservices that make up the bulk of the application.
  • services/**/contracts/*: smart contracts written in Solidity language.
  • services/**/scripts/*: TypeScript scripts to deploy contracts and to write relevant information about them in both front-end and subgraph workspaces.
  • services/**/tasks/setState: Hardhat task to set a state to the local node.
  • services/**/contracts/test/foundry/*: test contracts to run with Foundry.
  • services/client/src/app/*: React.js functional components, CSSModules files, PostCSS mixins and a global css file.
  • services/client/src/features/*: services code with its core and data sources.
  • services/client/src/**/shared/*: user interface code shared across files at the same folder level.
  • services/**/subgraph/scripts/*: script to generate a subgraph manifest from a template, replacing keys for values from a JSON file.
  • services/**/subgraph/src/*: mappings, written in AssemblyScript, constants and entities used to extract data from the local Hardhat chain, process them and store them.
  • services/**/subgraph/templates/*: a subgraph manifest template.
  • services/**/api/**/core/*: this folder gathers the business logic of each service.
  • services/**/api/**/controllers/*: functions that define the operations desired by the API of the application.
  • services/**/api/**/data-sources/*: class that implements methods described in the repositories.

Running locally

This application uses pnpm and is configured to run with Docker Compose.

$ git clone
$ cd bank-microservices
$ git submodule update --init --recursive
$ cp .env.example .env # fill in tha values for each variable in .env
$ pnpm install
$ pnpm start:chain --filter=customers # only run one node, for instance executing the hardhat node in the customers workspace

Open another tab in terminal and:

$ pnpm deploy:contracts && pnpm populate & pnpm share
$ COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker compose -f docker-compose.yaml build
$ docker compose -f docker-compose.yaml up

Testing the contracts

$ pnpm test

I have written the following post to explain in detail this project:


This project is released under MIT License.

Related projects

This is my personal webpage, where I publish articles and side-projects.

Learn more
Olive Oil Trust

Olive Oil Trust

Olive Oil Trust is an olive oil traceability solution built on Ethereum that adapts the workflow of the olive oil long value chain to the blockchain through the use of smart contracts.

Learn more
zk Connect Four

zk Connect Four

zk Connect Four is a zero-knowledge decentralised application that lets you play the game of Connect Four against a DQN agent-trained policy or against another user.

Learn more

Ready to #buidl?

Are you seeking collaboration on a Web3 project or a developer to join your team?. Then, do not hesitate to contact me by e-mail or on my LinkedIn profile. You can also find me on GitHub.