Integration HUB and API links
1) HUB role and area of responsibility
Integration HUB (hereinafter referred to as HUB) is the layer between the platform core and the outside world (game providers, PSP, KYC/AML, CRM, risk scoring, anti-fraud, BI/analytics, notifications). Its tasks are:- unify protocols and formats;
- ensure reliability (retrays, queues, timeout policies, circuit breaker);
- guarantee security (mTLS, OAuth2, JWT, HMAC, IP-allowlist);
- centralize observability (logs, metrics, traces);
- Simplify changing provider (adapters + field mapping)
- give stable contracts for product teams.
2) Design principles
Consistent contracts: single DTO/events, strict scheme and version.
Idempotency - request keys, deduplication, secure retries.
Default fail-safe: timeout, backoff, circuit breaker policies.
Observability as a function: everything is measurable and traceable.
Separation of integration from the domain: adapters do not "know" the business logic of the kernel.
Event value: publish/subscribe for asynchronous processes.
Versioning: SemVer contracts and managed depriction.
3) High-level architecture
Gateway API: authentication, rate limits, canary releases, WAF.
Orchestrator/Router: routing by providers, priorities, failover, smart-routing.
Provider adapters: REST/gRPC/GraphQL/WebSocket, field mapping, local caches.
EDA bus (Kafka/RabbitMQ/NATS): events "payment created," "KYC passed," "game session started."
Contract/Scheme Service: Schema Registry for JSON/Avro/Protobuf.
Integration state storage: idempotence keys, correlation, statuses.
Observability: Prometheus/OTel + dashboards and alerts.
DevPortal: integration directories, OpenAPI/Protobuf, examples, sandboxes.
4) Data contracts and schemas
Strict schemes (JSON Schema/Avro/Protobuf), mandatory input/output validation.
Schema Registry with backward-compatible policy.
Clear error conventions (uniform code/detail format).
5) Supported protocols
REST (OpenAPI): versatile, easy to document.
gRPC: high performance for internal communications.
GraphQL: when aggregated samples are needed.
Webhooks: events to external systems; HMAC signature, redelivery.
SSE/WebSocket: live event streaming (live statuses, transactions).
6) Security and access
mTLS between internal services.
OAuth2/OIDC for external clients, short-lived tokens.
JWT for Service Federation of Identities; audit claims.
HMAC signatures for webhooks/critical collbacks.
IP-allowlist, WAF, RASP, anti-bot filters.
Secret management (KMS/HSM), key rotation, split-knowledge.
GDPR/PCI DSS: minimization of personal and card data, tokenization.
7) Routing and orchestration
Policy-based routing: by geo, currency, failure metrics, SLA provider.
Failover: PSP/provider sequence, automatic degradation.
Circuit Breaker: fast fault-tolerant branches for frequent errors.
Bulkhead: isolation by provider/tenant/thread pool.
Saga/orchestration for long processes (registration → KYC → deposit).
8) Idempotence and Exactly-Once (as real as it gets)
Idempotency-Key + status/response cache.
Bus event deduplication (correlation key).
Storage "seen-requests" with TTL.
http
POST /payments
Idempotency-Key: 3d8c1a4f-7f0e-4a2a-9e5a-2b8d3e7e2c11
Content-Type: application/json
json
{
"tenantId": "eu-casino-12",
"userId": "u-9812",
"currency": "EUR",
"amount": 50. 00,
"method": "card",
"metadata": {"orderId": "ORD-2025-1105-001"}
}
HUB will save the result and return the same response on replays.
9) Queues and event bus
Kafka/NATS/RabbitMQ for asynchronous steps: KYC results, payout statuses, game provider balance.
Themes with membership keys are 'tenantId', 'userId', or 'providerId'.
Retention and DLQ (dead-letter) with automatic resubmission after the fix.
Outbox pattern in kernel services for guaranteed event publishing.
10) Versioning and compatibility
SemVer on contracts: 'v1', 'v1. 1`, `v2`.
Parallel existence of two minor versions, a clear depriction schedule.
Migration adapters (temporary field mappers) for a smooth transition.
11) Observability and reliability
Metrics: latency p50/p95/p99, error rate, throughput, success ratio by providers, event confirmation time, "Time-to-Wallet."
Tracing (OTel): end-to-end 'trace _ id '/' span _ id' from API call to provider response.
Logs: structured, with 'request _ id' correlation, PII/PAN masking.
SLO: for example, 99. 9% success rate <1. 5s for critical paths.
Alerts: by SLO-error budget, DLQ growth, retray/timeout anomalies.
12) Sandboxes and test circuits
Sandbox for each provider: fixes, answer emulators, data versioning.
Contract-testing (Pact/Buf) and SDK autogeneration.
Load profiles according to the scenarios "peak tournaments," "payment waves."
13) Integration categories (example for iGaming)
Payments/withdrawals: PSP, A2A/Open Banking, crypto gateways.
KYC/AML/Risk: identity/address verification, sanctions lists, behavioral scoring.
Game Providers/Aggregators: Session Launches, Game Tokens, Return Collecks.
Communications: email/SMS/push/messengers.
Analytics/BI: Event streaming and aggregates.
Fraud/Chargers: dispute centers, alerts.
14) Multi-tenancy and regionality
TenantId isolation: encryption keys, quotas, limits, connection pools.
Geo-sharding: routing to the nearest RAP/region, taking into account local rules.
Localized provider/payment methods: list by jurisdiction and KYC levels.
15) Performance and caching
Token cache (PSP/KYC), provider metadata responses (TTL).
Connection pooling and reuse of TLS sessions.
Async I/O for high RPS; butching in adapters.
Rate limits on client and provider perimeters.
16) End-to-end scenarios (examples)
16. 1 Deposit (card)
1. 'POST/payments' → Orchestrator → PSP # 1.
2. Timeout 2s; при `5xx/timeout` — retry с backoff; during degradation - PSP # 2.
3. Event 'payment. authorized '→ balance core → BI/anti-fraud.
16. 2 KYC
1. 'POST/kyc/submit' → KYC provider adapter.
2. async: webhook'kyc. result 'is signed by HMAC; in case of failure - repeated delivery (up to N times).
3. Event 'kyc. verified 'is published to the bus.
16. 3 Game session
1. 'POST/games/session' → aggregator adapter → session token.
2. Collbecks of results/bets → HUB validates signature and idempotency.
3. Event 'game. round. settled 'goes into the calculation of payments and reporting.
17) Errors and uniform response format
Коды: `INTEGRATION_TIMEOUT`, `PROVIDER_UNAVAILABLE`, `CONTRACT_VALIDATION_FAILED`, `SECURITY_SIGNATURE_INVALID`.
Error body:json
{
"code": "PROVIDER_UNAVAILABLE",
"message": "Primary PSP degraded, switched to fallback",
"correlationId": "9f8e1b6a-1c2d-4b4e-9d31-91c6bc31c1d4",
"provider": "psp-1",
"hint": "Retry allowed; idempotency key required"
}
18) Secure webhooks: Sign and repeat
Sign each webhook:
X-Signature: sha256=hex(hmac_sha256(secret, body + timestamp))
X-Timestamp: 1730812800
Check the time drift and accept only fresh notifications. Repeats - exponentially to N, then in DLQ.
19) Change Management and Releases
Canary adapters (1-5% of traffic), feature flags per-tenant.
Backward-compatible releases: adapters first, then contracts.
CAB/CRQ for external providers, deploy windows are SLA consistent.
20) SLA / SLO / OLA
SLA provider: uptime ≥ 99. 9%, ack webhooks ≤ 3c, payment finalization ≤ 30c (p95).
SLO HUB: p95 < 1. 5c to critical endpoints, error-rate <0. 3%.
OLA inside: queue limits, retray budget, maximum DLQ times.
21) Integration Catalog and DevPortal
Provider pages: statuses, adapter versions, field requirements, checklists.
SDK autogen (OpenAPI/gRPC), examples, Postman collections, mock servers.
"Test in Sandbox" button and CI integration lines.
22) Safety and compliance
PII edition in logs, encryption of at-rest fields, PAN fields only in tokenized form.
RBAC/ABAC for operator panels, least privilege principle.
Consent Registers (GDPR), right to delete/port.
Vendor-risk and DPIA for new integrations.
23) Implementation Plan (MVP → Scale)
MVP (0-2 months): Gateway, 1-2 PSP, 1 KYC, 1 game aggregator, baseline metrics, idempotency, DLQ.
Phase 2 (3-4 months): EDA bus, DevPortal, contract tests, fallback routing, webhooks signature.
Phase 3 (5-6 months): clusters with geo-rollover, smart-routing via SLA, extended SLO/alerts, SDK autogen, canary.
24) Pre-sale checklist
Contracts in Registry, compatibility tests passed.
Timeout/retray/breaker policies are set and covered with e2e tests.
IdempotencyKey is included in critical POST/PUT.
Webhooks signatures are verified, replays are configured, DLQ is monitored.
The p95/p99 and error-rate metrics correspond to SLO, alerts are connected.
Secrets in KMS, rotation tested; IP-allowlist/WAF are active.
Runbooks/incident playbooks published, on-call scheduled.
DevPortal and sandboxes are available to partners, versions are documented.
Summary
An integration HUB is an industrial "shield and translator" between your core and the world of external services. Its strength lies in strict contracts, idempotency, event bus, controlled versioning and observability. This architecture accelerates provider onboarding, reduces risk, provides predictable SLOs and simplifies scaling for traffic peaks and entering new markets.