Metadata-Version: 2.3
Name: mcms-pages
Version: 0.1.0
Summary: Represents pages within the MCMS component-tree architecture
Author: MikemathuKE
Author-email: MikemathuKE <michaelmathu6@gmail.com>
Requires-Dist: django>=6.0
Requires-Dist: mcms-core
Requires-Dist: mcms-content
Requires-Dist: mcms-design
Requires-Dist: mcms-components
Requires-Dist: mcms-render
Requires-Dist: mcms-layouts
Requires-Dist: mcms-data
Requires-Python: >=3.13
Description-Content-Type: text/markdown

# MCMS Pages

`mcms_pages` represents pages within the MCMS component-tree architecture. A page's visual composition is represented by a single root component tree, using the canonical `RenderTree` model.

## Responsibilities established by the ADRs

- Represent a page as a composition of RenderNodes.
- Associate the page with a root RenderNode composition.
- Use `RenderTree` as the canonical representation of that composition.
- Support the same runtime editing, styling, and rendering model used by other component compositions.
- Allow templates to be used as authoring-time blueprints and absorbed into the page tree.

## Page composition

A page references a single root component instance, which composes the page through component relationships.

```text
Page
  |
  v
Root component / RenderTree
  |
  +--> Header
  +--> Hero
  +--> Content sections
  +--> Footer
```

There is no separate page-layout tree. Every visible element is represented through the RenderNode tree.

## Templates and pages

`mcms_templates` provides reusable component compositions. When an author selects a template:

1. The template's `RenderTree` is cloned.
2. The clone receives new node identifiers.
3. The cloned tree is inserted into the page's `RenderTree`.
4. The inserted nodes become ordinary page-owned nodes.

Templates are authoring-time blueprints. A page does not retain a mandatory live template dependency after insertion, and changes to the source template do not automatically propagate to existing pages.

A page ultimately contains one `RenderTree`.

## Render-tree invariants

Page composition relies on the invariants maintained by `mcms_render`:

- Each node has a unique identity.
- A node belongs to one tree.
- A node has at most one parent.
- Parent and child indexes remain consistent.
- The tree has a valid root and ordering.
- Cycles are not permitted.
- Cloning and insertion maintain identifier consistency.

## Architectural integrations

| Package | Relationship |
|---|---|
| `mcms_core` | Shared registry and exception infrastructure |
| `mcms_components` | Defines the components used to construct a page |
| `mcms_render` | Owns the canonical `RenderTree` and `RenderNode` representation |
| `mcms_templates` | Supplies reusable compositions that are instantiated into a page tree |
| `mcms_design` | Supplies visual presentation definitions |
| `mcms_data` | Resolves dynamic data before rendering |

## Application configuration

The supplied ADRs do not name page-specific global settings, URL configuration, or an `apps` import path.

## Dependencies

### Architectural integrations

The most important architectural dependency is `mcms_render`, because the page's composition is represented by its `RenderTree`. The other integrations above describe the broader authoring and rendering flow; they are not necessarily direct Python dependencies.

### Python distribution dependencies

All MCMS Packages rely on django

## Development

```bash
uv run pytest packages/mcms-pages/tests
```

Run Ruff and mypy using the repository's configured commands.
