Skip to content

Push Server: Architecture

The Push Server runs as one Spring Boot process that contains the HTTP APIs, the RabbitMQ publisher and consumers, the FCM and APNs adapters, the JDBC repositories and the scheduled maintenance jobs. All replicas share one SQL database, one RabbitMQ broker, one Redis replay store and the same persistent server keys.

Component Role
Backend caller Customer backend that sends messages, reads state and verifies device tokens through the Messaging API
Device app Registers the device, retrieves and decrypts messages, reports state and sends callbacks through the Mobile API
Push Server Validates, persists, encrypts and delivers messages; forwards callbacks
SQL database Devices, messages, recipients, outbox, fallbacks, diagnostics and reporting data
RabbitMQ Asynchronous delivery commands and delayed retries
Redis Replay protection for device request signatures (outside development)
FCM / APNs Push providers that wake the device or display public notifications
Callback target Customer backend endpoint that receives verified device answers

The server listens on three connectors:

Port (default) Purpose
8080 Public APIs (/push/api/v2, /push/.well-known/jwks.json) and API documentation
8090 Admin connector: monthly usage reports (/push/api/v1) and the operator dashboard (/push/ui/dashboard)
8181 Actuator management endpoints (health, info, Prometheus)
Module Responsibility
m8ty-server Boot entry point, bean wiring, security configuration, attestation verifiers, Liquibase, optional audit publishing
m8ty-push-tenant-config Strict binding and startup validation of the tenant map and loading of credential files
m8ty-push-domain-models Domain values, delivery states and transitions, encrypted configuration helper
m8ty-push-dto Application and processing DTOs
m8ty-push-domain-validation Request validation, lifetime limits, sender rules, callback URL policy
m8ty-push-domain-services Retry and state policies, provider selection, sender configuration, active-device accounting
m8ty-push-application-api Internal use-case interfaces (not an HTTP API)
m8ty-push-application Registration, token issuance, message submission and retrieval, device directory, reports
m8ty-push-repository-interfaces Persistence ports
m8ty-push-repository JDBC implementations
m8ty-push-security-interfaces Contracts for keys, replay protection and attestation
m8ty-push-crypto JOSE transport, JWK thumbprints, PKCE and digests, HTTP message signature validation
m8ty-push-rest-api Messaging, mobile and public-key controllers, callback proxy, signature and tenant filters
m8ty-push-adm-rest-api Admin reporting controller and admin-port filter
m8ty-push-rapidocs RapiDoc pages and OpenAPI document selection per connector
m8ty-push-message-publisher Queue topology, publishing and delayed redelivery
m8ty-push-message-consumer Listeners, per-recipient encryption, provider delivery, state updates
m8ty-push-provider-interfaces Provider adapter contract, adapter selection, per-tenant token cache
m8ty-push-provider-http Shared HTTP/2 transport for provider calls with DNS/IP validation
m8ty-push-fcm-adapter FCM delivery through the Firebase Admin SDK with per-customer/app credentials
m8ty-push-apns-adapter Direct APNs requests with per-customer/app JWT signing and caching
m8ty-push-housekeeping Scheduled, bounded deletion jobs
m8ty-push-reporting-web Optional operator dashboard (Thymeleaf) and customer reporting endpoints
m8ty-logging Logging annotations for method and duration logging
m8ty-push-rest-client-dart OpenAPI-generated Dart (Dio) client packages

Application services depend only on repository ports; the server module composes JDBC repositories, queue publishing and application implementations. HTTP controllers use the application interfaces.

A tenant represents one customer. Each customer owns one or more independent apps, each with an Android and/or iOS variant. Configuration lives in one external YAML file that is imported at startup (SPRING_CONFIG_IMPORT=file:/.../tenants.yaml) under m8ty.push.tenants:

Level Settings
Customer (m8ty.push.tenants.<tenantId>) enabled, JWT trust (jwt), request limits and quotas (limits), optional apns-send-via-fcm default
App (...apps.<appId>) enabled, native identities (application), fcm, apns, Play Integrity credentials (attestation), senders, callbacks (credentials, OAuth realms, allowed networks), optional apns-send-via-fcm

Key rules:

  • Nothing is inherited between customers or between sibling apps: identities, provider and attestation credentials, sender policies, callback credentials and OAuth realms are resolved for the exact customer/app.
  • Every tenant API call carries the app in the appId query parameter. It may be omitted only when the customer has exactly one app.
  • Disabling a customer or app blocks registration, device and backend API access, background delivery, fallbacks and callbacks. Devices and messages are not deleted.
  • The configuration is a startup snapshot: changes require a rollout of every replica.
  • Startup validation rejects incomplete enabled apps (missing provider or attestation credentials), duplicate native identities and Firebase projects or APNs keys reused across customers.
  • Single-app installations keep the app ID default.

Server-wide settings such as database, broker, Redis, ports, provider URLs and timeouts, attestation enforcement, housekeeping and reporting are environment variables, not part of the tenant map. See Deployment and Operations.

