1.6 KiB
1.6 KiB
Presenters (Strict)
This document defines the Presenter boundary for apps/website.
Presenters exist to prevent responsibility drift into:
- server routes
- Page Queries
- Templates
1) Definition
A Presenter is a deterministic, side-effect free transformation between website presentation models.
Allowed transformations:
- Page DTO → ViewData
- Page DTO → ViewModel
- ViewModel → ViewData
2) Non-negotiable rules
- Presenters MUST be deterministic.
- Presenters MUST be side-effect free.
- Presenters MUST NOT perform HTTP.
- Presenters MUST NOT call API clients.
- Presenters MUST NOT access cookies/headers.
- Presenters MAY use Display Objects.
- Presenters MUST NOT import Templates.
3) Where Presenters run
Presenters run in client code only.
Presenters MUST be defined in 'use client' modules.
If a computation affects routing decisions (redirect, notFound), it belongs in a Page Query or server route composition, not in a Presenter.
4) Relationship to Display Objects
Display Objects implement reusable formatting/mapping.
Rules:
- Presenters may orchestrate Display Objects.
- Display Object instances MUST NOT appear in ViewData.
See DISPLAY_OBJECTS.md and VIEW_DATA.md.
5) Canonical placement in this repo (strict)
Presenters MUST live colocated with ViewModels under:
apps/website/lib/view-models/**
Reason: this repo already treats apps/website/lib/view-models/** as the client-only presentation module boundary.