How anandkilli/aem-spa-react works
Project type and purpose
• This is a full-stack, multi-module Maven project integrating an existing React SPA with Adobe Experience Manager (AEM) 6.4 as an SPA editor.
• Key indicators:
• “react-app” directory is a standard Node/React application
• “ui.apps” and “ui.content” contain AEM client libraries and JCR content definitions
• “core” is an OSGi bundle implementing Sling filters, servlets, models, schedulers
• Integration tests under “it.launcher” and “it.tests”
File structure
• Top-level modules (all under com.techmystyle.spa.react-demo):
• core – Java OSGi bundle: logging filter, resource listener, Sling model (HelloWorldModel), scheduled tasks, servlets
• it.launcher – launches an AEM instance for integration tests (uses Sling testing harness)
• it.tests – server-side integration tests against Sling model JSON endpoints
• react-app – Node/React SPA with webpack, builds App.js and clientlib.config.js for AEM SPA editor
• ui.apps – AEM clientlibs (CSS/JS under /apps/react-demo/clientlibs), component definitions, templates, Sling servlets for error handling
• ui.content – JCR content: /apps configurations under /conf/react-demo, editable templates and policies, sample content under /content/react-demo, DAM assets
• Root pom.xml orchestrates module builds and packaging (mvn clean install -PautoInstallPackage,buildDev -Padobe-public).
README for additional insights
• Project purpose: step-by-step integration of an existing React SPA into AEM SPA editor
• Build steps: npm install, then Maven build with AEM packaging
• Dependency on AEM 6.4, Node 8, Java 8, Maven 3.5.2
a. Main components
1. Developer Workstation
• Node toolchain: npm, webpack dev server
• Maven CLI
2. React SPA (react-app)
• Source: App.js + components
• Build: webpack → dist/App.js
3. AEM Author/Publish Instance
• Sling OSGi container
• core bundle (filters, models, servlets, schedulers)
• it.launcher for test harness
• CRX JCR repository
• ui.apps clientlibs and component definitions under /apps/react-demo
• ui.content templates, policies, sample content under /conf/react-demo and /content/react-demo
4. Browser / SPA Editor UI
5. Integration Tests (it.tests)
b. Relationships and interactions
• Developer runs npm build → generates client-side JS assets
• Maven packages assets and OSGi bundle → installs to AEM
• Browser requests page → AEM Sling resolves templates, includes clientlibs (/etc/clientlibs/react-demo)
• React SPA boots in the browser; client-side routing fetches JSON models via Sling Model Exporter servlet endpoints (e.g., /content/react-demo.model.json)
• OSGi bundle (core) exports RESTful JSON for Sling models (HelloWorldModel)
• Scheduled tasks and filters in core handle server-side events and logging
• Integration tests launch an in-JVM AEM server (it.launcher) and run server-side tests (it.tests) against Sling servlets and model endpoints
c. Architectural patterns and design principles
• Multi-module Maven for clear separation of concerns
• OSGi modularity: core business logic in bundles
• SPA editor pattern in AEM: React components mapped to AEM components and Sling models
• Client-side build pipeline (webpack) decoupled from server packaging (Maven)
• Test harness using Sling Testing Tools for automated integration tests
d. Relevant technologies, frameworks, libraries
• React, Babel, Webpack (react-app)
• Node.js, npm
• Maven multi-module
• AEM 6.4 (Sling, OSGi container, JCR)
• Sling Model Exporter
• Sling Testing Tools (it.launcher, it.tests)
Elements
• Rectangles for each component/module (e.g., React Build, core OSGi bundle, ui.apps, ui.content, Browser, Integration Test Harness)
• Green for frontend (react-app, browser)
• Blue for backend/AEM (core bundle, ui.apps, ui.content, Sling container)
• Gray for build/deploy pipeline (npm, Maven)
• Orange for tests (it.launcher, it.tests)
Detail
• Important endpoints (e.g., /apps/react-demo/clientlibs/clientlib-react-demo/js/App.js, /content/react-demo.model.json)
• How templates, policies (ui.content) configure the SPA editor and how clientlibs (ui.apps) serve the React assets
• OSGi bundle lifecycle (install, activate) and Sling Model Exporter interactions