The server uses JDBC repositories over a SQL database. Liquibase owns the schema.

Database Status
PostgreSQL Production; optional row-level security (RLS)
Oracle 19c Production with RLS disabled (Oracle VPD is not implemented)
H2, MariaDB Development and compatibility only

Important tables:

Table Purpose
device, device_notification_token, device_verifier_proof Device identity, public key, status, preferences, one push token per device, registration proofs
registration_data Registration nonces with PKCE challenge and expiry
device_opaque_token Hashed one-time device authentication tokens
push_message, processed_request Message metadata, lifetime, aggregate state, callback destination; deduplication by correlation ID
push_outbox Transactional outbox for broker publication
message_recipient Per-device state, provider claim, encrypted payload, localized text snapshot
notification_fallback Durable public fallback jobs for private notifications
device_access_log, active_device_log Access events and monthly active-device accounting

Production uses separate database logins with least privilege: a runtime login for request processing, a maintenance login for global jobs (outbox leases, fallback claims, housekeeping), a read-only reporting login restricted to metadata columns, and a migration login used only by the dedicated --migrate-database command. Normal production startup never runs Liquibase.

Message submission does not wait for provider delivery. The publisher and consumer modules use RabbitMQ:

Element Details
Exchange Durable direct exchange m8ty.nhub-push.v1.dx
INSTANT messages Queue m8ty.nhub-push.api.v1.commands.instant-messages (queue TTL 120 s)
ALERT messages Queue m8ty.nhub-push.api.v1.commands.standard-messages (queue TTL 900 s)
Dead letters ...standard-messages.dlqueue (4 hours)
Delayed retries m8ty.nhub-push-delay.v1.wait.5m (5 minutes)
Unroutable messages m8ty.no-routes.dlqueue
  • Publisher: submission stores the message, the deduplication record and an outbox command in one transaction. An outbox dispatcher publishes the command with publisher confirms and deletes the outbox row afterwards. Publication is scheduled fairly across customers.
  • Consumer: listeners prepare recipients and call the providers in bounded turns of at most ten devices; remaining work continues through the outbox. Acknowledgement is manual. Failures are republished to the five-minute delay queue while the retry limit (3 for INSTANT, 5 for ALERT) and the message lifetime allow it; otherwise remaining recipients are marked failed.
  • Queues are quorum queues with capacity limits (default 10,000 ready commands and 64 MiB per queue) and reject-publish overflow behavior.
Adapter Used for Authentication
FCM (m8ty-push-fcm-adapter) Android; iOS when routed through FCM Firebase Admin SDK with the app’s original Google service-account JSON
APNs (m8ty-push-apns-adapter) iOS direct delivery APNs provider JWTs signed with the app’s .p8 key; tokens cached per customer/app
HTTP transport (m8ty-push-provider-http) Shared HTTP/2 client for provider calls Validates DNS answers at connection time, blocks private and metadata addresses, no redirects or transport retries

Provider selection uses the device OS, its stored token and the effective apns-send-via-fcm setting (app override, then customer override, then the global default true). Each device stores exactly one push token. FCM messages restrict delivery to the configured Android package and Apple bundle ID of the exact app. Outside development, provider origins are restricted to the official FCM and APNs HTTPS hosts.

