Temp - dennisholee/notes GitHub Wiki
Key Decision Document (KDD): Integration Hub Deployment Architecture
| Document ID | KDD-INT-HUB-001 |
|---|---|
| Status | Draft |
| Author | Enterprise Architecture |
| Date | 2026-07-15 |
| Version | 1.0 |
1. Problem
The Integration Hub must be deployed across multiple geographic and regulatory jurisdictions (initially UK and HK) while ingesting change streams from multiple MongoDB deployments that are logically separated by domain (Party, Relationship, Contact Points, Product Holdings). These independent change streams must converge into a unified event topology (Market β Line of Business β Domain) for global event visibility and downstream consumption. A deployment architecture must be selected that balances data sovereignty, event aggregation fidelity, operational cost, and future expansion capacity.
2. Background
The Integration Hub uses a Control Plane / Worker Plane architecture:
- Control Plane: Centralised management service exposing REST APIs. Persists flow configurations in MongoDB. Uses MongoDB Change Streams to broadcast lifecycle commands to worker nodes in real-time. Also handles leader election, node heartbeat monitoring, and cluster coordination β all backed by MongoDB (TTL indexes, atomic lookups).
- Worker Nodes: Java 21 (virtual-thread) engines that subscribe to the MongoDB Change Stream, react to configuration changes, and execute SourceβPipelineβSink flows. Each node polls or listens on assigned sources and routes data through transformers.
- Coordination Layer: MongoDB replaces Hazelcast/Redis for distributed locking, leader election, health monitoring, and heartbeats.
Currently, the codebase assumes a single MongoDB URI (application.yml default). Expanding to a federated, multi-region model requires fundamental architectural decisions:
- Data Residency: Core domains (Party, Relationship, Contact Points) must remain in the UK. Product Holdings and other relationship-based domains are federated across UK and HK.
- Multiple Change Streams: Each MongoDB deployment independently emits change stream events. These must be ingested and converged into a consistent event topology: Market β Line of Business β Domain.
- Event Aggregation: Downstream consumers (analytics, data warehouses, audit, real-time dashboards) require a unified, ordered, and enriched view of events regardless of origin region.
- Cost & Growth: The solution must be cost-efficient at launch yet support expansion into additional regions (e.g., APAC, EMEA, AMER) without architectural overhaul.
3. Constraints
| # | Constraint | Description |
|---|---|---|
| C1 | MongoDB 6.0+ Dependency | Change Streams (resume tokens, DDL support) and TTL-based heartbeats require MongoDB 6.0+ replica sets. |
| C2 | Data Sovereignty | UK PII / core domain data must not leave the UK jurisdiction. HK Product Holdings data must remain in HK unless legally exempted. |
| C3 | Control Plane Single-Writer Semantics | Leader election and cluster coordination rely on MongoDB atomicity. Only one control-plane leader should actively mutate flows at any time. |
| C4 | Network Latency & Reliability | Cross-region latency (UKβHK ~200-300ms) impacts synchronous operations. RPO/RTO targets must be achievable within these bounds. |
| C5 | Event Ordering | Events within a single domain (e.g., Party changes in UK) must remain ordered. Cross-domain event ordering is best-effort; a causal consistency model is acceptable. |
| C6 | Change Stream Idempotency | Each change stream cursor is unique to a MongoDB cluster. Aggregation logic must handle duplicate or out-of-order events across clusters. |
| C7 | Cost of Ownership | Infrastructure (compute, network egress, storage), operational complexity (monitoring, deployment, DR), and licensing must fit within projected budget for β₯3 years. |
| C8 | Expansion Capacity | The architecture must support adding new regions (e.g., Singapore, Dubai, EU) with minimal reconfiguration. |
4. Assumptions
| # | Assumption |
|---|---|
| A1 | MongoDB Atlas (or equivalent managed service) will be used for production to minimise operational overhead. Self-managed replica sets are acceptable for non-prod. |
| A2 | Cross-region network links are private (AWS Direct Connect / Azure ExpressRoute / GCP Interconnect) and meet 99.9% availability SLA. |
| A3 | Event topology consumers tolerate up to 5-second end-to-end latency for cross-region events. Same-region events are sub-second. |
| A4 | The current Integration Hub worker plane can be extended to connect to multiple MongoDB clusters (one per region) without core changes to pipeline execution. |
| A5 | Kubernetes (K8s) will be the deployment substrate in all regions. Helm charts and K8s Operators will be used for lifecycle management. |
| A6 | Authentication & authorisation across regions will use a centralised OIDC provider (e.g., Keycloak / Azure AD) rather than per-region identity stores. |
5. Options
5.1 Option Comparison Table
| Criteria | Option A: Single Global Deployment | Option B: Regional Deployment (Federated Control Planes) | Option C: Hybrid β Central Control with Regional Workers + Stream Aggregation Gateway |
|---|---|---|---|
| Summary | One centralised Integration Hub stack (single control plane, single MongoDB replica set) deployed in the UK. All event ingestion, transformation, and delivery occurs against a single global MongoDB cluster. Workers may be co-located in UK data centre; remote source connections use VPN/Direct Connect. | Fully independent Integration Hub stacks per region. Each region has its own control plane, worker pool, and MongoDB deployment. Cross-region event sharing is achieved via a separate event bridge (e.g., Kafka MirrorMaker 2 or custom bridge) that asynchronously replicates selected events. | A single central control plane resides in the UK. Each region hosts its own MongoDB cluster (UK core domains + HK/HK federated domains) with local worker nodes. A Stream Aggregation Gateway (SAG) β a lightweight, stateless service β subscribes to all regional MongoDB change streams, normalises events into the Market β LoB β Domain topology, and publishes them to a global event mesh (e.g., Kafka multi-region cluster or Pulsar). Workers and control plane consume from this global mesh. |
| Design (Deployment Topology) | |||
| Topology Description: | Topology Description: | Topology Description: | |
| β’ UK Data Centre (primary region) | β’ UK Region: Full IH stack (control plane + workers + MongoDB for core domains). | β’ UK Region: Central Control Plane + UK MongoDB (Party, Relationship, Contact Points) + UK Worker Pool. | |
| β Single Control Plane (1 pod, K8s) | β’ HK Region: Full IH stack (control plane + workers + MongoDB for Product Holdings). | β’ HK Region: HK MongoDB (Product Holdings) + HK Worker Pool. Workers connect to central control plane REST API via private link. | |
| β Single MongoDB Replica Set (3-node) hosting ALL domains (Party, Relationship, Contact Points, Product Holdings) | β’ Event Bridge (Kafka MirrorMaker 2 / custom bridge) asynchronously replicates events between UK and Kafka clusters in each region. | β’ Stream Aggregation Gateway (SAG): Deployed as a sidecar or standalone K8s deployment per region. Each SAG subscribes to its local MongoDB Change Stream, applies topology enrichment (tagging events with Market β LoB β Domain), and publishes to the Global Event Mesh. | |
| β Worker pool co-located (or remote with cross-region latency to MongoDB) | β’ Each control plane manages flows only within its region. Global flows require manual coordination or a separate orchestration layer. | β’ Global Event Mesh: Multi-region Kafka (Confluent / MSK / Strimzi) or Apache Pulsar. Topics are partitioned by topology (Market.LoB.Domain). | |
| β All change streams originate from one MongoDB cluster | β’ Workers consume from the global event mesh for cross-region flows; local change streams are consumed directly by SAG for low-latency regional processing. | ||
| Pros | β’ Simplest Architecture: Single control plane, single MongoDB cluster, single set of change streams β minimal operational complexity. | β’ Full Data Sovereignty: Each region owns and controls its data and control plane β no cross-border data movement without explicit replication. | β’ Best Balance of Control & Scale: Single logically centralised control plane eliminates cross-region consistency issues. Regional workers + SAG preserve low-latency regional processing. |
| β’ Strong Consistency: Since all domains exist in one MongoDB, cross-domain events (e.g., Party β Product Holding) are trivially consistent and ordered. | β’ Isolated Failure Domain: A control plane outage in one region does not affect other regions. | β’ Native Multi-Change-Stream Ingestion: SAG is explicitly designed for this. Each regional change stream is independently consumed and converged into the global event mesh. | |
| β’ No Integration Fabric: No need for cross-region event bridges, message replication, or aggregation gateways. | β’ Compliance-First: Meets the strictest data residency interpretation (no data leaves the region at the storage layer). | β’ Event Topology Enforcement: SAG normalises events into Market β LoB β Domain at ingress, so downstream consumers always see unified topology. | |
| β’ Lowest Initial Cost: Single region infrastructure, no cross-region networking. | β’ Regional Autonomy: Each region can independently upgrade, restart, or reconfigure its control plane without coordination. | β’ Expansion-Friendly: Adding a new region = deploy SAG + worker pool + MongoDB. No new control plane. SAG publishes to the global event mesh automatically. | |
| β’ Simpler Disaster Recovery: One replica set; failover to a second AZ/region using MongoDB Atlas global clusters. | β’ No Cross-Region Latency for Local Events: All intra-region processing is sub-second. | β’ Cost-Effective: Single control plane reduces infrastructure and operational overhead vs. Option B. No need for full stack per region. | |
| Cons | β’ Data Sovereignty Violation Risk: Storing HK Product Holdings data in a UK MongoDB cluster may breach HK data residency regulations. | β’ Operational Complexity: N control planes to deploy, monitor, upgrade, and patch. | β’ Control Plane Single Point of Failure (SPOF): A central control plane outage impacts all regions. Mitigation via active-passive DR. |
| β’ Single Region SPOF: A UK data centre outage takes down the entire Integration Hub globally. Mitigation requires multi-region MongoDB (Atlas Global Clusters, incurring egress costs). | β’ Event Consistency Challenges: Two independent change streams producing events that must be correlated across regions requires a complex event bridge with conflict resolution, deduplication, and ordering semantics. | β’ Global Event Mesh Dependency: Requires Kafka/Pulsar multi-region deployment, which has its own operational complexity and cross-region replication latency. | |
| β’ Cross-Region Latency: Workers in HK connecting to UK MongoDB suffer ~200-300ms additional latency per operation, impacting real-time ingestion throughput. | β’ Higher Infrastructure Cost: Duplicate control-plane services, load balancers, ingress controllers per region. | β’ SAG as New Component: The SAG must be built, tested, and maintained. It introduces a new failure mode (if SAG dies, change stream resumption must be handled). | |
| β’ Single Change Stream Bottleneck: All domain events flow through one MongoDB cluster's oplog. High event volume (especially from HK) may cause oplog window pressure and change stream lag for UK consumers. | β’ Global Flow Orchestration Gap: A flow that spans UK and HK (e.g., enrich Party data from UK with Product Holdings from HK) requires cross-control-plane coordination, which the current codebase does not support. Custom orchestration needed. | β’ Event Ordering Semantics: Events from different regions must be sequenced by the SAG / event mesh. Causal consistency across regions is non-trivial (e.g., Lamport clocks or Kafka partition key by entity ID). | |
| β’ Expansion Cost Grows: Adding a new region still requires all workers to connect to the UK MongoDB cluster β increased network egress costs and latency. | β’ Costly Expansion: Each new region requires a full Integration Hub stack + new event bridge connections. | β’ Requires Change Stream Resume Token Management Across Restarts: SAG must persist resume tokens for each regional MongoDB cluster. | |
| Notes | β’ Atlas Global Clusters with sharding by region could mitigate some data sovereignty concerns but adds cost and complexity. | β’ The event bridge introduces at-least-once delivery semantics, which may cause duplicate events in the target region. Downstream deduplication is required. | β’ The SAG can be implemented as a lightweight Spring Boot service using MongoDB's ChangeStreamPublisher β minimal code changes to existing worker logic. |
| β’ Workers in HK would use local read preference if a secondary is available, but all writes still go to UK primary. | β’ This option closely mirrors a "sovereign cloud" pattern used by financial institutions in highly regulated markets. | β’ The global event mesh topics can be sharded by market.lob.domain partition key for ordered event delivery within a topology branch. |
|
| β’ Not recommended for any deployment that must comply with HK data residency. | β’ This option is the recommended approach for a scalable, compliant, and cost-effective deployment. | ||
| Score | 2 / 5 | 3 / 5 | 4.5 / 5 |
| Remarks | Feasible only if all data can legally reside in the UK. Violates constraints C2 (HK data residency). Strongly disfavoured for any multi-jurisdiction rollout. | Technically viable but operationally heavy. The event bridge adds latency, complexity, and potential inconsistency. Suitable only for extremely high regulatory separation requirements where even a shared control plane is prohibited. | Strongly recommended. Satisfies all constraints. Single control plane avoids consistency problems. SAG cleanly solves the multi-change-stream convergence requirement. Expansion cost is linear (add region = add SAG + worker + mesh topic). Four remediation actions should be prioritised: (1) resilience for central control plane (active-passive DR), (2) SAG resume token persistence, (3) global event mesh deployment standards, (4) causal consistency design for cross-region events. |
5.2 Topology Diagrams
Option A: Single Global Deployment
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β UK Data Centre β
β βββββββββββββββ ββββββββββββββββββββββββββββββββ β
β β Control β β MongoDB Global Replica Set β β
β β Plane (x1) ββββ ββββββββββββββββββββββββ β β
β β REST API β β β Party β β β
β ββββββββ¬ββββββββ β β Relationship β β β
β β β β Contact Points β β β
β β Change β β Product Holdings β β β
β β Stream β ββββββββββββββββββββββββ β β
β βΌ ββββββββββββββββ¬ββββββββββββββββ β
β βββββββββββββββ β β
β β Worker Pods ββββββββββββββββββββ Change Stream β
β β (UK + HK) β β
β βββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Option B: Regional Deployment (Federated Control Planes)
ββββββββββββββββββββββββββββββββββββ ββββββββββββββββββββββββββββββββββββ
β UK Region β β HK Region β
β βββββββββββββββ β β βββββββββββββββ β
β β Control β ββββββββββββββ β β β Control β ββββββββββββββ β
β β Plane UK ββββ MongoDB UK β β β β Plane HK βββ MongoDB HK β β
β β REST API β β Party β β β β REST API β β Product β β
β ββββββββ¬βββββββ β Relationshipβ β β ββββββββ¬βββββββ β Holdings β β
β β β Contact Ptsβ β β β ββββββββββββββ β
β βΌ ββββββββββββββ β β βΌ β
β βββββββββββββββ β β βββββββββββββββ β
β β Worker β βββββββββββββ β β β Worker β ββββββββββββ β
β β Pool UK β β Event ββββββββββ Pool HK β β Event β β
β βββββββββββββββ β Bridge β β β βββββββββββββββ β Bridge β β
β β (Kafka β β β β (Kafka β β
β β MM2) ββββββββββββββββββββββββββββ MM2) β β
β βββββββββββββ β β ββββββββββββ β
ββββββββββββββββββββββββββββββββββββ ββββββββββββββββββββββββββββββββββββ
Option C: Hybrid β Central Control + Regional Workers + SAG (Recommended)
βββββββββββββββββββββββββββββββ
β Global Event Mesh β
β (Multi-region Kafka/Pulsar) β
β Topics: Market.LoB.Domain β
ββββββββ¬βββββββββββββββββββββββ
β
ββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββ
β β β
βΌ βΌ βΌ
βββββββββββββββββββββββββββ βββββββββββββββββββββββββββ βββββββββββββββββββββββββββ
β UK Region β β HK Region β β Future Region (SG) β
β β β β β β
β βββββββββββββββ β β βββββββββββββββ β β βββββββββββββββ β
β β Control β β β β SAG HK β β β β SAG SG β β
β β Plane (x1) β β β β (Stream β β β β (Stream β β
β β REST API ββββ β β β Aggregator)β β β β Aggregator)β β
β βββββββββββββββ β β β β β β β β β β
β β β β ββββββββ¬βββββββ β β ββββββββ¬βββββββ β
β β β β β Change Stream β β β β
β βΌ β β βΌ β β βΌ β
β ββββββββββββββββββββββ β β ββββββββββββββββββββββ β β βββββββββββββββββββββββ
β β MongoDB UK β β β β MongoDB HK β β β β MongoDB SG ββ
β β Party β β β β Product Holdings β β β β Loans ββ
β β Relationship β β β ββββββββββββββββββββββ β β β Investments ββ
β β Contact Points β β β β β βββββββββββββββββββββββ
β ββββββββββββββββββββββ β β β β β
β β β β β β
β βββββββββββββββ β β βββββββββββββββ β β βββββββββββββββ β
β β Worker Pool β β β β Worker Pool β β β β Worker Pool β β
β β (Local) β β β β (Local) β β β β (Local) β β
β βββββββββββββββ β β βββββββββββββββ β β βββββββββββββββ β
β β β β β β
β Workers can consume β β Workers can consume β β Workers can consume β
β local Change Stream OR β β local Change Stream OR β β local Change Stream OR β
β Global Mesh β β Global Mesh β β Global Mesh β
βββββββββββββββββββββββββββ βββββββββββββββββββββββββββ βββββββββββββββββββββββββββ
5.3 Change Stream & Event Topology Flow (Option C)
ββββββββββββββ ββββββββββββββββ βββββββββββββββββββββ βββββββββββββββββββββ
β MongoDB UK βββββΆβ SAG UK βββββΆβ Global Event Mesh βββββΆβ Downstream β
β Change β β Normalises β β Topic: β β Consumers: β
β Stream β β Market.LoB. β β APAC.UK.WEALTH β β β’ Data Warehouse β
β - Party β β Domain β β APAC.UK.INSURANCE β β β’ Real-time Dash β
β - Contact β β Tags event β β APAC.HK.WEALTH β β β’ Audit Log β
ββββββββββββββ ββββββββββββββββ βββββββββββββββββββββ βββββββββββββββββββββ
ββββββββββββββ ββββββββββββββββ
β MongoDB HK βββββΆβ SAG HK βββββΆ
β Change β β Normalises β
β Stream β β Market.LoB. β
β - Product β β Domain β
β Holdings β β Tags event β
ββββββββββββββ ββββββββββββββββ
Event Envelope (after SAG normalisation):
{
"market": "APAC",
"lineOfBusiness": "WEALTH",
"domain": "PRODUCT_HOLDING",
"originRegion": "HK",
"eventType": "INSERT",
"entityId": "ph-001",
"payload": { ... },
"timestamp": "2026-07-15T09:00:00Z",
"traceId": "abc-123"
}
6. Recommendations
Option C (Hybrid β Central Control with Regional Workers + Stream Aggregation Gateway) is the recommended deployment architecture for the Integration Hub. It satisfies all constraints β data sovereignty (C2), multi-change-stream ingestion (implied by federated MongoDB), event topology convergence, and expansion capacity (C8) β while maintaining a single control plane for operational simplicity and strong event consistency.
6.1 Implementation Roadmap
| Phase | Activity | Deliverable | Timeline |
|---|---|---|---|
| 1 | SAG Design & Prototype | Spring Boot service using MongoDB Change Streams publisher. Resume token persistence in a local MongoDB/Redis. Event topology normalisation logic. | 4β6 weeks |
| 2 | Global Event Mesh Provisioning | Deploy multi-region Kafka cluster (Confluent or Strimzi Operator on K8s). Define topic naming convention ({market}.{lob}.{domain}). Partition key: {entityId} for ordering. |
4β6 weeks |
| 3 | UK Pilot Deployment | Deploy SAG-UK + central control plane + UK MongoDB (Party, Relationship, Contact Points). Validate change stream ingestion β event mesh pipeline. | 4 weeks |
| 4 | HK Region Onboarding | Deploy SAG-HK + HK MongoDB (Product Holdings). Configure private link to UK control plane. Validate cross-region event convergence. | 4 weeks |
| 5 | Observability & DR | Prometheus/Grafana dashboards for SAG lag, mesh throughput, control plane health. Active-passive DR for control plane (standby in HK region). | 4 weeks |
| 6 | Expansion Playbook | Document "Region Addition Runbook" for self-service onboarding of new regions (SG, EU, etc.). | 2 weeks |
6.2 Risk & Mitigation
| Risk | Likelihood | Impact | Mitigation |
|---|---|---|---|
| Central control plane outage | Medium | High | Active-passive DR with MongoDB Atlas Global Cluster for control plane state. DNS failover. |
| SAG change stream resumption failure | Low | High | Persist resume tokens in a separate MongoDB collection with checkpointing every 100 events. SAG health check endpoint. |
| Global event mesh cross-region latency | Medium | Medium | Tune Kafka/Pulsar replication factor and min.insync.replicas for latency vs. durability trade-off. Use Pulsar for lower latency if needed. |
| Cost of egress between regions | Medium | Medium | Use private interconnects (Direct Connect / ExpressRoute). Negotiate egress-free data transfer with cloud provider intra-region. |
| Event ordering across regions | Medium | Medium | Use composite partition keys that include entity ID. Implement Lamport clocks or KSUID-based ordering for cross-region causal events. |
7. Scoring Methodology
Each option was scored on a 1β5 scale across weighted criteria:
| Criterion | Weight | Rationale |
|---|---|---|
| Data Sovereignty Compliance | 25% | Non-negotiable regulatory requirement. |
| Multi-Change-Stream Ingestion & Convergence | 20% | Core functional requirement for federated MongoDB. |
| Operational Simplicity | 15% | Total cost of ownership includes operational burden. |
| Expansion / Growth Capacity | 15% | Must support adding 5+ regions over 3 years. |
| Event Aggregation & Topology Alignment | 15% | Ability to produce a unified Market β LoB β Domain event stream. |
| Cost Efficiency | 10% | Infrastructure + operational cost over 3-year horizon. |
| Option | Score | Weighted Score |
|---|---|---|
| A. Single Global Deployment | 2 / 5 | 2.0 |
| B. Regional Federated Control Planes | 3 / 5 | 2.7 |
| C. Hybrid β Central Control + Regional SAG | 4.5 / 5 | 4.3 |
Recommendation: Option C.
8. Appendices
8.1 Event Topology Taxonomy (Market β Line of Business β Domain)
Market
βββ APAC
β βββ UK
β β βββ Wealth
β β β βββ Party
β β β βββ Relationship
β β β βββ ContactPoint
β β β βββ ProductHolding
β β βββ Insurance
β β β βββ Party
β β β βββ Relationship
β β β βββ ContactPoint
β β β βββ ProductHolding
β β βββ Banking
β β βββ Party
β β βββ Relationship
β β βββ ContactPoint
β β βββ ProductHolding
β βββ HK
β βββ Wealth
β β βββ ProductHolding
β βββ Insurance
β βββ ProductHolding
βββ EMEA (future)
βββ ...
8.2 Glossary
| Term | Definition |
|---|---|
| Control Plane | Centralised management service exposing REST APIs for flow configuration, cluster monitoring, and lifecycle management. |
| Worker Plane | Distributed Java 21 engine pool that executes SourceβPipelineβSink flows. |
| Change Stream | MongoDB feature that provides real-time, ordered stream of data changes on collections. |
| Stream Aggregation Gateway (SAG) | Lightweight service that subscribes to regional MongoDB Change Streams, normalises events into the event topology, and publishes to the global event mesh. |
| Global Event Mesh | Multi-region Kafka or Pulsar cluster that acts as the unified event bus across all regions. |
| Event Topology | Hierarchical classification: Market β Line of Business β Domain. Used to partition events for ordered, route-able delivery. |
| Resume Token | MongoDB Change Stream cursor token that allows a consumer to resume from the last processed event after a restart. |
| Event Bridge | Cross-region message replication layer (e.g., Kafka MirrorMaker 2) used in Option B to synchronise events between independent regional stacks. |