AI-DLC: inception en ontwerp voor redesign B/E met contactformulier
Requirements, application design (incl. concept-API-contract voor het contactformulier), units en functional design voor U1. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
+41
@@ -0,0 +1,41 @@
|
||||
# Application Design — redesign-modern-timetravel (consolidated)
|
||||
|
||||
Details: [components.md](components.md) · [component-methods.md](component-methods.md) · [services.md](services.md) · [component-dependency.md](component-dependency.md) · [contact-api-contract.md](contact-api-contract.md)
|
||||
|
||||
## Decisions (user, 2026-11-09)
|
||||
| # | Decision | Source |
|
||||
|---|---|---|
|
||||
| D1 | Shared layer (content, data hooks, form logic) + separate presentation for B and E; E lazy-loaded | Design Q1-A |
|
||||
| D2 | Variant is app state only, not in the URL, not persisted; every visit starts in B | Design Q2-A, Req Q3-A |
|
||||
| D3 | Headless form logic is written first in this repo in a movable folder `src/cms-client/`, then handed over to SlpModularCms | Design Q3-B |
|
||||
| D4 | One frontend package `cms-client` with separately importable parts (subpaths); offerings moves in later | Follow-up decision |
|
||||
| D5 | API module Contact/Forms in SlpModularCms built by `SLS Software - CMS` | Req Q10-A/Q11-B |
|
||||
| D6 | Mode (light/dark) follows system preference, overridable and persisted | Req Q5-B |
|
||||
|
||||
## Architecture overview
|
||||
```mermaid
|
||||
graph LR
|
||||
subgraph FE[slp-software-frontend]
|
||||
TP[ThemeProvider variant x mode] --> VR[VariantRenderer]
|
||||
VR --> B[Variant B eager]
|
||||
VR -.lazy.-> E[Variant E chunk]
|
||||
B --> S[shared logic]
|
||||
E --> S
|
||||
B --> CC[src/cms-client movable]
|
||||
E --> CC
|
||||
end
|
||||
CC --> API[SlpModularCms API: Contact/Forms module and Offerings category]
|
||||
S --> API
|
||||
classDef fe fill:#63b3ed,stroke:#2b6cb0,color:#000;
|
||||
classDef pkg fill:#f6e05e,stroke:#c05621,color:#000;
|
||||
classDef ext fill:#9ae6b4,stroke:#2f855a,color:#000;
|
||||
class TP,VR,B,E,S fe;
|
||||
class CC pkg;
|
||||
class API ext;
|
||||
```
|
||||
Text alternative: the theme provider drives a variant renderer that shows eager B or lazy E; both use shared logic and the movable cms-client folder, which talks to the CMS API.
|
||||
|
||||
## Design validation
|
||||
- Requirements coverage: FR-1..FR-6 (theme, variants, nav buttons, mode rules) → ThemeProvider, ModeToggle, VariantToggle, VariantRenderer, LandingB/E. FR-7..FR-12 (packages) → usePackagesQuery/usePackageFilter/useSwipeRow + PackagesB/E. FR-13..FR-19 (form) → cms-client/contact, form skins, contract. NFR-1..8 → usePrefersReducedMotion, code split, boundary lint rule, scrubbing, tests.
|
||||
- Consistency: all component names in methods/dependency docs exist in components.md; contract field names equal the hook payload.
|
||||
- Open items are listed in contact-api-contract.md § 9 and are owned by the CMS sessions.
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
# Component Dependencies
|
||||
|
||||
## Dependency matrix (frontend)
|
||||
|
||||
| Component | Depends on |
|
||||
|---|---|
|
||||
| RootLayout | ThemeProvider, VariantRenderer, UmamiAnalytics |
|
||||
| VariantRenderer | ThemeProvider, LandingB, LandingE (lazy) |
|
||||
| LandingB / LandingE | shared/content, usePackagesQuery, usePackageFilter, useSwipeRow, ContactPreselectContext, cms-client/contact, ModeToggle, VariantToggle |
|
||||
| PackagesB / PackagesE | usePackageFilter, useSwipeRow, ContactPreselectContext |
|
||||
| ContactFormView / ContactFormTerminal | cms-client/contact only (props) |
|
||||
| cms-client | nothing outside `cms-client` (enforced by ESLint `no-restricted-imports`) |
|
||||
| ThemeProvider | tokens, localStorage (guarded) |
|
||||
|
||||
## Diagram
|
||||
|
||||
```mermaid
|
||||
graph TD
|
||||
Root[RootLayout] --> TP[ThemeProvider]
|
||||
Root --> VR[VariantRenderer]
|
||||
VR --> LB[LandingB eager]
|
||||
VR -.lazy.-> LE[LandingE chunk]
|
||||
LB --> PB[PackagesB]
|
||||
LB --> CB[ContactB with ContactFormView]
|
||||
LE --> PE[PackagesE]
|
||||
LE --> CE[ContactE with ContactFormTerminal]
|
||||
PB --> Shared[shared: filter, swipe, content, preselect]
|
||||
PE --> Shared
|
||||
CB --> CC[cms-client/contact headless]
|
||||
CE --> CC
|
||||
CC --> HTTP[cms-client/http]
|
||||
Shared --> Q[usePackagesQuery]
|
||||
Q --> API[(CMS API offerings)]
|
||||
HTTP --> API2[(CMS API contact-messages)]
|
||||
classDef ui fill:#63b3ed,stroke:#2b6cb0,color:#000;
|
||||
classDef shared fill:#9ae6b4,stroke:#2f855a,color:#000;
|
||||
classDef pkg fill:#f6e05e,stroke:#c05621,color:#000;
|
||||
classDef ext fill:#e2e8f0,stroke:#4a5568,color:#000;
|
||||
class Root,TP,VR,LB,LE,PB,PE,CB,CE ui;
|
||||
class Shared,Q shared;
|
||||
class CC,HTTP pkg;
|
||||
class API,API2 ext;
|
||||
```
|
||||
|
||||
Text alternative: the root layout renders the variant renderer, which shows the eager B landing or the lazy E landing; both use shared logic and the headless cms-client contact part, which talks to the CMS API through the http helpers.
|
||||
|
||||
## Communication patterns
|
||||
- Theme/variant: React context (no URL, no persistence of variant).
|
||||
- Data: TanStack Query for offerings; imperative fetch with state reducer for the form.
|
||||
- Package → form: `ContactPreselectContext.select(subject)` then hash scroll to `#contact`; the form hook applies it when `key` changes.
|
||||
- Cross-repo: HTTP only (`/api/v1/...`, same origin through nginx); source-level sharing via the movable `cms-client` folder.
|
||||
|
||||
## Data flow: form submission
|
||||
```mermaid
|
||||
sequenceDiagram
|
||||
box rgba(99,179,237,0.4) Browser
|
||||
participant V as Visitor
|
||||
participant H as useContactForm
|
||||
end
|
||||
box rgba(154,230,180,0.4) CMS API
|
||||
participant A as contact-messages
|
||||
participant M as IEmailSender
|
||||
end
|
||||
V->>H: focus form
|
||||
H->>A: GET token
|
||||
A-->>H: signed token and captcha info
|
||||
V->>H: submit valid values
|
||||
H->>A: POST with Idempotency-Key
|
||||
A->>A: spam checks, store message
|
||||
A-->>H: 202 received
|
||||
A->>M: send mail (best effort)
|
||||
H-->>V: success message
|
||||
```
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
# Component Methods
|
||||
|
||||
Signatures are high-level. Business rules are detailed in Functional Design (U1, U3, U4).
|
||||
|
||||
## Theme
|
||||
```ts
|
||||
type Variant = 'b' | 'e';
|
||||
type Mode = 'light' | 'dark';
|
||||
resolveInitialMode(stored: string | null, systemPrefersDark: boolean): Mode;
|
||||
useTheme(): { variant: Variant; mode: Mode; toggleMode(): void; setVariant(v: Variant): void; toggleVariant(): void };
|
||||
```
|
||||
|
||||
## Packages (shared)
|
||||
```ts
|
||||
type PackageCardData = { id; slug; title; description; price; priceNote; features: string[]; ctaLabel; featured?: boolean; category?: string | null };
|
||||
usePackagesQuery(): UseQueryResult<PackageCardData[]>;
|
||||
usePackageFilter(packages: PackageCardData[]): { categories: { id: string; label: string; count: number }[]; active: string; setActive(id: string): void; visible: PackageCardData[]; showChips: boolean };
|
||||
useSwipeRow(itemCount: number, initialIndex: number): { ref: RefObject<HTMLElement>; activeIndex: number; scrollToIndex(i: number): void };
|
||||
```
|
||||
|
||||
## Contact preselect
|
||||
```ts
|
||||
useContactPreselect(): { subject: string | null; key: number; select(subject: string): void };
|
||||
```
|
||||
|
||||
## cms-client / contact (headless)
|
||||
```ts
|
||||
type ContactFields = { name: string; email: string; subject: string; message: string };
|
||||
type ContactErrorCode = 'required' | 'tooLong' | 'invalid';
|
||||
type ContactStatus = 'editing' | 'sending' | 'sent' | 'failed';
|
||||
|
||||
validateContact(values: ContactFields): Partial<Record<keyof ContactFields, ContactErrorCode>>;
|
||||
contactFormReducer(state: ContactState, event: ContactEvent): ContactState; // pure
|
||||
|
||||
createContactClient(opts?: { baseUrl?: string; fetch?: typeof fetch }): {
|
||||
getToken(): Promise<{ token: string; minSeconds: number; captcha: { provider: string; siteKey: string } | null }>;
|
||||
submit(payload: ContactPayload, ctx: { token: string; captchaToken?: string; idempotencyKey: string }): Promise<void>; // throws ContactApiError
|
||||
};
|
||||
|
||||
useContactForm(options: {
|
||||
idPrefix: string;
|
||||
subjectOptions: { value: string; label: string }[];
|
||||
preselect?: { subject: string | null; key: number }; // unknown value ignored
|
||||
submit?: ContactClient['submit']; // injectable
|
||||
messages?: Partial<ContactMessages>; // default nl
|
||||
now?: () => number;
|
||||
}): {
|
||||
status: ContactStatus; values: ContactFields; errors: Partial<Record<keyof ContactFields, string>>;
|
||||
getFieldProps(name: keyof ContactFields): { id; name; value; onChange; onBlur; 'aria-invalid'; 'aria-describedby' };
|
||||
honeypot: { name: string; ref; tabIndex: -1; autoComplete: 'off' };
|
||||
formProps: { onSubmit; noValidate: true };
|
||||
focusFirstError(): void;
|
||||
retry(): void;
|
||||
};
|
||||
```
|
||||
|
||||
## http
|
||||
```ts
|
||||
apiUrl(path: string): string; // VITE_API_BASE_URL ?? '' + path
|
||||
parseProblemDetails(res: Response): Promise<{ status: number; errors?: Record<string, string[]>; retryAfter?: number }>;
|
||||
```
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
# Components
|
||||
|
||||
Source layout (target):
|
||||
|
||||
```text
|
||||
src/
|
||||
cms-client/ # self-contained, movable to SlpModularCms (no imports from outside)
|
||||
index.ts # barrel, but sites import subpaths
|
||||
http/ # apiUrl, fetch helpers, ProblemDetails parsing
|
||||
contact/ # headless contact form
|
||||
offerings/ # (later) typed offerings client; types from OpenAPI
|
||||
theme/ # variant x mode state (replaces red/purple)
|
||||
shared/ # a11y/motion hooks, packages logic (filter, swipe), content
|
||||
variants/
|
||||
b/ # Modern (default, eager)
|
||||
e/ # Time-travel (lazy chunk)
|
||||
components/ # RootLayout shell, ErrorBoundary, analytics
|
||||
routes/ , router.tsx # unchanged (hash history)
|
||||
```
|
||||
|
||||
## Theme and switching
|
||||
### ThemeProvider (changed)
|
||||
- **Purpose**: owns `variant` ('b' | 'e') and `mode` ('light' | 'dark').
|
||||
- **Responsibilities**: initial mode from stored value else `prefers-color-scheme`; persist only mode; write `data-variant` and `data-mode` on `<html>`; variant always starts as 'b' and is never persisted.
|
||||
- **Interface**: `useTheme(): { variant, mode, toggleMode(), setVariant(v), toggleVariant() }`.
|
||||
|
||||
### ModeToggle (replaces ThemeToggle)
|
||||
- **Purpose**: light/dark switch in the nav of both variants. Accessible name "Wissel tussen licht en donker", `aria-pressed` for dark.
|
||||
|
||||
### VariantToggle (new)
|
||||
- **Purpose**: icon-only button next to ModeToggle; tooltip and accessible label ("Tijdreis" in B, "Terug naar nu" in E). Uses `toggleVariant`.
|
||||
|
||||
### VariantRenderer (new)
|
||||
- **Purpose**: renders `LandingB` or the lazy `LandingE` depending on `variant`; `Suspense` fallback (small neutral loader); focus and scroll position reset when the variant changes; announces the change to screen readers (`aria-live`).
|
||||
|
||||
### tokens (changed)
|
||||
- **Purpose**: CSS variable sets per `[data-variant][data-mode]` (B light/dark, E light/dark), semantic Tailwind color names kept (`bg`, `surface`, `text`, `muted`, `accent`, ...), plus variant-only tokens for E eras.
|
||||
|
||||
## Variant B (eager)
|
||||
- **LandingB**: composition of NavB, HeroB, AboutB, PackagesB, ProcessB, ContactB, FooterB.
|
||||
- **NavB**: wordmark, anchor links (no years), CTA, ModeToggle, VariantToggle, mobile menu.
|
||||
- **HeroB / AboutB / ProcessB / FooterB**: presentational ports of the canvas design B using shared content.
|
||||
- **PackagesB**: B styling of the packages block (square filter chips, cards, black "Past er niets bij?" banner), uses shared packages logic.
|
||||
- **ContactB**: red contact block with white (light) / dark form panel; uses `ContactFormView` from the B skin.
|
||||
|
||||
## Variant E (lazy chunk)
|
||||
- **LandingE**: eras in order 2026 → 2013 → 2006 → 1998 → 1989 with year badges; own nav bar style including ModeToggle and VariantToggle.
|
||||
- **Era sections** (EHero2026, EAbout2013, EPackages2006, EProcess1998, EContact1989): presentational ports of design E; the 1998 Werkwijze uses the step-card layout; the 1989 terminal looks the same in both modes.
|
||||
- **EffectsLayer**: marquee, scanlines, dither transitions, caret; all disabled via `usePrefersReducedMotion`.
|
||||
|
||||
## Shared (variant-independent)
|
||||
- **content.ts** (kept): nav links (without years), hero, about, process, contact copy, package seed; E-only era captions live in `variants/e`.
|
||||
- **usePackagesQuery** (kept): TanStack Query against `/api/v1/offerings`; type gains `category`.
|
||||
- **usePackageFilter**: derives categories (order of first appearance), counts, current filter, filtered list; `showChips` when `packages.length >= 4`.
|
||||
- **useSwipeRow**: scroll-snap helper for the mobile row (active index for dots, `scrollToIndex`, initial index = featured package); no JS needed for scrolling itself.
|
||||
- **usePrefersReducedMotion**, **usePrefersDark** (media query helpers).
|
||||
- **ContactPreselectContext**: `{ subject, key }`; the "Kies …" button of a package sets it (key increments on each click) and scrolls to the contact section.
|
||||
|
||||
## cms-client (movable package, headless)
|
||||
- **contact/ContactFormState**: pure reducer + types (`editing | sending | sent | failed`).
|
||||
- **contact/validateContact**: pure validation with limits (name 100, email 254, message 2000) and error codes (`required`, `tooLong`, `invalid`).
|
||||
- **contact/useContactForm**: React hook tying state, validation, preselect (initial value + change key), `idPrefix`, honeypot, token handling and submit; returns prop getters and slots data. No markup, no styles.
|
||||
- **contact/createContactClient**: fetch implementation of the API contract (`getToken`, `submit`) incl. ProblemDetails parsing, `Idempotency-Key`, 429 handling; submit function is injectable.
|
||||
- **contact/messages.nl**: default Dutch messages (injectable/overridable).
|
||||
- **http/**: `apiUrl()` honoring `VITE_API_BASE_URL`, shared error types.
|
||||
|
||||
## Form skins
|
||||
- **ContactFormView (B)** and **ContactFormTerminal (E 1989)**: presentational components consuming `useContactForm` output; render honeypot slot (visually hidden, `aria-hidden`, `tabIndex=-1`), privacy line, status regions (`role=alert` on error, `role=status` + focus on success).
|
||||
- **ContactGate** (optional): feature flag / env switch `VITE_CONTACT_FORM_ENABLED`; when off, shows the existing mailto fallback (address assembled client-side after mount, not in static HTML).
|
||||
|
||||
## Backend components (SlpModularCms, for hand-off; not built here)
|
||||
- **Contact/Forms module**: endpoints, validation, storage, mail via `IEmailSender`, spam checks, rate-limit policy, retention job, per-site config.
|
||||
- **Offerings module**: new optional `category` field.
|
||||
+226
@@ -0,0 +1,226 @@
|
||||
# Contact Form & Offerings — Draft API Contract
|
||||
|
||||
**Version**: 0.3.1-draft (2026-11-09) — incorporates the reviews of `SLS Software - CMS` (API side), `CMS & API` (ASF website) and `AndreaSlopFotografie` (ASF CMS/hosting) and the product decisions of Bryan (admin view in scope, spam stored as `spam`, captcha fail-open).
|
||||
**Status**: DRAFT for confirmation by the builders. Product decisions still open are marked **[Bryan]** (see § 10).
|
||||
**Source of truth** once agreed: the OpenAPI document generated by the CMS (`AddOpenApi`/`MapOpenApi`), exported as a **committed artifact** in SlpModularCms so `cms-client` can generate types from it. This file carries the behaviour agreements and the intended shape.
|
||||
**Compatibility**: breaking changes → `/api/v2`; additive changes allowed within `/api/v1`. The frontend package `cms-client` follows semver.
|
||||
|
||||
## 1. Scope
|
||||
1. New `Contact/Forms` module (own DbContext + additive migration per host, own Module class, like `Modules.Offerings`): token endpoint, submit endpoint, admin endpoints, background jobs.
|
||||
2. `GET /api/v1/offerings` gains the optional field `category`.
|
||||
3. Per-site configuration (host-based: Api.SlpSoftware, Api.AndreaSlopFotografie, ...).
|
||||
|
||||
All paths are **same-origin** (`/api/v1/...`) through "the reverse proxy of the host" (nginx for SLP; ASF production will be IIS — do not hard-code nginx). No CORS. The site id is derived from the host/config, **never** from the request body.
|
||||
|
||||
**Availability gate — decided (Bryan, 2026-11-09)**: the statuses (CMS disabled / maintenance, set by the master) block **only the CMS**, i.e. changing data and settings through the admin. **Public content is always available.** The gate therefore applies to admin/CMS routes only; the public routes `GET /api/v1/offerings`, `GET /api/v1/contact-messages/token` and `POST /api/v1/contact-messages` must stay reachable (a visitor's contact request is public site functionality, not a CMS change). Today `AvailabilityMiddleware` returns `503` for everything under `/api/` (bypass list limited); the CMS must align this with the decision (public routes on the bypass list or gate limited to admin routes), and the bypass must never cover admin routes. The frontend still treats `503`/network errors as a failure with the **mailto fallback** as a safety net.
|
||||
|
||||
## 2. Public endpoints
|
||||
|
||||
### 2.1 `GET /api/v1/contact-messages/token`
|
||||
Issues a server-signed token used for the minimum-time check, bound to the site. Tokens use **ASP.NET DataProtection** (key ring in the DB survives deploys), not a custom HMAC secret. The key ring must be **persistent per host** (DB or shared directory; on IIS it must survive app-pool recycles) and use a **per-site purpose string**, so an SLP token is invalid on ASF. (Already covered by the host-level `AddCmsDataProtection`, keys in the database; Contact only uses an `IDataProtector` with purpose `SlpModularCms.Contact.Token.{siteId}`; no own key ring or table.)
|
||||
|
||||
`200 application/json`
|
||||
```json
|
||||
{ "token": "<opaque signed string>", "minSeconds": 3, "captcha": null }
|
||||
```
|
||||
- `captcha` is `null` when disabled, else `{ "provider": "friendlycaptcha", "siteKey": "..." }`.
|
||||
- Token carries issue time + site id; valid for e.g. 120 minutes. Not stored.
|
||||
- Rate-limited; `429` with `Retry-After`.
|
||||
- The client fetches the token **lazily after hydration, on first focus/interaction**, not on page load (prerender contains no token; crawlers do not use up the limit).
|
||||
|
||||
### 2.2 `POST /api/v1/contact-messages`
|
||||
Headers: `Content-Type: application/json`, `Idempotency-Key: <uuid>` (required).
|
||||
|
||||
Request body:
|
||||
```json
|
||||
{
|
||||
"name": "Jan Jansen",
|
||||
"email": "jan@example.nl",
|
||||
"subject": "website",
|
||||
"message": "Ik wil graag een offerte voor …",
|
||||
"hpCheck": "",
|
||||
"token": "<from 2.1>",
|
||||
"captchaToken": null
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Required | Rules |
|
||||
|---|---|---|---|
|
||||
| `name` | string | yes | trimmed, 1–100 chars; control characters rejected |
|
||||
| `email` | string | yes | trimmed, 1–254 chars, regex `^[^\s@]+@[^\s@]+\.[^\s@]{2,}$`, no control characters |
|
||||
| `subject` | string | yes | trimmed, 1–100 chars; **opaque value** chosen by the site (a package id, slug, or `other`); no slug regex; stored as given, never validated against offerings. The label of `other` is per site (ASF: "Overig"). |
|
||||
| `message` | string | yes | trimmed, 1–2000 chars |
|
||||
| `hpCheck` | string | yes (key present) | **honeypot**; must be empty. Deliberately implausible name (not `website`/`url`) to avoid password-manager autofill; field is configurable per site; render with `autocomplete="off"`, `tabindex="-1"`, `aria-hidden`, off-screen |
|
||||
| `token` | string | yes | from 2.1 |
|
||||
| `captchaToken` | string \| null | when `captcha` enabled | verified server-side |
|
||||
|
||||
Responses:
|
||||
- `202 Accepted` — `{ "status": "received" }`. **Identical body and status for genuine and spam submissions** (honeypot filled, token too young, captcha failed) so bots learn nothing. Replays with the same `Idempotency-Key` (24 h) return the same 202 without storing twice.
|
||||
- `400 application/problem+json` — validation errors (§ 3): field validation; **expired, forged or other-site token** (all answered as `errors.token: ["expired"]`, so the endpoint is no oracle; the client fetches a fresh token and retries once automatically); missing or non-UUID `Idempotency-Key` (`errors.idempotencyKey: ["required" | "invalid"]`).
|
||||
- `413 application/problem+json` — body too large (`MaxRequestBodySize` per endpoint, e.g. 16 KB, with our own ProblemDetails shape).
|
||||
- `429 application/problem+json` — rate limit; header `Retry-After: <seconds>` (the existing `OnRejected` sets neither body nor `Retry-After` yet). This is a **separate, first-executed CMS unit**: it changes the behaviour of existing policies (login/refresh/sentry-tunnel), the admin frontend must cope with it and `PipelineTests` need adjusting. `Retry-After` comes from `MetadataName.RetryAfter` (available for fixed/sliding window limiters).
|
||||
- `503` — should not occur for the public routes (see § 1); if it does (e.g. host down behind the proxy), the client shows the mailto fallback.
|
||||
- `5xx application/problem+json` — generic; no internal detail.
|
||||
|
||||
## 3. Error shape (ProblemDetails)
|
||||
```json
|
||||
{
|
||||
"type": "about:blank",
|
||||
"title": "Validation failed",
|
||||
"status": 400,
|
||||
"errors": { "name": ["required"], "email": ["invalid"], "message": ["tooLong"] }
|
||||
}
|
||||
```
|
||||
The `type` URI is configurable per host (`Contact:ProblemTypeBase`), default `about:blank`, so no site domain is hard-coded in a module used by two sites; clients map on `errors`, never on `type`. Codes: `required`, `tooLong`, `invalid`, `expired` (token only; also for forged/other-site tokens). The `errors` mapping is custom (not the default ASP.NET `ValidationProblemDetails`). Messages are **not** localized by the API; the client maps `messages[field][code]`. Client-side validation uses the same limits and codes.
|
||||
|
||||
## 4. Server behaviour agreements
|
||||
1. **Store first, mail after commit.** Validate → store and commit (`status: new`, `mailStatus: pending`) → respond 202. Mail is **not fire-and-forget** in the request scope: a `BackgroundService`/queue picks up `pending` rows, sends via `IEmailSender`/`IMailAvailability` (returns `MailSendResult`, does not throw) and updates `mailStatus` and `mailAttempts`. A short sweep (every few minutes) catches `pending` rows left by a crash; `failed` rows are retried with **backoff** up to a configurable max attempts (so a first outage does not mean 24 h delay). A mail failure never fails the request. If `Email:Smtp:Host` is not configured: store only, show a notice in the admin.
|
||||
2. **Stored entity `ContactMessage`**: `id` (GUID), `siteId`, `receivedAt`, `name`, `email`, `subject`, `message`, `status` (`new` | `read` | `archived` | `spam` [Bryan] | later `converted`), `mailStatus` (`pending` | `sent` | `failed` + the existing error code, e.g. `auth_failed`, `rejected_sender`, `timeout_*`), `mailAttempts`, `retentionUntil` (fixed per row at insert; a config change does **not** apply retroactively). `id` and `status` exist so a message can later become an assignment for quotes/invoices (**not built now**). No IP address is stored.
|
||||
3. **Retention**: per site, default **12 months**; a daily `BackgroundService` (pattern: `IntegrityCheckBackgroundService`) deletes messages with `retentionUntil < now` and idempotency records older than 24 h. Database backups may keep messages longer: mention in the privacy statement or shorten backup retention. The admin can delete a single message (right to erasure).
|
||||
4. **Spam** (captcha behind an `ICaptchaVerifier` interface with a Null implementation when disabled): honeypot must be empty; elapsed time since token issue ≥ `minSeconds`; optional captcha verified server-side; rate limit policy `ContactForm` (defaults, config `RateLimiting:ContactForm`: 5 submissions per 10 minutes per client IP; token endpoint 20 per 10 minutes). Spam is answered with the normal 202. **Decided (Bryan):** instead of discarding, honeypot/too-young submissions are stored with `status: spam` (never mailed, retention 30 days) so a real visitor who tripped the check (autofill, very fast typist) is not lost silently; the visitor still sees the normal thank-you. **Cap on spam rows** (suggestion of `AndreaSlopFotografie` and `SLS Software - CMS`): per site at most N spam rows per day (default e.g. 200; `Contact:MaxSpamRowsPerDay`); above N the submission still gets the normal 202 but is only counted and logged, not stored. Spam rows are excluded from the unread counter and hidden from the default admin list (separate filter), so spam content is never shown first. Spam rows are stored with `retentionUntil = receivedAt + 30 days`, so the retention job works on each row's own `retentionUntil`. Timing: spam may be slightly faster (skips mail); accepted consciously. **Captcha provider failure** (timeout/5xx of the verify endpoint): **decided fail-open** with a log entry. Captcha ships **disabled** (honeypot + time + rate limit); it is a per-site switch for when abuse appears.
|
||||
5. **Client IP**: **release prerequisite** — on CMS master (`d9cc539`) the rate-limit policies are plain global buckets; the per-client partitioning (`ClientPartitionKey`) and `ForwardedHeaders` exist only on the unmerged ASF branch `feature/identity-email-notifications`. A `ContactForm` policy of 5 per 10 minutes as a global bucket would block the whole site after five submissions, so the contact routes must not be enabled on a public host before the per-client partitioning is on the base branch. The rate limit needs `ForwardedHeaders:KnownProxies` on each host (set on the test hosts; ASF production on IIS will differ), otherwise all visitors share one bucket (5 per 10 minutes for the whole site).
|
||||
6. **Privacy / logging**: never log `name`, `email`, `message` or the request body for this route; the Sentry SDK request body/PII is explicitly off for it (`BeforeSend` scrubbing; extra rule in the existing `SecurityEventProcessor`; a test proves a logged exception holds no body); client side: no form fields in Sentry breadcrumbs or replay (masked). Log only status codes, site id and outcome. Configuration errors of the mail setup are logged as Error (so the Sentry rule fires) in the style of `identity_mail_failed`, without addresses or content.
|
||||
7. **Idempotency**: table (`key`, `siteId`, `createdAt`, `statusCode`; no request content, no PII), unique index, cleaned after 24 h by the retention job; in-memory is not enough. Spam submissions also get a key record so replay behaviour is identical. Same key → same response, no second row, no second mail.
|
||||
8. **Mail safety**: `From` = fixed site sender on `Email:AllowedFromAddresses`; `Reply-To` = visitor e-mail (never as `From`: SPF/DMARC). Reject/strip control characters (`EmailAddressRules` exists) in `name`, `email`, `subject` before use in mail headers; HTML-encode all values in the body; never put `subject` 1:1 in the mail subject line (sanitize, cut at 100). The recipient address never appears in client-reachable config or in OpenAPI examples.
|
||||
9. **Availability gate / 503**: see § 1.
|
||||
10. **CSP** (frontend/host): `connect-src 'self'` suffices for the same-origin API. A captcha provider needs more (per provider and version, e.g. Friendly Captcha v1 `api.friendlycaptcha.com`/`eu-api.friendlycaptcha.eu`, v2 `global.frcapi.com`; widget script via npm bundle = `'self'`, else `script-src`; possible `'wasm-unsafe-eval'`, `worker-src blob:`, inline styles). The module documents the required directives per provider/version; the site adds them and tests in a real browser. The captcha provider must be named in the privacy statement.
|
||||
|
||||
## 5. Per-site configuration
|
||||
|
||||
Server (appsettings per host, `Contact:` section):
|
||||
| Setting | Example | Notes |
|
||||
|---|---|---|
|
||||
| `Contact:Enabled` | `false` | **safety switch** (release condition, § 4.5): while `false` both public contact routes answer `404` with an empty body and nothing runs; the client treats `404` on the token route as "form not available" and shows the mailto fallback. Enabled per host after the per-client rate-limit partitioning is on the base branch |
|
||||
| `Contact:RecipientEmail` | — | never exposed to the client. ASF: **env-only** (no ASF addresses in code or committed config); SLP may keep a committed default |
|
||||
| `Contact:SenderEmail` | — | must be on `Email:AllowedFromAddresses`; env-only for ASF |
|
||||
| `Contact:RetentionMonths` | `12` | |
|
||||
| `Contact:MinSeconds` | `3` | |
|
||||
| `Contact:TokenLifetimeMinutes` | `120` | |
|
||||
| `Contact:Captcha:Enabled / Provider / SiteKey / Secret` | `false` | secret via secrets manager |
|
||||
| `RateLimiting:ContactForm` | 5 / 10 min | |
|
||||
|
||||
Frontend per-site options (not API): subject options and labels (incl. the label of `other`), reply-time text, **privacy sentence and link target** (ASF: "Lees in de privacyverklaring wat ik met je gegevens doe." → `/privacyverklaring`), per-field message texts.
|
||||
|
||||
## 5a. Form fields and on/off switch (decided by Bryan, 2026-11-09)
|
||||
- **Fixed fields** for now (name, email, subject, message). A form builder with per-site field definitions is **not** part of this feature; it can come later as its own feature (field definitions as CMS data). The model stays extendable (additive migrations, contract versioned).
|
||||
- **Two-layer switch**: (1) host level `Contact:Enabled` (deployment, default off, release condition § 4.5); (2) a CMS switch for the owner: singleton resource `GET /api/v1/contact-settings` and `PUT /api/v1/contact-settings` (AdminOnly, body `{ "enabled": true|false }`, stored as data, default `false`). The form is active only when **both** are on. When either is off, `GET .../token` and `POST .../contact-messages` answer `404` with an empty body and the client shows the mailto fallback. Admin screen "Berichten" gets a visible switch ("Contactformulier aan/uit"). Implemented in CMS-U4 (API) and CMS-U6 (UI); CMS-U3 builds the gate behind an interface so U4 adds the CMS switch without rewriting the filter.
|
||||
|
||||
## 6. Admin endpoints (CMS) — decided: in scope, full version
|
||||
AdminOnly (Owner + Administrator). Module appears in `/System/capabilities` so the admin menu "Berichten" only shows on hosts with the module.
|
||||
**Decided by Bryan (2026-11-09): RESTful routes without an `/admin` segment.** That an admin may use an endpoint does not require a separate admin route: the same resource is used by everyone, access is controlled by the authorization policy (AdminOnly = Owner + Administrator) and, for public endpoints, by the `[PublicSiteEndpoint]` marker. This supersedes both `/api/v1/admin/contact-messages` and `/api/v1/contact-messages/admin`.
|
||||
- `POST /api/v1/contact-messages` — **public** (submit, § 2.2). `GET /api/v1/contact-messages/token` — **public** (§ 2.1); the `{id}` routes use the constraint `{id:guid}` so `token` never collides.
|
||||
- `GET /api/v1/contact-messages` — AdminOnly: list with paging; filter `?status=new|read|archived|spam` (default excludes `spam`); the response carries the unread count (spam excluded).
|
||||
- `GET /api/v1/contact-messages/{id:guid}` — AdminOnly: detail.
|
||||
- `PATCH /api/v1/contact-messages/{id:guid}` — AdminOnly: status `new`/`read`/`archived`.
|
||||
- `DELETE /api/v1/contact-messages/{id:guid}` — AdminOnly: **hard delete** (no soft delete), for erasure requests.
|
||||
- `POST /api/v1/contact-messages/{id:guid}/resend` — AdminOnly: resend mail; itself rate-limited (policy `RateLimiting:ContactResend`, no mail-bomb button); `mailStatus` and error code visible.
|
||||
- The public client (`cms-client`) only uses the two public routes.
|
||||
- Offerings: categories are CMS data with RESTful CRUD under `/api/v1/offerings/categories` (AdminOnly), see § 7 (not `offerings/admin/categories`, and no longer an appsettings list). Existing `offerings/admin...` routes are out of scope for this feature (see the open item on a later RESTful refactor).
|
||||
- Spam rows: excluded from the unread counter and the default list; separate filter.
|
||||
|
||||
## 7. Offerings change
|
||||
**Decided by Bryan (2026-11-09, supersedes the appsettings list):** categories are **data managed in the CMS**, not settings. They are part of Offerings: a sub-section/dialog inside the Offerings admin screen (not a new page). Bryan starts with the categories **Websites** and **Onderhoud** (he currently offers complete packages and new builds; takeover/"overname" is not decided yet), created by him in the CMS (not seeded in code).
|
||||
|
||||
Model: `OfferingCategory` (`id`, `name`, `sortOrder`), unique name (case-insensitive), nullable `categoryId` on `Offering`. Routes (RESTful, no `/admin`): `GET /api/v1/offerings/categories` (AdminOnly; list), `POST /api/v1/offerings/categories`, `PUT /api/v1/offerings/categories/{id:guid}`, `DELETE /api/v1/offerings/categories/{id:guid}` (all AdminOnly). Deleting a category that is still used by offerings is rejected (`409` ProblemDetails) until those offerings are moved. Offering create/update accept `categoryId` (must exist) instead of free text; renaming a category updates every offering through the relation. Admin read DTOs carry `categoryId` and `category` (name).
|
||||
|
||||
Public `GET /api/v1/offerings` item gains `"category": "Websites"` — the category **name** as string or `null` (shape unchanged for the frontend). `null`/empty → no chip. The public response also carries the additive fields `categoryId` (GUID string or null) and `displayOrder` (int); the SLP site ignores both. Decision (CMS-U0, 2026-11-09): **one URL and one DTO for everybody** (`GET /api/v1/offerings`; the former admin DTO is removed); writes are `POST /api/v1/offerings`, `PUT|DELETE /api/v1/offerings/{id:guid}` and `PUT /api/v1/offerings/order` (`{ "orderedIds": [...] }`), all AdminOnly. The frontend builds chips from distinct non-empty values in order of first appearance, counts itself, and shows chips only when there are **4 or more** packages. Existing fields unchanged (see `aidlc-docs/features/react-frontend/construction/react-frontend-app/functional-design/packages-api-handoff.md`). Array order = display order; exactly one `featured: true`. Independent of the form; can start immediately.
|
||||
|
||||
## 8. OpenAPI sketch (intended shape; the CMS exports the definitive document)
|
||||
```yaml
|
||||
openapi: 3.0.3
|
||||
info: { title: SLP CMS public API, version: 0.2.0-draft }
|
||||
paths:
|
||||
/api/v1/contact-messages/token:
|
||||
get:
|
||||
responses:
|
||||
'200': { description: token, content: { application/json: { schema: { $ref: '#/components/schemas/ContactToken' } } } }
|
||||
'429': { $ref: '#/components/responses/RateLimited' }
|
||||
/api/v1/contact-messages:
|
||||
post:
|
||||
parameters:
|
||||
- { name: Idempotency-Key, in: header, required: true, schema: { type: string, format: uuid } }
|
||||
requestBody:
|
||||
required: true
|
||||
content: { application/json: { schema: { $ref: '#/components/schemas/ContactMessageRequest' } } }
|
||||
responses:
|
||||
'202': { description: received, content: { application/json: { schema: { $ref: '#/components/schemas/Received' } } } }
|
||||
'400': { $ref: '#/components/responses/Validation' }
|
||||
'413': { $ref: '#/components/responses/TooLarge' }
|
||||
'429': { $ref: '#/components/responses/RateLimited' }
|
||||
components:
|
||||
responses:
|
||||
Validation:
|
||||
description: validation failed (also expired/forged token and bad Idempotency-Key)
|
||||
content: { application/problem+json: { schema: { $ref: '#/components/schemas/ValidationProblem' } } }
|
||||
TooLarge:
|
||||
description: body too large
|
||||
content: { application/problem+json: { schema: { $ref: '#/components/schemas/Problem' } } }
|
||||
RateLimited:
|
||||
description: too many requests
|
||||
headers: { Retry-After: { schema: { type: integer }, description: seconds } }
|
||||
content: { application/problem+json: { schema: { $ref: '#/components/schemas/Problem' } } }
|
||||
schemas:
|
||||
Problem:
|
||||
type: object
|
||||
properties: { type: { type: string }, title: { type: string }, status: { type: integer } }
|
||||
ValidationProblem:
|
||||
allOf:
|
||||
- $ref: '#/components/schemas/Problem'
|
||||
- type: object
|
||||
properties:
|
||||
errors:
|
||||
type: object
|
||||
additionalProperties: { type: array, items: { type: string, enum: [required, tooLong, invalid, expired] } }
|
||||
ContactToken:
|
||||
type: object
|
||||
required: [token, minSeconds]
|
||||
properties:
|
||||
token: { type: string }
|
||||
minSeconds: { type: integer }
|
||||
captcha: { type: object, nullable: true, properties: { provider: { type: string }, siteKey: { type: string } } }
|
||||
ContactMessageRequest:
|
||||
type: object
|
||||
required: [name, email, subject, message, hpCheck, token]
|
||||
properties:
|
||||
name: { type: string, minLength: 1, maxLength: 100 }
|
||||
email: { type: string, minLength: 1, maxLength: 254 }
|
||||
subject: { type: string, minLength: 1, maxLength: 100 }
|
||||
message: { type: string, minLength: 1, maxLength: 2000 }
|
||||
hpCheck: { type: string, maxLength: 0 }
|
||||
token: { type: string }
|
||||
captchaToken: { type: string, nullable: true }
|
||||
Received:
|
||||
type: object
|
||||
properties: { status: { type: string, enum: [received] } }
|
||||
```
|
||||
|
||||
## 9. Frontend package expectations (`cms-client`, headless, by subpath)
|
||||
- `cms-client/contact`: `useContactForm`, `contactFormReducer`, `validateContact`, `createContactClient`, types, default Dutch messages.
|
||||
- **Messages**: `messages[field][code]` with Dutch defaults **identical to the ASF texts** ("Vul je naam in.", "De naam is te lang.", "Vul je e-mailadres in.", "Het e-mailadres is te lang.", "Dit e-mailadres is ongeldig.", "Kies een soort shoot." → generic "Kies een onderwerp.", "Schrijf hier je vraag.", "Het bericht is te lang."), plus texts for 429 (shows "probeer het over X minuten" from `Retry-After`), 413, network/5xx/503, expired token. Fully overridable per site.
|
||||
- **Field ids**: derived from `idPrefix` + logical field name; a site can keep its own DOM names, ids and test ids; payload mapping lives in the client, not in the site.
|
||||
- **Idempotency-Key**: one UUID per attempt series; reused on "opnieuw proberen" until success; a new key after success/reset; provided by the hook.
|
||||
- **States**: `editing | sending | sent | failed` pure reducer; `sent` never reverts; edits and second submit while `sending` are ignored; input kept on `failed`. Spam gets the same 202, so there is one success path. The submit button is **not** blocked for `minSeconds`; the server answers early submissions with the normal 202 and stores them as `spam` (never mailed).
|
||||
- **Token**: fetched lazily after hydration on first focus/interaction; on `errors.token = ["expired"]` one fresh token and an automatic repeat, then the error message. No `Date.now` on the client.
|
||||
- **Preselect**: `{ subject, key }` with change counter; unknown value ignored; the site reads the query string.
|
||||
- **Captcha slot**: slot data `{ provider, siteKey, onToken(token), onExpired() }`; the site renders the widget client-only after hydration, reserves a fixed height (no layout shift), puts no captcha HTML in prerendered output, resets the widget when the token expires; with `captcha: null` the slot renders nothing and takes no space.
|
||||
- **Fallback**: on failure the hook returns `{ failed: true }`; the site renders the mailto fallback without the address in static HTML (assembled after hydration).
|
||||
- **Honeypot slot**: field name configurable (`hpCheck` default).
|
||||
- **Boundary**: no imports from the consuming app. Developed first in `slp-software-frontend/src/cms-client/` (decision of the user), then moved to SlpModularCms. `cms-client/offerings` (typed client from OpenAPI) follows later.
|
||||
|
||||
## 10. Open items
|
||||
- [x] **[Bryan, decided 2026-11-09]** Admin view for contact messages is in scope, full version (list with paging and unread count, detail, status new/read/archived, delete, resend mail).
|
||||
- [x] **[Bryan, decided 2026-11-09]** Honeypot/too-fast submissions are stored with `status: spam` (30 days, never mailed).
|
||||
- [x] **[Bryan, decided 2026-11-09]** Captcha provider failure: fail-open; captcha ships disabled.
|
||||
- [x] **[Bryan, decided 2026-11-09, revised]** Categories are data managed in the CMS inside the Offerings admin (sub-section, not a new page), not an appsettings list. Starting categories: Websites and Onderhoud. (The earlier decision "fixed list in appsettings" is superseded.)
|
||||
- [ ] `SLS Software - CMS`: confirm the build plan incl. `Retry-After` in `OnRejected`, own ProblemDetails mapping, DataProtection tokens, idempotency table, retry job, `AvailabilityMiddleware` aligned with the decision "only the CMS/admin is blocked, public content stays available" (public offerings + contact routes reachable, admin routes still gated), capabilities entry.
|
||||
- [ ] `CMS & API`: decide `other` (label per site) vs ASF `overig`; plan the ASF migration to `cms-client` as an own ASF-web feature (not part of this feature; existing ContactForm/reducer tests can serve as acceptance tests).
|
||||
- [ ] Host: `ForwardedHeaders:KnownProxies` per host; reverse-proxy route `/api/v1/` for test and production (nginx for SLP, IIS for ASF production).
|
||||
- [x] **[Bryan, decided 2026-11-09]** Existing routes with an `/admin` segment are refactored to RESTful routes **now, in this feature** (Bryan maintains both websites and prefers doing it now): Offerings (`GET/POST offerings/admin`, `PUT/DELETE offerings/admin/{id}`, `admin/reorder`, `admin/{id}/move-up|down`) in phase 1 together with the admin-frontend call sites and tests, before the category work; `Availability` `POST admin/status` in phase 2 after the merge of the ASF branch (that branch touches Availability and master/slave callers must be checked).
|
||||
- [x] Reviews received 2026-11-09: `SLS Software - CMS`, `CMS & API`, `AndreaSlopFotografie`; folded into v0.2.0 and v0.3.x.
|
||||
|
||||
## 10a. Notes for the CMS builder on the availability gate (from review)
|
||||
- The latest commit on the CMS branch (`701091f`, "Beschikbaarheidspoort blokkeert alleen de API, niet de website en de admin") touches the same middleware: build on it; limiting the gate to admin/CMS routes is a second step, not a rewrite.
|
||||
- Prefer an **explicit allowlist of public routes** (offerings GET, contact token GET, contact POST) over a prefix exception, so a new admin endpoint can never fall under the bypass by accident; add a test proving that every endpoint without `[PublicSiteEndpoint]` (iterating all endpoints, including all admin routes) still returns 503 when the gate is closed. (Replaces the earlier prefix test `/api/v1/admin/*`; the repo has no common admin prefix.)
|
||||
|
||||
## 11. Suggested CMS build order (from the review; build only after Bryan confirms the whole)
|
||||
(a) `category` on Offerings (migration on existing SLP and ASF databases; field in admin forms and tests); (b) `OnRejected` / `Retry-After` / ProblemDetails unit (existing policies, `PipelineTests`); (c) Contact module: storage, token, submit, idempotency, spam checks; (d) mail background service + retry; (e) admin API; (f) admin UI. Build and test per unit.
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
# Services
|
||||
|
||||
## Frontend services
|
||||
### ThemeService (inside ThemeProvider)
|
||||
- Reads/writes mode in localStorage key `slp-software-mode` (guarded try/catch); never writes the variant. Applies `data-variant`/`data-mode`. Migration: ignore the old `slp-software-theme` key.
|
||||
|
||||
### OfferingsService (usePackagesQuery)
|
||||
- `GET /api/v1/offerings` via TanStack Query; later replaced by `cms-client/offerings`.
|
||||
|
||||
### ContactService (cms-client/contact)
|
||||
Orchestration of one submission:
|
||||
1. On first focus (or mount), `getToken()` fetches the server-signed timestamp token and captcha info.
|
||||
2. `useContactForm` validates on blur / submit; honeypot filled → no request, show success (silent drop).
|
||||
3. Submit sends `POST /api/v1/contact-messages` with `Idempotency-Key`.
|
||||
4. `202` → `sent`; `400` token expired → refetch token and retry once; `400` field errors → map to fields; `429` → `failed` with retry-after message; other → `failed` (input kept).
|
||||
5. No PII in logs, Sentry breadcrumbs or analytics events (Sentry `beforeBreadcrumb`/`beforeSend` scrub for the form route).
|
||||
|
||||
### Observability
|
||||
- Existing Sentry and Umami remain. Umami event for form outcome without field data (`contact-sent`, `contact-failed`).
|
||||
|
||||
## Backend services (SlpModularCms, by `SLS Software - CMS`)
|
||||
- **ContactMessageService**: validate → store (status `new`) → send mail best-effort via `IEmailSender` → update `mailStatus`.
|
||||
- **ContactTokenService**: issues and verifies HMAC-signed timestamp tokens (site-bound).
|
||||
- **SpamGuard**: honeypot, minimum elapsed time from the token, optional captcha verification (Friendly Captcha), identical 202 response on spam.
|
||||
- **RetentionJob**: deletes messages older than the configured retention (12 months).
|
||||
- **RateLimiting**: extends `AddCmsRateLimiting` with policy `ContactForm`; needs `ForwardedHeaders:KnownProxies` for the real client IP.
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
# Unit Dependencies
|
||||
|
||||
## Matrix
|
||||
| Unit | Depends on | Blocks |
|
||||
|---|---|---|
|
||||
| U1 theme-foundation | — | U2, U3, U4, U5 |
|
||||
| U2 b-modern-sections | U1 | U3, U4 (container frames) |
|
||||
| U3 packages-block | U1, U2 | U4 (preselect), U5 (shared packages logic) |
|
||||
| U4 contact-form | U1, U2, U3 (preselect context) | U5 (`cms-client` reused by the terminal skin) |
|
||||
| U5 e-timetravel | U1, U3, U4 | — |
|
||||
| X-a category | — | U3 real data (soft) |
|
||||
| X-b gate + rate limit | — | U4 end-to-end test (soft) |
|
||||
| X-c contact module | X-b (marker) | U4 end-to-end test |
|
||||
| X-d mail + retry | X-c, merge of ASF branch | owner notification in production (not frontend) |
|
||||
| X-e admin API | X-c | X-f |
|
||||
| X-f admin UI | X-e, merge of ASF branch | — |
|
||||
|
||||
## Diagram
|
||||
```mermaid
|
||||
graph TD
|
||||
U1[U1 theme-foundation] --> U2[U2 b-modern-sections]
|
||||
U2 --> U3[U3 packages-block]
|
||||
U3 --> U4[U4 contact-form]
|
||||
U4 --> U5[U5 e-timetravel]
|
||||
Xa[X-a category] -.soft.-> U3
|
||||
Xb[X-b gate and rate limit] --> Xc[X-c contact module]
|
||||
Xc -.end to end.-> U4
|
||||
Xc --> Xd[X-d mail and retry]
|
||||
Xc --> Xe[X-e admin API]
|
||||
Xe --> Xf[X-f admin UI]
|
||||
Merge[(merge of ASF branch decided by Bryan)] -.-> Xd
|
||||
Merge -.-> Xf
|
||||
classDef fe fill:#63b3ed,stroke:#2b6cb0,color:#000;
|
||||
classDef cms fill:#9ae6b4,stroke:#2f855a,color:#000;
|
||||
classDef gate fill:#f6e05e,stroke:#c05621,color:#000;
|
||||
class U1,U2,U3,U4,U5 fe;
|
||||
class Xa,Xb,Xc,Xd,Xe,Xf cms;
|
||||
class Merge gate;
|
||||
```
|
||||
Text alternative: frontend units run in sequence U1 to U5; CMS units run in parallel, with the form unit's end-to-end test depending on the contact module and mail and admin UI waiting for the merge of the ASF branch.
|
||||
|
||||
## Integration points and checkpoints
|
||||
- **Contract**: `contact-api-contract.md` v0.3.1 (source of truth, OpenAPI exported by the CMS later).
|
||||
- **Checkpoint 1 (after U3)**: packages with mock data of 3 and 6, swipe row on a phone viewport.
|
||||
- **Checkpoint 2 (after U4)**: form against mock server; contract tests; notify the CMS builder if the contract needs changes.
|
||||
- **Checkpoint 3 (Build and Test)**: end-to-end against a test host once X-b and X-c are deployed there.
|
||||
- **Rollback**: each unit is its own commit; the form is behind `VITE_CONTACT_FORM_ENABLED`; E is a separate lazy chunk.
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
# Requirement-to-Unit Map
|
||||
|
||||
User Stories were skipped (single visitor persona, detailed requirements). Requirements are mapped to units instead.
|
||||
|
||||
| Requirement | Summary | Unit(s) |
|
||||
|---|---|---|
|
||||
| FR-1 | Design B default site | U2 (+U3, U4 parts) |
|
||||
| FR-2 | Variant E full, five eras | U5 |
|
||||
| FR-3 | Theme model variant × mode, accents | U1 |
|
||||
| FR-4 | Mode switch + icon-only variant button | U1 |
|
||||
| FR-5 | System preference, persisted mode, variant not remembered | U1 |
|
||||
| FR-6 | E lazy-loaded | U1 (boundary), U5 (content) |
|
||||
| FR-7 | Any number of packages | U3 |
|
||||
| FR-8 | Chips from 4 packages, category from API | U3, X-a |
|
||||
| FR-9 | Maatwerk banner | U3, U5 |
|
||||
| FR-10 | Mobile swipe row | U3 |
|
||||
| FR-11 | Extra package content out of scope; mock data | U3 (tests) |
|
||||
| FR-12 | Packages styling B and E | U3 (B), U5 (E) |
|
||||
| FR-13 | Form fields, all required, limits | U4 |
|
||||
| FR-14 | Submit to CMS, store, mail, 12 months | U4 (client), X-c, X-d |
|
||||
| FR-14a | Future: message to assignment | none (out of scope; data model leaves room in X-c) |
|
||||
| FR-15 | Form states | U4 |
|
||||
| FR-16 | Spam protection | U4 (client), X-c |
|
||||
| FR-17 | Privacy sentence, per-site config | U4 |
|
||||
| FR-18 | Reusable cms-client package | U4 (first version), moves to SlpModularCms later |
|
||||
| FR-19 | Form skins B and E | U4 (B), U5 (E) |
|
||||
| NFR-1 | WCAG AA, reduced motion | all; verified in U1, U3, U4, U5 |
|
||||
| NFR-2 | Responsive | U2, U3, U5 |
|
||||
| NFR-3 | Performance, fonts, code split | U1, U5 |
|
||||
| NFR-4 | Security baseline | U4 (+ X-b, X-c) |
|
||||
| NFR-5 | Privacy | U4, X-c |
|
||||
| NFR-6 | Testing, PBT partial | all; PBT in U4 |
|
||||
| NFR-7 | Maintainability | U1 |
|
||||
| NFR-8 | Compatibility | all |
|
||||
|
||||
All FR/NFR are assigned. Open external items are tracked in `unit-of-work.md` (X-a..X-f).
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
# Units of Work
|
||||
|
||||
**Code organization**: brownfield monolith SPA (Vite/React/TS) in the workspace root `src/`; no new deployable services. Target layout is described in `components.md`. Application code never goes in `aidlc-docs/`.
|
||||
|
||||
## Frontend units (this repo)
|
||||
|
||||
### U1 — theme-foundation
|
||||
- **Purpose**: replace red/purple with variant (B|E) × mode (light|dark).
|
||||
- **Responsibilities**: `ThemeProvider` (mode from system preference + persisted choice; variant app-state only, always starts in B), tokens as CSS variable sets per `[data-variant][data-mode]`, `ModeToggle`, icon-only `VariantToggle`, `VariantRenderer` (B eager, E lazy placeholder), removal of old themes and storage key migration, self-hosted fonts for B, `usePrefersReducedMotion`/`usePrefersDark`, tests.
|
||||
- **Design stages**: Functional Design (theme state rules). NFR: covered by requirements.
|
||||
- **Requirements**: FR-3, FR-4, FR-5, FR-6 (shell), NFR-1 (focus/aria for toggles), NFR-3 (fonts), NFR-7.
|
||||
|
||||
### U2 — b-modern-sections
|
||||
- **Purpose**: design B default site (light and dark), without packages and form internals.
|
||||
- **Responsibilities**: NavB, HeroB, AboutB (photo, existing WebP variants), ProcessB ("Van idee naar live in drie stappen" progress bar), FooterB, contact block frame (red block, white/dark panel container), section anchors without years in the menu, B accent `#7A1414`, responsive 360px-1440px+, tests.
|
||||
- **Design stages**: none (design exists in the canvas).
|
||||
- **Requirements**: FR-1, NFR-1, NFR-2.
|
||||
|
||||
### U3 — packages-block
|
||||
- **Purpose**: generic packages block for B.
|
||||
- **Responsibilities**: `PackageCardData.category`, `usePackageFilter` (chips from 4+ packages, counts, order of first appearance), `useSwipeRow` (mobile scroll-snap row, ~85% card width, dots, featured first), skeleton for any count, banner "Past er niets bij?", "Kies …" button feeding `ContactPreselectContext`, mock data for 6 packages in tests, tests.
|
||||
- **Design stages**: Functional Design (filter and swipe behaviour).
|
||||
- **Requirements**: FR-7, FR-8, FR-9, FR-10, FR-11, FR-12 (B part), NFR-1, NFR-2.
|
||||
- **External dependency**: X-a (`category` in the API) for real data; works without (no category → no chips).
|
||||
|
||||
### U4 — contact-form
|
||||
- **Purpose**: working contact form in B and the movable headless package.
|
||||
- **Responsibilities**: `src/cms-client/` (`http`, `contact`: reducer, validation, `useContactForm`, `createContactClient`, default messages), import-boundary lint rule, `ContactFormView` (B skin), privacy sentence, honeypot/idempotency/token handling, mailto fallback with feature flag `VITE_CONTACT_FORM_ENABLED`, CSP/connect-src notes, Sentry/Umami scrubbing, PBT for pure functions (partial), tests incl. contract tests against a mock server.
|
||||
- **Design stages**: Functional Design, NFR Requirements, NFR Design, Infrastructure Design (nginx route, CSP, env). Security Baseline enforced.
|
||||
- **Requirements**: FR-13..FR-19, NFR-4, NFR-5, NFR-6.
|
||||
- **External dependencies**: contract v0.3.x; X-b/X-c (rate limit, contact endpoint) for end-to-end; X-d (mail) and X-e (admin) are not needed for the frontend.
|
||||
|
||||
### U5 — e-timetravel
|
||||
- **Purpose**: variant E in full, lazy-loaded.
|
||||
- **Responsibilities**: `LandingE` with eras 2026/2013/2006/1998/1989, year badges, Win98 Werkwijze step cards, packages 2006 style (glossy tabs/cards, star badge, "Maatwerk!" banner), terminal form skin (`ContactFormTerminal`) on `cms-client`, light/dark tokens, EffectsLayer (marquee, scanlines, dither, caret) fully disabled under reduced motion, E fonts only in the E chunk, tests (render per era, reduced motion, variant switch round-trip).
|
||||
- **Design stages**: NFR Requirements and NFR Design (performance with effects, accessibility). No Functional Design (design exists).
|
||||
- **Requirements**: FR-2, FR-12 (E part), FR-19 (E part), NFR-1, NFR-2, NFR-3.
|
||||
|
||||
## External units (CMS builder, SlpModularCms — feature `contact-forms-module`)
|
||||
| Id | Content | Base |
|
||||
|---|---|---|
|
||||
| X-0 | RESTful refactor of the existing Offerings routes (no `/admin` segment) incl. admin-frontend call sites and tests (CMS-U0) | master |
|
||||
| X-a | `category` on Offerings as CMS-managed data (`OfferingCategory` CRUD, FK on Offering) + categories sub-section and dropdown in the Offerings admin (CMS-U1, CMS-U1b) | master |
|
||||
| X-b | `OnRejected` with `Retry-After` + ProblemDetails; `[PublicSiteEndpoint]` marker for the availability gate | master |
|
||||
| X-c | Contact module: token, submit, idempotency, spam, retention fields (mail behind own interface) | master |
|
||||
| X-d | Mail with retry job (new `MailKind`) | after merge of `feature/identity-email-notifications` + rebase |
|
||||
| X-e | Admin API (list/detail/status/delete/resend) | master |
|
||||
| X-f | Admin UI "Berichten" | after merge + rebase |
|
||||
| X-g | RESTful `Availability` status route (PUT instead of `POST admin/status`), callers checked | after merge + rebase |
|
||||
|
||||
Frontend integration with the real API happens in Build and Test once X-b/X-c exist on a test host.
|
||||
Reference in New Issue
Block a user