> For the complete documentation index, see [llms.txt](https://ispectra.gitbook.io/mutamad/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ispectra.gitbook.io/mutamad/concepts/architecture.md). Agents can also search and read this documentation through its [MCP server](https://ispectra.gitbook.io/mutamad/~gitbook/mcp).

# Architecture

A thin profile over a recipe-composed site template, and why it has that shape.

Mutamad is structured the way Drupal CMS 2 is: a **thin installation profile** over a **site template** built from **recipes**. Every control lives in a recipe that can be applied to a bare Drupal site and checked in a test.

<figure><img src="https://171036656-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FQSekKpxOCXC1q6G2NRy9%2Fuploads%2Fgit-blob-d9164fa5ebc421657a5dcd144eb8156700aea362%2Fdiagram-layers.svg?alt=media" alt="Mutamad&#x27;s layers: the entity&#x27;s site on top, Mutamad&#x27;s project template, profile, site template and recipes in the middle, the Drupal ecosystem and core below"><figcaption><p>Mutamad's layers. What is specific to one entity stays in the entity's own site, above Mutamad.</p></figcaption></figure>

## The parts

| Part                | Composer type          | Role                                                                                                                                                                     |
| ------------------- | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `mutamad_project`   | `project`              | What a developer `create-project`s. Pins core and the profile, scaffolds hardened settings, carries the patches, ships DDEV with `install-mutamad` and `mutamad-verify`. |
| `mutamad`           | `drupal-profile`       | Owns the installer — its forms, its theme and a few install steps — and **no site configuration**.                                                                       |
| `mutamad_starter`   | `drupal-recipe` (Site) | The site template. Applies every recipe in a fixed order and ships the site's pages, menus and sample content.                                                           |
| `mutamad_*` recipes | `drupal-recipe`        | One concern each: security, workflow, a content type…                                                                                                                    |
| `mutamad_*` modules | `drupal-module`        | Code a recipe cannot hold. Some carry their recipe inside them (`mutamad_multilingual`, `mutamad_search`, `mutamad_ai`).                                                 |
| `mutamad_theme`     | `drupal-theme`         | The front-end theme, a Drupal core starterkit.                                                                                                                           |

Every one of them is a **separate drupal.org project**, with its own repository, releases and issue queue.

## The rules that keep it this way

1. **Configuration lives in recipes, never in the profile.** A recipe can be applied to a bare site and its resulting configuration asserted in a test. A profile's install hooks cannot.
2. **One concern per recipe.** Each recipe is independently applicable and testable against a bare core install, so "which recipe implements ECC 2-2-3-3?" has one answer.
3. **Never edit core or contributed code in place.** When core or Drupal CMS sets something Mutamad needs changed, a Mutamad recipe applied *after* theirs overrides it.
4. **Nothing entity-specific in a `mutamad_*` recipe.** An entity's own requirements go in its own module. This is how a distribution avoids turning into one client's site.
5. **Every contributed dependency is a decision.** Adding a module changes what the baseline is and what an auditor must account for; each is added for a stated reason.
6. **The installer theme lives in the profile; the site theme does not.** The installer runs before any recipe.

## The order of recipes is load-bearing

`mutamad_starter` applies its recipes in this order, for these reasons:

| Order | Recipe                                                                                    | Why here                                                                                                                          |
| ----- | ----------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
| 1     | `mutamad_roles`                                                                           | **Roles before grants.** A grant to a role that does not exist stops a recipe ("Entity user.role.… does not exist").              |
| 2     | `mutamad_security`                                                                        | The baseline before anything else.                                                                                                |
| 3     | `mutamad_crypto`                                                                          | The key that encrypts MFA secrets, and MFA itself.                                                                                |
| 4     | `mutamad_multilingual`                                                                    | Adds the second language before any content type or field exists.                                                                 |
| 5     | `core/recipes/tags_taxonomy`, `mutamad_media`                                             | **Providers before grants.** Core's standard recipe grants permissions whose modules it never installs; these install them first. |
| 6     | `core/recipes/standard`                                                                   | Drupal's standard set-up.                                                                                                         |
| 7     | Easy Email Express, Drupal CMS authentication and accessibility tools                     | HTML email, login by username or email, Editoria11y.                                                                              |
| 8     | `mutamad_forms`, `mutamad_editor`, `mutamad_admin`, `mutamad_logging`, `mutamad_workflow` | Forms, editor, admin UI, logs, approval.                                                                                          |
| 9     | `mutamad_canvas`, `mutamad_theme_recipe`                                                  | The page builder, then the theme on it.                                                                                           |
| 10    | `mutamad_seo`, `mutamad_privacy`, `mutamad_search`, `mutamad_dashboard`                   | Search and sharing, consent, site search, dashboard.                                                                              |
| 11    | `mutamad_content_base`, then the content types                                            | Services, FAQ, News, Events, Publications, Leadership, Newsletter.                                                                |
| 12    | The site's own pages, menus and content                                                   | As Canvas pages and content, in Arabic and English.                                                                               |

The optional recipes (`mutamad_e_consultations`, `mutamad_life_journeys`, `mutamad_analytics`, `mutamad_ai`) are required by the starter, so every site has them in its code base, but not applied.

## Three things that fail silently

Mutamad is built around three failure modes, each of which produces an install that reports success:

1. **Recipes skip a module's default configuration.** A recipe applies configuration in *syncing mode*, which does not process a module's `config/install`. Each Mutamad recipe imports what it needs explicitly (`config: import:`).
2. **`views.view.frontpage` is optional configuration**, and the only provider of the `/node` route the front page points at. Without it the front page is a 404. `core/recipes/standard` imports it.
3. **A permission whose module or bundle does not exist is dropped** from the role, with only a log line ("Non-existent permission(s) assigned to role … were removed"). The control is simply absent. `mutamad-verify` searches the log for it.

## Content types and their layout

A content-type recipe must apply on bare core, so its Canvas content template uses only field components. `mutamad_starter`, which also installs the theme, replaces those templates with the theme's DGA components at the site's component versions. Applied alone, a content type works and looks plain; on a Mutamad site, it looks like DGA's template.

## Custom config actions

`mutamad_canvas_controls` gives recipes three config actions for Canvas:

* `createWithComponentTree` — create a page template or pattern with its components and their translations
* `setComponentTree` — replace a content template's components
* `addComponents` — add components after a given anchor, with translations

They exist because Canvas pins component versions that differ from site to site.

<figure><img src="https://171036656-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FQSekKpxOCXC1q6G2NRy9%2Fuploads%2Fgit-blob-09504da751e1a89805aeb73c02e56badca8ca46b%2Fcanvas-en.jpg?alt=media" alt="The About us page in the Canvas editor"><figcaption><p>A Canvas page built from the Mutamad theme's components.</p></figcaption></figure>
