docs
This commit is contained in:
56
docs/architecture/website/PRESENTERS.md
Normal file
56
docs/architecture/website/PRESENTERS.md
Normal file
@@ -0,0 +1,56 @@
|
||||
# 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
|
||||
|
||||
1. Presenters MUST be deterministic.
|
||||
2. Presenters MUST be side-effect free.
|
||||
3. Presenters MUST NOT perform HTTP.
|
||||
4. Presenters MUST NOT call API clients.
|
||||
5. Presenters MUST NOT access cookies/headers.
|
||||
6. Presenters MAY use Display Objects.
|
||||
7. 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`](docs/architecture/website/DISPLAY_OBJECTS.md:1) and [`VIEW_DATA.md`](docs/architecture/website/VIEW_DATA.md:1).
|
||||
|
||||
## 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.
|
||||
Reference in New Issue
Block a user