How shekh1995/bank-of-anthos works
Purpose and Entry Points
Bank of Anthos is a sample HTTP banking/payment application used to demonstrate modernization on Kubernetes and Google Cloud. The browser entry point is the Python frontend; deployment starts from Kubernetes manifests or Skaffold. Core entry paths: src/frontend/frontend.py, kubernetes-manifests/frontend.yaml, skaffold.yaml.
Edge and UI Orchestration
The frontend serves login, signup, account, deposit, and transfer pages, and invokes backend HTTP APIs. It is the external service in the standard deployment; production overlays add ingress, frontend configuration, and certificates.
Paths: src/frontend/frontend.py, src/frontend/api_call.py, src/frontend/k8s/overlays/production/frontend-ingress.yaml.
Identity and Account Domain
userservice manages account creation and authentication, signing JWTs trusted by downstream services. contacts persists each user’s associated accounts for payment/deposit selections. Both are Python services backed by the accounts PostgreSQL database.
Paths: src/accounts/userservice/userservice.py, src/accounts/contacts/contacts.py, src/accounts/accounts-db/initdb/0-accounts-schema.sql.
Transaction Write Path
Payments and deposits flow from frontend to the Java/Spring ledger writer. It validates incoming transactions, verifies JWTs, and persists accepted records to the ledger database. This is the transactional consistency boundary: account identity data and immutable transaction data are separate stores.
Paths: src/ledger/ledgerwriter/src/main/java/anthos/samples/bankofanthos/ledgerwriter/LedgerWriterController.java, src/ledger/ledgerwriter/src/main/java/anthos/samples/bankofanthos/ledgerwriter/TransactionValidator.java, src/ledger/ledger-db/initdb/0_init_tables.sql.
Read Models for Ledger Data
Two Java/Spring services provide optimized read-side APIs over ledger-db: balance reader maintains a balance cache, while transaction history maintains a transaction cache. The frontend uses these separate query services rather than directly reading the ledger.
Paths: src/ledger/balancereader/src/main/java/anthos/samples/bankofanthos/balancereader/BalanceCache.java, src/ledger/transactionhistory/src/main/java/anthos/samples/bankofanthos/transactionhistory/TransactionCache.java, src/ledger/balancereader/src/main/java/anthos/samples/bankofanthos/balancereader/LedgerReader.java.
Runtime and Deployment Boundary
Services run as containers on Kubernetes, with per-service Kustomize bases and development/staging/production overlays. The top-level manifest set deploys the standard in-cluster topology. PostgreSQL can instead be externalized to Google Cloud SQL with proxy/workload-identity components.
Paths: kubernetes-manifests/, src/components/cloud-sql/kustomization.yaml, extras/cloudsql/kubernetes-manifests/config.yaml.
Platform Variants and Delivery
The repository supports GKE, Anthos Service Mesh/Config Management, Workload Identity, multi-environment deployment, and Terraform-provisioned Google Cloud infrastructure. Cloud Build/Cloud Deploy resources are defined in Terraform; Artifact Registry and GKE are material external services. A legacy alternative combines the three ledger services into a Java monolith for VM deployment.
Paths: iac/tf-multienv-cicd-anthos-autopilot/pipelines.tf, iac/tf-anthos-gke/gke.tf, src/ledgermonolith/src/main/java/anthos/samples/bankofanthos/ledgermonolith/LedgerMonolithApplication.java.
Load and Observability Extensions
A Locust container generates ongoing user/account/transaction traffic through the frontend, exercising the same public flow as users. Optional extras provide Prometheus/Google Managed Prometheus rules, alerting, dashboards, TLS, and service-mesh ingress.
Paths: src/loadgenerator/locustfile.py, extras/prometheus/gmp/rules.yaml, extras/istio/frontend-ingress.yaml.
Main entry points: api_call.py Frontend API client · frontend.yaml Kubernetes topology · LedgerWriterController.java Ledger writer · frontend.py Python frontend
Components 19
Edge & clients
- Browser users
- Locust load generator · Exercises the public frontend flow.
src/loadgenerator/locustfile.py - Python frontend · Serves banking pages and orchestrates backend API calls.
src/frontend/frontend.py - Frontend API client
src/frontend/api_call.py - Production ingress
src/frontend/k8s/overlays/production/frontend-ingress.yaml
Identity & accounts
- User service · Creates accounts, authenticates users, and signs JWTs.
src/accounts/userservice/userservice.py - Contacts service · Maintains users' associated payment accounts.
src/accounts/contacts/contacts.py
Ledger services
- Ledger writer · Transactional write boundary for payments and deposits.
src/ledger/ledgerwriter/src/main/java/anthos/samples/bankofanthos/ledgerwriter/LedgerWriterController.java - Transaction validator · Validates transactions and verifies JWTs before persistence.
src/ledger/ledgerwriter/src/main/java/anthos/samples/bankofanthos/ledgerwriter/TransactionValidator.java - Balance reader · Serves balances from a maintained cache.
src/ledger/balancereader/src/main/java/anthos/samples/bankofanthos/balancereader/BalanceCache.java - Transaction history · Serves transaction history from a cache.
src/ledger/transactionhistory/src/main/java/anthos/samples/bankofanthos/transactionhistory/TransactionCache.java
Data stores
- Accounts PostgreSQL · Identity and account-association store.
src/accounts/accounts-db/initdb/0-accounts-schema.sql - Ledger PostgreSQL · Immutable transaction record store.
src/ledger/ledger-db/initdb/0_init_tables.sql
Deployment & platform
- Kubernetes topology · Deploys the standard in-cluster service topology.
kubernetes-manifests/frontend.yaml - Cloud SQL option · Can externalize PostgreSQL through proxy and workload identity.
src/components/cloud-sql/kustomization.yaml - Cloud Build & Deploy · Terraform provisions delivery resources including Artifact Registry.
iac/tf-multienv-cicd-anthos-autopilot/pipelines.tf - GKE infrastructure · Provisions the Kubernetes runtime.
iac/tf-anthos-gke/gke.tf - Legacy ledger monolith · Alternative deployment combining the three ledger services.
src/ledgermonolith/src/main/java/anthos/samples/bankofanthos/ledgermonolith/LedgerMonolithApplication.java - Prometheus rules
extras/prometheus/gmp/rules.yaml
Connections 27
- Browser users → Production ingress: HTTPS
- Locust load generator → Python frontend: simulated traffic
- Production ingress → Python frontend: routes
- Python frontend → Frontend API client: uses
- Frontend API client → User service: authentication
- Frontend API client → Contacts service: account selections
- Frontend API client → Ledger writer: payments & deposits
- Frontend API client → Balance reader: balance queries
- Frontend API client → Transaction history: history queries
- User service → Accounts PostgreSQL: accounts
- Contacts service → Accounts PostgreSQL: contacts
- Ledger writer → Transaction validator: validates
- Transaction validator → User service: JWT trust
- Ledger writer → Ledger PostgreSQL: accepted transactions
- Balance reader → Ledger PostgreSQL: ledger reads
- Transaction history → Ledger PostgreSQL: ledger reads
- GKE infrastructure → Kubernetes topology: hosts
- Kubernetes topology → Python frontend: deploys
- Kubernetes topology → User service: deploys
- Kubernetes topology → Ledger writer: deploys
- Cloud SQL option → Accounts PostgreSQL: externalization option
- Cloud SQL option → Ledger PostgreSQL: externalization option
- Cloud Build & Deploy → GKE infrastructure: provisions delivery target
- Prometheus rules → Kubernetes topology: optional monitoring
- Legacy ledger monolith → Ledger writer: legacy alternative
- Legacy ledger monolith → Balance reader: legacy alternative
- Legacy ledger monolith → Transaction history: legacy alternative