How contentful/apps works
Project type and purpose
• This is a large monorepo (“apps” + “packages” + “scripts”) containing multiple Contentful Marketplace apps (React front‐ends, serverless back‐ends, and shared libraries).
• It’s managed with Lerna/Nx (see lerna.json, nx.json) and contains CI/CD configurations (.circleci/, .github/workflows).
Structure and extract main components
• Monorepo Root
– Package manager & orchestrators (package.json, lerna.json, nx.json).
– CI/CD pipelines (.circleci/config.yml, GitHub workflows).
– Scripts (scripts/… for provisioning Contentful spaces, apps, etc.).
• Shared Libraries (packages/)
– dam-app-base
– ecommerce-app-base
– eslint-plugin-contentful-apps
These are npm packages consumed by individual apps.
• Apps (apps/)
By pattern:
– UI-only (e.g. ai-content-generator, aws-amplify, bulk-edit): React-based front-ends loaded in the Contentful web app.
– Front-end + serverless back-end (e.g. ai-image-generator, google-analytics-4, slack):
• Front-end (apps/<app>/frontend or apps/<app>/src): Vite/React, Contentful App SDK.
• Serverless functions (apps/<app>/backend or apps/<app>/lambda): handlers keyed to App Actions or App Events, deployed via Serverless framework/Docker.
– Examples of external service clients in services/ or utils/: OpenAI, AWS Bedrock, Google Analytics, Slack, MS Teams, etc.
• External services
– Contentful Content Management API & App SDK
– Third-party APIs (OpenAI, AWS Bedrock, Google Analytics, Slack, Microsoft Graph, Mux, etc.)
Relationships and interactions
• Each app’s front-end is embedded in Contentful’s extension iframe.
• User interactions in the UI call:
– Shared libraries (dam-app-base, ecommerce-app-base).
– Contentful App SDK → CMA or own serverless functions.
• Serverless back-end functions (lambda) handle:
– App actions/events (e.g. generate AI content, upload images).
– Proxy to third-party APIs.
– Persist credentials or usage in a database (e.g. DynamoDB for google-analytics-4, slack).
• CI/CD pipelines run tests (frontend with vitest/jest, backend with Mocha), build bundles, and deploy functions to cloud providers.
Key architectural patterns
• Monorepo + Lerna/Nx: centralized dependency management and versioning.
• Modular apps: each app folder is an independent micro-frontend (and optional micro-service).
• Shared UI libraries: base packages reduce duplication across apps.
• Serverless microservices: stateless functions triggered by HTTP (actions) or events, scale on demand.
• Layered separation:
– Presentation: React-based UI loaded in Contentful.
– Business logic: Hooks, utils, providers in front-end.
– Integration layer: Serverless functions & API helpers.
– External systems: CMA, third-party APIs, Databases.