HomeIntegrations & Platform Patterns › Where integration logic belongs

Where integration logic belongs

Purpose: Decide per integration whether logic lives in AEM, in middleware, or in the browser.

Who this page is for

AudienceWhy it matters to you
Backend engineersDesign decisions
Tech leadsArchitecture reviews

The decision table

SignalPut it in…
Data is content-like, freshness ≥ hoursAEM scheduled sync → repository (pattern)
Per-user, personalised, or session dataBrowser → API directly (or via gateway), never in cached HTML
Orchestrating several systems, transformation-heavyMiddleware/API gateway — keep AEM a consumer
Simple read of one stable API for renderingAEM service with cache + breaker
Write operations (form submissions)Servlet → queue/job → upstream, or direct browser → API
Adobe ecosystem (Analytics/Target)Their JS/tag integration, configured not coded

Why "not in AEM" is often right

AEM's strengths: content, rendering, authoring. Its weaknesses as an integration hub: render-thread coupling, JVM redeploys for logic changes, limited horizontal elasticity of author. A thin gateway (or serverless functions) owning aggregation/transformation keeps AEM releases about experience, not plumbing. The elective edge-compute patterns page covers pushing this further.

The client-side split (PHI example)

The plan page is cached HTML for everyone. The "your estimated premium" module is personalised:

Cached page HTML (same for all users)
   └── <div data-module="premium-estimate" data-plan="gold-hospital">
              │ clientlib JS on load
              ▼
        GET api.example.org/quote?plan=gold-hospital (browser → gateway, with user token)

Cacheability preserved, personalisation delivered, AEM uninvolved at request time.

Anti-patterns

Quick navigation