diff --git a/docs/superpowers/specs/2026-12-02-landing-pages-design.md b/docs/superpowers/specs/2026-12-02-landing-pages-design.md new file mode 100644 index 0000000..af73b95 --- /dev/null +++ b/docs/superpowers/specs/2026-12-02-landing-pages-design.md @@ -0,0 +1,129 @@ +# Landing Pages + +Status: draft for the owner's approval, 2026-12-02. + +## Intent + +Marketing wants public pages, per company, that feed the lead pipeline. Each page is either an event sign-up page or a general enquiry page. We port babyboo's CMS page builder instead of hand-building each page. The INS landing-page proof of concept (`~/Projects/ins-landing-page`, never deployed) is rebuilt as the first page. Its leads were never real, so none are imported. + +Timing: after the WhatsApp inbox and before go-live on 2027-01-15. + +## Goals + +- Staff with `BO_PAGES` build pages for their own company from blocks: hero, rich text, image with text, FAQ and form. They save a page as a draft or publish it. +- A published page is public at `/p//`, rendered on the server so search engines and link previews read it. +- The form block creates real Co-Lite leads through the existing sign-up rules: consent, matching by mobile then email, a new or existing lead, and interests. The lead source is a new value, "Web page", and the capture records the page and the visitor's UTM tags. +- Each company has a logo and one accent colour, used on all its landing pages. + +## Non-Goals + +- No leads without an event (decided 2026-12-02: approach 1 below). General enquiries go to a standing "enquiries" event that the company creates. +- No custom form builder (babyboo's `cms-forms`). The form block always uses Co-Lite's sign-up form. +- No custom domain per company. There is one public hostname with a path per company. +- The QR sign-up and invitation pages (`/r`, `/i`, `/c`) keep their neutral look. Company branding there is a later choice. +- No babyboo product blocks: featured products and collection list. + +## Anti-Goals + +- A landing page must never write leads outside the sign-up rules: no second lead-creation path with weaker matching or no consent. +- A company must never see, edit or show another company's pages, images or events. +- Page HTML must not run scripts on the public page. + +## Constraints + +- **Hosting:** public pages stay in the admin portal for go-live, on their own hostname (for example `go.`). This keeps printed QR links working after a later move to the customer portal. No host-splitting middleware: the existing public-route logic (`isPublicPath`) is extended to `/p`. +- **APIs:** admin screens call `/api/admin/**` in mobile-api. Public reads and submits use `/api/public/**` with the API key and no session. +- **Data:** new tables carry `company_id`. DDL for real environments goes in the OpenSpec change folder, and the local seed in `local/seed/`. +- **Porting rule:** when porting, list babyboo's business rules first and turn them into tests before building the screen. +- **Infrastructure:** Co-Lite has no file service (babyboo's `services-drive`), and adding one is out of scope. + +## Approaches + +### Where a general enquiry goes (decided by the owner) + +1. **A standing "enquiries" event per company (chosen).** The company creates an event such as "INS website enquiries", with a far-off end date and a team. Every form block points at an event, so status, follow-ups, salesperson, the dashboard and the WhatsApp owner all work unchanged. The cost is that enquiries appear as an event in event lists and dashboards. +2. **Leads with no event.** This would move status, salesperson and follow-ups onto the lead, and teach the lead list, dashboard, WhatsApp owner and exports about leads without an event. It is the cleaner model, but it reworks the pipeline weeks before go-live. It can follow after go-live by moving the standing event's captures. + +### The look (decided by the owner) + +1. **Company logo and accent colour (chosen).** These are set once per company and used on all its pages. +2. **The neutral Co-Lite look.** Less work, but every company's pages look the same. + +### Image storage (my call; the owner can override) + +1. **Images in MySQL (chosen).** + - A `page_image` table holds the bytes, at most 2 MB each, in PNG, JPEG or WebP only. + - Images are served publicly by id with long cache headers. + - There is no new infrastructure, and backups already cover the database. + - Its ceiling is a few hundred images. Past that, move to object storage. +2. **Object storage (S3-compatible or MinIO on the cluster).** It scales, but it is new infrastructure, credentials and backups for a few dozen images. +3. **External image URLs only.** No upload: marketing hosts images elsewhere. It is fragile, and staff would need somewhere to host them. + +## Design + +### Model (services-counter, beside events and event leads) + +- **`cms_page`:** + - columns: `id`, `company_id`, `slug`, `title`, `meta_description`, `status` (DRAFT or PUBLISHED), the blocks as JSON, and the audit columns; + - `slug` is unique per company, ignoring case; + - at most 30 blocks per page, stored and returned in order; + - a save replaces the blocks as a whole (babyboo rule). +- **Blocks** (ported from babyboo, minus the product blocks): + - HERO: `imageId`, `heading`, optional `text`, optional `buttonLabel` and `buttonUrl`. + - RICH_TEXT: `html`. + - IMAGE_TEXT: `imageId`, `imagePosition` (LEFT or RIGHT), optional `heading`, `html`, optional button. + - FAQ: optional `heading`, 1 to 30 `question` and `answer` pairs, in plain text. + - FORM: optional `heading`, `eventUuid`. The event must belong to the page's company. + - Field limits and link rules are ported from babyboo's validation. Buttons allow only `https:`, `mailto:`, `tel:` and same-site paths. +- **`page_image`:** `id`, `company_id`, `content_type`, `bytes`, `created`. Images are company-scoped for staff and public by id. +- **Company:** `logo_image_id` and `accent_color` (`#RRGGBB`), edited on the existing Companies screen. +- **Event lead:** a new source value `WEB`, plus a nullable `page_id`, `utm_source`, `utm_medium` and `utm_campaign`. These show on the event lead detail and in the lead export. + +### The form block's submit + +- The public submit takes the company code, the slug and the block position. +- The server finds the published page and its FORM block's event. It then runs the same registration service the QR flow uses, with source `WEB`, no salesperson, the page id and the UTM tags. +- The form works under the same conditions as an event code: the event is enabled, its end date in Malaysia time has not passed, and the company has a privacy notice. When the form cannot work, the page still shows its other blocks, and the form area says sign-up is closed. +- The QR flow's registration abuse limits apply to this submit too. +- **Builder check:** + - The submit reuses `PublicRegistrationService` in mobile-api for validation and normalisation. It also reuses `RegistrationService.register` in services-counter, which already takes a `source`. + - That service marks a registration as attended when it is not an INVITE and arrives during the event. A WEB registration MUST NOT be marked attended. Otherwise every enquiry to a standing event, which is always running, would count as an attendance. + - The notes text "Registered by QR with: …" must say "web page" for WEB registrations. + +### Admin portal + +- A **Pages** entry is added to the sidebar under a new "Website" group, or under Events if the group would hold only one item. This is the builder's call; the sidebar spec decides. +- **List:** title, slug, status and updated time. Plus a page editor ported from babyboo's `PageEditor` and `BlockFields`: + - Tiptap for rich text, with babyboo's extension set minus YouTube and tables, unless the INS page needs them; + - image upload on HERO and IMAGE_TEXT; + - an event picker for FORM, limited to the company's enabled events that have not ended; + - a "View page" link after saving; + - drafts can be previewed by signed-in staff. +- **Tiptap:** a new dependency for the portal (`@tiptap/*`), the same versions as babyboo. +- **Sanitising:** `sanitize-html` sanitises the HTML at render time with an allow-list. This is a second new dependency. Saves also reject `