How googlecloudplatform/bank-of-anthos works
Project Type and Purpose
• Bank of Anthos is a full-stack, microservices-based sample web application that simulates a bank’s payment network.
• It demonstrates modernizing enterprise apps on Google Cloud: GKE, Anthos Service Mesh, Cloud SQL, Cloud Build/Deploy, etc.
File Structure Analysis
• Top-level “src” folders group microservices:
· src/frontend (Python HTTP server + UI templates + static assets)
· src/accounts/userservice & src/accounts/contacts (Python services for user auth & contact storage)
· src/ledger/ledgerwriter, balancereader, transactionhistory (Java Spring Boot microservices)
· src/accounts/accounts-db & src/ledger/ledger-db (PostgreSQL init scripts + k8s overlays)
· src/loadgenerator (Locust-based load generator)
• kustomize/kubernetes-manifests and skaffold files indicate Kubernetes deployment per environment (dev, staging, prod).
• “extras” / “iac” folders contain alternate deployment patterns (Cloud SQL, multi-cluster, Istio, Terraform).
• README’s “Service architecture” table lists the nine core components (including loadgenerator).
Key Insights from README
• Each microservice exposes REST/HTTP endpoints and communicates via JWT authentication.
• frontend ←→ user-service for auth, frontend ←→ contacts for address book, frontend ←→ ledger-writer for transactions, frontend ←→ balance-reader & transaction-history for read-only queries.
• ledger-writer writes to ledger-db, accounts-service and contacts write/read from accounts-db.
• Loadgenerator simulates client traffic against frontend.
• Optional external Cloud SQL can replace in-cluster Postgres.
• External Entity: End User (browser)
• Processes: Frontend, UserService, Contacts, LedgerWriter, BalanceReader, TransactionHistory, LoadGenerator
• Data Stores: Accounts-DB, Ledger-DB
• Infrastructure: Kubernetes Cluster (GKE), Ingress/Gateway, Service Mesh, CI/CD
b. Data Flows & Interactions
• User → Frontend: HTTP(S) requests (login, signup, view, transfer)
• Frontend → UserService: Authenticate, issue JWT → Accounts-DB
• Frontend → Contacts: Retrieve contact list → Accounts-DB
• Frontend → LedgerWriter: Submit transaction (with JWT) → Ledger-DB
• Frontend → BalanceReader & TransactionHistory: Query caches → Ledger-DB
• LoadGenerator → Frontend: Periodic simulation of requests
• (Optional) Ingress/Gateway → All services: TLS termination, routing via Anthos Service Mesh
c. Architectural Patterns & Principles
• Microservices: Small, single-responsibility services
• API Layer: Frontend aggregated API calls
• CQRS-ish: Separate writer (LedgerWriter) vs. readers (BalanceReader, TransactionHistory)
• JWT for stateless auth
• Kubernetes deployments with kustomize overlays per environment
• Service mesh sidecar proxies for secure mTLS
d. Key Technologies/Frameworks
• Python Flask (frontend, user/contacts, loadgenerator)
• Java Spring Boot (ledger services)
• PostgreSQL (in-cluster) or Cloud SQL
• Kubernetes (GKE), Anthos Service Mesh, Ingress, Config Management
• kustomize, skaffold, Cloud Build, Cloud Deploy
Detailed Elements to Capture
• External User → Ingress/Gateway → Frontend
• Frontend ↔ UserService & Contacts (Accounts-DB)
• Frontend ↔ LedgerWriter → Ledger-DB
• Frontend ↔ BalanceReader & TransactionHistory → Ledger-DB
• LoadGenerator → Frontend
• Service Mesh sidecars around each pod
• Distinct k8s namespace or overlay boundaries for dev/staging/prod