Skip to content

drvaya-learn/bank-of-anthos

 
 

Repository files navigation

Continuous Integration

Bank of Anthos

This project simulates a bank's payment processing network using Anthos. Bank of Anthos allows users to create artificial accounts and simulate transactions between accounts. Bank of Anthos was developed to create an end-to-end sample demonstrating Anthos best practices.

Architecture

Architecture Diagram

Service Language Description
frontend Python Exposes an HTTP server to serve the website. Contains login page, signup page, and home page.
ledger-writer Java Accepts and validates incoming transactions before writing them to the ledger.
balance-reader Java Provides efficient readable cache of user balances, as read from ledger-db.
transaction-history Java Provides efficient readable cache of past transactions, as read from ledger-db.
ledger-db Redis Streams Append-only ledger of all transactions. Comes pre-populated with past transaction data for default user.
user-service Python Manages user accounts and authentication. Signs JWTs used for authentication by other services.
contacts Python Stores list of other accounts associated with a user. Used for drop down in "Send Payment" and "Deposit" forms (mock, uses hard-coded data).
accounts-db MongoDB Database for user accounts and associated data. Comes pre-populated with default user.
loadgenerator Python/Locust Continuously sends requests imitating users to the frontend. Periodically created new accounts and simulates transactions between them.

Installation

1 - Clone the repo

Clone this repository to your local environment.

git clone https://github.com/GoogleCloudPlatform/bank-of-anthos.git

2 - Project setup

Create a Google Cloud Platform project or use an existing project. Then, set the Project ID variable.

PROJECT_ID=<your-project-id>

3 - Create a Kubernetes cluster

gcloud beta container clusters create bank-of-anthos \
    --project=${PROJECT_ID} --zone=us-central1-b \
    --machine-type=n1-standard-2 --num-nodes=4

4 - Generate RSA key pair secret

openssl genrsa -out jwtRS256.key 4096
openssl rsa -in jwtRS256.key -outform PEM -pubout -out jwtRS256.key.pub
kubectl create secret generic jwt-key --from-file=./jwtRS256.key --from-file=./jwtRS256.key.pub

5 - Deploy Kubernetes manifests

kubectl apply -f ./kubernetes-manifests

After 1-2 minutes, you should see that all the pods are running:

kubectl get pods

Example output - do not copy

NAME                                  READY   STATUS    RESTARTS   AGE
accounts-db-6f589464bc-6r7b7          1/1     Running   0          99s
balancereader-797bf6d7c5-8xvp6        1/1     Running   0          99s
contacts-769c4fb556-25pg2             1/1     Running   0          98s
frontend-7c96b54f6b-zkdbz             1/1     Running   0          98s
ledger-db-5b78474d4f-p6xcb            1/1     Running   0          98s
ledgerwriter-84bf44b95d-65mqf         1/1     Running   0          97s
loadgenerator-559667b6ff-4zsvb        1/1     Running   0          97s
transactionhistory-5569754896-z94cn   1/1     Running   0          97s
userservice-78dc876bff-pdhtl          1/1     Running   0          96s

4 - Get the frontend IP

kubectl get svc frontend | awk '{print $4}'

Example output - do not copy

EXTERNAL-IP
35.223.69.29

Note: you may see a <pending> IP for a few minutes, while the GCP load balancer is provisioned.

5 - Navigate to the web frontend

Paste the frontend IP into a web browser. You should see a log-in screen:

Using the pre-populated username and password fields, log in as testuser. You should see a list of transactions, indicating that the frontend can successfully reach the backend transaction services.

Local Development

See the Development Guide for instructions on how to build and develop services locally, and the Contributing Guide for pull request and code review guidelines.


This is not an official Google project.

About

Anthos sample application for retail banking

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 29.8%
  • HTML 28.6%
  • Python 27.8%
  • Shell 5.2%
  • Dockerfile 3.8%
  • CSS 2.4%
  • Other 2.4%