> For the complete documentation index, see [llms.txt](https://developer.emporix.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.emporix.io/partner-library/partner-components/medienwerft-cms/developer-guide/how-it-fits-together.md).

# How it fits together

Three parts, each owning one thing:

Three parts, each owning one thing:

| Part                                                                 | Owns                                                                                                                                                                                         |
| -------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **cms-api**, an Emporix cloud function in your tenant                | The content. Editors work in the CMS perspective of the Emporix Management Dashboard; cms-api stores pages, layouts and themes as Emporix custom entities and serves them to the storefront. |
| **The storefront**                                                   | Its own routes, its shop and checkout, and the places a CMS can plug into: the *extension points* and the *CMS adapter hooks*. It knows no CMS by name.                                      |
| **The Medienwerft CMS plugin** (`extensions/medienwerft-cms-plugin`) | Everything between the two: rendering CMS content, the site layout, the theme, the live preview in the editor, 23 ready-made components, and the product and category pickers.               |

## How the plugin gets in: extension points

The storefront's `npm run generate` reads the plugin's `plugin.json` and generates what the plugin declares into gitignored files: two routes (`/api/cms/…` and the editor's preview page), a CSRF exemption for the publish callback, the environment check and the SDK dependencies. Remove the plugin and the next `generate` removes them again. Nothing under `src/` is edited by hand.

## How it takes over: the CMS adapter

The storefront asks its *active CMS* for everything CMS-related, through one interface (`CmsAdapter`). `NEXT_CMS_PROVIDER` decides which CMS is active. With `NEXT_CMS_PROVIDER=contenter` it is the plugin's adapter, which contributes:

| Hook                        | What the storefront gets                                                                                                                                                                                                                      |
| --------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `providesLayout` + `Layout` | The **whole site layout** from the CMS — header, navigation, footer. The storefront renders none of its own; see [chapter 5](https://developer.emporix.io/partner-library/partner-components/medienwerft-cms/developer-guide/site-layout.md). |
| `PageRenderer`              | CMS pages rendered by the plugin, so the storefront's home page and catch-all route show CMS content unchanged.                                                                                                                               |
| `Root`                      | The theme stylesheet, the component registry and the live-preview runtime around every page.                                                                                                                                                  |
| `getBodyProps`              | The theme's attributes on `<body>`.                                                                                                                                                                                                           |

Because all of this comes from the adapter rather than from the storefront's code, **switching the CMS is one variable**: `NEXT_CMS_PROVIDER=storyblok` and the storefront renders exactly as without the plugin, set it back and the plugin takes over. See [chapter 9](https://developer.emporix.io/partner-library/partner-components/medienwerft-cms/developer-guide/switching-storyblok-contenter.md).

## What talks to what

```
Editor (Emporix Management Dashboard, CMS perspective)
  │ edits, publishes ──────────────> cms-api (cloud function) <── reads ──┐
  │                                        │                              │
  └─ previews the storefront in a frame ──>│                              │
                                           v                              │
                                  Storefront + plugin ────────────────────┘
                                  (reads published content with an Emporix token,
                                   drafts only for the editor's preview)
```

* **Content reads** go from the storefront's server to cms-api, through the Emporix gateway, with an **Emporix access token**. The plugin obtains it from an Emporix API key. See [chapter 4](https://developer.emporix.io/partner-library/partner-components/medienwerft-cms/developer-guide/credentials-and-environment.md).
* **The editor's preview** loads the storefront in a frame. The storefront checks the **CMS API key** before it shows anything unpublished.
* **Publishing** can refresh the storefront's cache at once, through the Emporix Orchestration Engine. See [chapter 8](https://developer.emporix.io/partner-library/partner-components/medienwerft-cms/developer-guide/publishing-caching-and-webhooks.md).

Next: [Set up the CMS in Emporix](https://developer.emporix.io/partner-library/partner-components/medienwerft-cms/developer-guide/set-up-the-cms-in-emporix.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://developer.emporix.io/partner-library/partner-components/medienwerft-cms/developer-guide/how-it-fits-together.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