A provider 2xx response means SENT (accepted by the provider), not that the device received or displayed the notification. Uncertain outcomes (for example a timeout after transmission) keep the recipient claim and are not resent automatically.

  • The server has a persistent EC P-256 key pair (PKCS#12 keystore) and publishes its public keys at /push/.well-known/jwks.json.
  • During registration, the device sends its public key encrypted to the server key (ECDH-ES+A256KW / A256GCM) inside a device-signed JWT.
  • For each recipient, private content is signed by the server (ES256 JWT) and encrypted to the device key as compact JWE (ECDH-ES+A256KW for EC keys, RSA-OAEP for RSA keys, A256GCM content encryption).
  • With a privateNotification, the provider receives only a silent push containing the pushId. The app fetches the ciphertext over HTTPS, decrypts it and displays the notification locally.
  • A durable fallback job sends the neutral publicNotification if the device has not retrieved the message within a server-controlled timeout (default 15 seconds).

This is delivery encryption between server and device. The sender API, broker, outbox and database are trusted server-side components.

Scheduled jobs delete data in bounded batches (default 999 rows, at most 1000 batches per run):

Job Default schedule
Expired messages (with recipients and outbox children) older than the retention (default 3 days) 0 0 1 * * *
Deduplication records 0 30 0 * * *
Expired or used opaque device tokens 0 0 2 * * *
Expired or used registration nonces 0 30 2 * * *

A message is only deleted when both its expiry and any callback expiry are older than the retention cutoff.

The optional m8ty-push-reporting-web module provides:

  • Operator dashboard at /push/ui/dashboard on the admin connector: registrations, de-registrations, message traffic, active versus total devices, platform, version and language distributions, and a current device inventory across all tenants. Authentication is either an OIDC access proxy forwarding short-lived operator tokens or explicitly configured HTTP Basic.
  • Customer reporting endpoints on the public connector (/push/api/v2/{tenantId}/reporting/...), restricted to the customer’s own apps.

Reporting reads through its own read-only database login.

Caller Mechanism
Backend OAuth 2.0 bearer JWT (RS256) verified against the customer’s own trust (issuer discovery, JWKS or static key); requires audience push, endpoint scopes and roles, the path tenant in tenant_id, an exact app grant in app_access, and a lifetime of at most 15 minutes by default
Device (registration) PKCE nonce, JOSE key proof and platform attestation (Play Integrity or Apple App Attest); no bearer token
Device (all other calls) RFC 9421 HTTP message signature with the registered device key, body digest and replay nonce stored in Redis
Operator Dashboard on the admin connector only, with OIDC proxy tokens (dedicated issuer and audience) or Basic credentials

Additional controls: per-customer and per-IP request limits, monthly and pending-work quotas, a request body limit, guarded outbound connections for callbacks, OAuth and providers, and logs that never contain tokens, credentials or notification content. The dev profile disables bearer authorization and must never be used in production; production startup rejects disabled attestation.

  1. The app fetches the server public keys from GET /push/.well-known/jwks.json.
  2. It generates a device key pair and a PKCE verifier, and calls GET /push/api/v2/{tenantId}/devices/registration with the S256 code_challenge. The server stores a nonce valid for five minutes.
  3. The app builds registrationData (nonce, encrypted device key material, device info with language and OS, push token) and obtains platform attestation bound to the exact bytes of registrationData.
  4. It posts the raw JSON with registrationData and attestationData to POST /push/api/v2/{tenantId}/devices/registration?code_verifier=....
  5. The server consumes the nonce, checks PKCE, tenant and app, decrypts and verifies the device key, and validates properties and the push token.
  6. It verifies Play Integrity (through Google) or Apple App Attest (locally against the configured trust store) against the app’s configured identity.
  7. On success it atomically stores an AUTHORIZED device and returns 201. A failed attestation creates no device; the nonce stays consumed.
  1. Every device request (token issuance, message retrieval, state update, callback, token and preference updates) carries Signature-Input, Signature and Content-Digest headers.
  2. The signature filter resolves the key of the AUTHORIZED, ACTIVE device for the path tenant and app, matches the key ID to its JWK thumbprint, and checks algorithm, age and body digest.
  3. It claims the nonce in the replay store and verifies the signature; failures return 401.
  4. For login flows, the device calls GET .../devices/{deviceId}/token and receives a one-time opaque token valid for five minutes.
  5. The device hands the token to the customer backend, which calls POST .../devices/{deviceId}/token/verify with its bearer JWT. The server consumes the token once and confirms the device (202), or returns 409.
  1. The backend posts a message with a bearer JWT and an X-Correlation-Id.
  2. The server validates the request and deduplicates by customer, app and correlation ID; a duplicate returns the original pushId.
  3. It stores metadata, the deduplication record and an outbox command in one transaction and returns 202 with the pushId.
  4. The outbox dispatcher publishes the command to the INSTANT or standard queue and waits for broker confirmation.
  5. The consumer resolves eligible devices, selects the provider, freezes the localized text per recipient and stores the encrypted payload per device.
  6. It claims each recipient, sends the provider request (silent pushId-only push for private notifications, public alert otherwise) and records SENT, EXPIRED or ERROR.
  7. Retryable failures go to the delay queue; for private notifications a fallback job sends the public notification if the device has not retrieved the message in time.
  1. The woken app lists messages (GET .../devices/{deviceId}/messages, cursor-based) or fetches one message by pushId, signed with its device key.
  2. The server returns the public notification and the per-device encryptedNotification and records the retrieval, which cancels a pending fallback.
  3. INSTANT messages are marked DELIVERED and archived on first read; ALERT messages can be read repeatedly.
  4. The app decrypts the JWE, verifies the nested server signature and displays the notification.
  5. The app reports delivered, read or deleted with a signed PUT on the message; the aggregate message state is recomputed asynchronously.
  1. The backend includes a callback (URL and auth type) in the message; the URL must be permitted by the sender’s policy in the tenant configuration.
  2. The app signs the answer with its device key, encrypts it to the server key and posts it to .../messages/{pushId}/callback.
  3. The server checks that the recipient is DELIVERED or READ and the callback has not expired, decrypts the JWE and verifies the device signature.
  4. It resolves the configured outbound credentials (or obtains an OAuth token for SERVICE_TOKEN) and durably claims the recipient.
  5. It posts the decrypted JSON to the backend with an Idempotency-Key header. On a 2xx response the recipient becomes ANSWERED and the device receives 200; a non-2xx response returns 502.