This document describes a secure enterprise banking microservices architecture using modern cloud-native technologies and security best practices.
The architecture includes:
API Gateway Identity & Access Management OAuth2 / OpenID Connect Service Discovery Secret Management Distributed Cache Microservices Database Isolation Event-Driven Communication Observability Zero Trust Security DevSecOps Goal Description Security Enterprise-grade authentication, authorization, encryption Scalability Horizontal scaling of services Availability Fault-tolerant banking platform Compliance PCI-DSS, SOC2, GDPR-ready Isolation Database-per-service architecture Observability Full tracing, logging, monitoring Performance Redis caching and async processing Extensibility Independent microservice deployment
Layer Technology Frontend Angular / React / Mobile App API Gateway Spring Cloud Gateway Identity Provider Keycloak Authentication OAuth2 + OpenID Connect + JWT Backend Framework Spring Boot Service Discovery Eureka / Consul Config Management Spring Cloud Config Secret Management HashiCorp Vault Messaging Kafka / RabbitMQ Cache Redis Database PostgreSQL / Oracle Observability Prometheus + Grafana Logging ELK Stack Tracing Zipkin / Jaeger Containerization Docker Orchestration Kubernetes CI/CD Jenkins / GitLab CI Service Mesh Istio Security Scanning SonarQube + Trivy
+ - Reset Drag to move • Scroll to zoom
The Spring Cloud Gateway acts as the single entry point for all client requests.
Routing — Forward requests to appropriate microservicesRate Limiting — Prevent abuse with token bucket algorithmAuthentication — Validate JWT tokens before forwardingCircuit Breaker — Fail fast when downstream services are unavailableRequest/Response Transformation — Normalize headers and payloadsCORS Management — Handle cross-origin requests securelyspring :
cloud :
gateway :
routes :
- id : account- service
uri : lb: //account- service
predicates :
- Path=/api/v1/accounts/**
filters :
- name : RequestRateLimiter
args :
redis-rate-limiter.replenishRate : 100
redis-rate-limiter.burstCapacity : 200
+ - Reset Drag to move • Scroll to zoom
Keycloak serves as the centralized identity provider with:
OAuth2 Authorization Server — Issue access tokensOpenID Connect — Identity layer on top of OAuth2Single Sign-On (SSO) — Unified authentication across servicesUser Federation — LDAP/Active Directory integrationSocial Login — Optional Google/Facebook loginMulti-Factor Authentication (MFA) — TOTP/SMS verification+ - Reset Drag to move • Scroll to zoom
{
"iss" : "https://auth.bank.com/auth/realms/bank" ,
"sub" : "a1b2c3d4-e5f6-7890-abcd-ef1234567890" ,
"aud" : "account-service" ,
"exp" : 1715239200 ,
"iat" : 1715235600 ,
"realm_access" : {
"roles" : [ "bank_admin" , "account_viewer" ]
} ,
"resource_access" : {
"account-service" : {
"roles" : [ "read" , "write" ]
}
}
}
Each microservice registers itself with Eureka on startup and periodically sends heartbeats.
+ - Reset Drag to move • Scroll to zoom
Spring Cloud Config Server provides externalized configuration for all services.
spring :
cloud :
config :
server :
git :
uri : https: //git.bank.com/config- repo
default-label : main
search-paths : '{application}'
Each service fetches config at startup:
spring :
application :
name : account- service
cloud :
config :
uri : http: //config- server: 8888
fail-fast : true
retry :
initial-interval : 1000
max-attempts : 5
Dynamic Secrets — Generate database credentials on-demandEncryption as a Service — Encrypt sensitive data at restAudit Logging — Track every secret accessAutomatic Rotation — Rotate credentials without downtime+ - Reset Drag to move • Scroll to zoom
spring :
cloud :
vault :
host : vault.bank.com
port : 8200
scheme : https
authentication : KUBERNETES
kubernetes :
role : account- service
service-account-token-file : /var/run/secrets/kubernetes.io/serviceaccount/token
database :
enabled : true
role : account- db- role
backend : database
Cache Type TTL Use Case Session Cache 30 min User sessions Account Cache 5 min Account balances Rate Limit Cache 1 min API rate limiting Reference Data 1 hour Currency codes, branch lists
+ - Reset Drag to move • Scroll to zoom
@Configuration
@EnableCaching
public class RedisConfig {
@Bean
public RedisCacheManager cacheManager ( RedisConnectionFactory factory) {
RedisCacheConfiguration config = RedisCacheConfiguration . defaultCacheConfig ( )
. entryTtl ( Duration . ofMinutes ( 5 ) )
. serializeKeysWith (
RedisSerializationContext. SerializationPair . fromSerializer (
new StringRedisSerializer ( ) ) )
. serializeValuesWith (
RedisSerializationContext. SerializationPair . fromSerializer (
new GenericJackson2JsonRedisSerializer ( ) ) ) ;
return RedisCacheManager . builder ( factory)
. cacheDefaults ( config)
. build ( ) ;
}
}
+ - Reset Drag to move • Scroll to zoom
Aspect Detail Responsibility User registration, profile management, KYC verification Endpoints POST /api/v1/users, GET /api/v1/users/{id}, PUT /api/v1/users/{id}Database PostgreSQL — users schema Dependencies Redis (session cache), Kafka (user events)
Aspect Detail Responsibility Account creation, balance inquiry, account closure Endpoints POST /api/v1/accounts, GET /api/v1/accounts/{id}, GET /api/v1/accounts/{id}/balanceDatabase PostgreSQL — accounts schema Dependencies Redis (balance cache), User Service
Aspect Detail Responsibility Deposit, withdrawal, fund transfer, transaction history Endpoints POST /api/v1/transactions, GET /api/v1/transactions/{id}, GET /api/v1/transactions/historyDatabase Oracle — transactions schema Dependencies Account Service, Kafka (transaction events)
Aspect Detail Responsibility Bill payment, merchant payment, QR payment Endpoints POST /api/v1/payments, GET /api/v1/payments/{id}Database PostgreSQL — payments schema Dependencies Transaction Service, Notification Service
Aspect Detail Responsibility Loan application, approval, repayment scheduling Endpoints POST /api/v1/loans, GET /api/v1/loans/{id}, POST /api/v1/loans/{id}/repayDatabase Oracle — loans schema Dependencies Account Service, Credit Scoring Engine
Aspect Detail Responsibility Email, SMS, push notification delivery Endpoints POST /api/v1/notifications/sendDatabase PostgreSQL — notifications schema Dependencies Kafka (consume events), Third-party SMS/Email providers
Aspect Detail Responsibility Immutable audit log for compliance Endpoints GET /api/v1/audit/logs, GET /api/v1/audit/logs/{entityId}Database PostgreSQL — audit schema (append-only) Dependencies Kafka (consume all domain events)
Each microservice owns its database exclusively. No service directly accesses another service's database.
+ - Reset Drag to move • Scroll to zoom
Pattern Implementation Saga Pattern Distributed transactions via Kafka choreography Event Sourcing Audit service stores immutable event log CQRS Separate read/write models for high-volume services Idempotency Idempotency keys on all payment/transaction endpoints
+ - Reset Drag to move • Scroll to zoom
+ - Reset Drag to move • Scroll to zoom
{
"event_id" : "evt_a1b2c3d4-e5f6-7890-abcd-ef1234567890" ,
"event_type" : "TRANSACTION_COMPLETED" ,
"source" : "transaction-service" ,
"timestamp" : "2026-05-09T10:00:00Z" ,
"trace_id" : "trace_abc123" ,
"data" : {
"transaction_id" : "txn_987654" ,
"from_account" : "ACC-1001" ,
"to_account" : "ACC-2002" ,
"amount" : 500.0 ,
"currency" : "USD" ,
"status" : "COMPLETED"
}
}
@Service
public class EventPublisher {
private final KafkaTemplate < String , DomainEvent > kafkaTemplate;
public EventPublisher ( KafkaTemplate < String , DomainEvent > kafkaTemplate) {
this . kafkaTemplate = kafkaTemplate;
}
public void publish ( DomainEvent event) {
kafkaTemplate. send ( event. getTopic ( ) , event. getEventId ( ) , event) ;
}
}
@Component
public class NotificationConsumer {
@KafkaListener ( topics = {
"user-events" ,
"transaction-events" ,
"payment-events"
} , groupId = "notification-service" )
public void handleEvent ( DomainEvent event) {
switch ( event. getEventType ( ) ) {
case "TRANSACTION_COMPLETED" -> sendTransactionNotification ( event) ;
case "PAYMENT_RECEIVED" -> sendPaymentNotification ( event) ;
case "USER_REGISTERED" -> sendWelcomeEmail ( event) ;
}
}
}
+ - Reset Drag to move • Scroll to zoom
@Configuration
public class TracingConfig {
@Bean
public Tracer tracer ( ) {
return BraveTracer . create (
Tracing . newBuilder ( )
. localServiceName ( "account-service" )
. spanReporter ( ZipkinReporter . create (
"http://zipkin:9411/api/v2/spans" ) )
. build ( )
) ;
}
}
@RestController
public class AccountController {
private final MeterRegistry meterRegistry;
private final Counter accountCreatedCounter;
public AccountController ( MeterRegistry meterRegistry) {
this . meterRegistry = meterRegistry;
this . accountCreatedCounter = Counter . builder ( "accounts.created.total" )
. description ( "Total number of accounts created" )
. register ( meterRegistry) ;
}
@PostMapping
public ResponseEntity < Account > createAccount ( @RequestBody AccountRequest request) {
Account account = accountService. create ( request) ;
accountCreatedCounter. increment ( ) ;
return ResponseEntity . status ( 201 ) . body ( account) ;
}
}
13.4 Logging Standard{
"timestamp" : "2026-05-09T10:00:00.123Z" ,
"level" : "INFO" ,
"service" : "account-service" ,
"trace_id" : "trace_abc123" ,
"span_id" : "span_def456" ,
"user_id" : "usr_7890" ,
"message" : "Account created successfully" ,
"account_id" : "ACC-1001" ,
"duration_ms" : 45
}
+ - Reset Drag to move • Scroll to zoom
Control Implementation Network Segmentation Kubernetes namespaces with network policies mTLS Istio mutual TLS between all services JWT Validation Every request validated at gateway and service level RBAC Role-based access control via Keycloak Secret Rotation Vault dynamic secrets with 24h TTL Audit Logging Immutable audit trail for all sensitive operations Rate Limiting Per-client rate limits at API Gateway SQL Injection Prevention Parameterized queries, ORM validation Encryption at Rest AES-256 for sensitive database columns Encryption in Transit TLS 1.3 for all communications
@Configuration
@EnableWebSecurity
@EnableMethodSecurity
public class SecurityConfig {
@Bean
public SecurityFilterChain filterChain ( HttpSecurity http) throws Exception {
http
. csrf ( AbstractHttpConfigurer :: disable )
. sessionManagement ( session ->
session. sessionCreationPolicy ( SessionCreationPolicy . STATELESS ) )
. authorizeHttpRequests ( auth -> auth
. requestMatchers ( "/api/v1/admin/**" ) . hasRole ( "BANK_ADMIN" )
. requestMatchers ( "/api/v1/accounts/**" ) . hasAnyRole ( "BANK_USER" , "BANK_ADMIN" )
. requestMatchers ( "/api/v1/transactions/**" ) . authenticated ( )
. anyRequest ( ) . authenticated ( )
)
. oauth2ResourceServer ( oauth2 ->
oauth2. jwt ( Customizer . withDefaults ( ) ) ) ;
return http. build ( ) ;
}
}
+ - Reset Drag to move • Scroll to zoom
FROM eclipse-temurin:21-jre-alpine AS builder
WORKDIR /app
COPY target/*.jar app.jar
RUN java -Djarmode=layertools -jar app.jar extract
FROM eclipse-temurin:21-jre-alpine
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
WORKDIR /app
COPY --from = builder /app/dependencies/ ./
COPY --from = builder /app/spring-boot-loader/ ./
COPY --from = builder /app/snapshot-dependencies/ ./
COPY --from = builder /app/application/ ./
USER appuser
EXPOSE 8080
ENTRYPOINT ["java" , "org.springframework.boot.loader.launch.JarLauncher" ]
apiVersion : apps/v1
kind : Deployment
metadata :
name : account- service
namespace : banking
spec :
replicas : 3
selector :
matchLabels :
app : account- service
template :
metadata :
labels :
app : account- service
spec :
serviceAccountName : account- service- sa
containers :
- name : account- service
image : bank.registry/account- service: latest
ports :
- containerPort : 8080
env :
- name : SPRING_PROFILES_ACTIVE
value : 'k8s'
- name : VAULT_ADDR
value : 'https://vault.bank.com:8200'
resources :
requests :
memory : '512Mi'
cpu : '250m'
limits :
memory : '1Gi'
cpu : '500m'
livenessProbe :
httpGet :
path : /actuator/health/liveness
port : 8080
initialDelaySeconds : 30
periodSeconds : 10
readinessProbe :
httpGet :
path : /actuator/health/readiness
port : 8080
initialDelaySeconds : 20
periodSeconds : 5
---
apiVersion : v1
kind : Service
metadata :
name : account- service
namespace : banking
spec :
selector :
app : account- service
ports :
- port : 8080
targetPort : 8080
+ - Reset Drag to move • Scroll to zoom
apiVersion : autoscaling/v2
kind : HorizontalPodAutoscaler
metadata :
name : account- service- hpa
namespace : banking
spec :
scaleTargetRef :
apiVersion : apps/v1
kind : Deployment
name : account- service
minReplicas : 3
maxReplicas : 10
metrics :
- type : Resource
resource :
name : cpu
target :
type : Utilization
averageUtilization : 70
- type : Resource
resource :
name : memory
target :
type : Utilization
averageUtilization : 80
This enterprise banking microservices architecture provides:
Requirement How It's Addressed Security Zero Trust model, mTLS, OAuth2/OIDC, Vault secrets Scalability Horizontal pod autoscaling, Redis caching, Kafka async processing Availability Circuit breakers, health probes, multi-replica deployments Compliance Immutable audit logs, database isolation, encryption at rest/transit Observability Prometheus + Grafana, ELK Stack, distributed tracing Extensibility Independent services, event-driven communication, API Gateway routing
The architecture follows cloud-native best practices and is designed to meet the rigorous demands of the banking industry while maintaining flexibility for future growth.