AladiaDocs

Site builder

Workspace website built with blocks (batch L1, backend): sites / site_pages / site_releases, premounted site, drafts with optimistic lock, publish and rollback, Marketplace as a builder page, public release and tenant resolve, shared block format.

Status: branch feat/site-builder-backend (2026-10-20), behind the site-builder flag (off). The Italian page is the full reference; this is a summary. Paths are relative to backend/.

Model

libs/common/src/common/models/microservices/profile/site.model.ts (profile service):

  • sites: one per workspace (owner.id unique). Theme, header, footer, nav, settings, membersLanding (app default or site), draftUpdatedAt (frame lock), changedAt, publishedReleaseId, publishedAt, publishedPaths, seededAt.
  • site_pages: siteId, slug ("" = home, unique per site), title, kind, seo, draft (Puck document), draftUpdatedAt (lock), hiddenFromNav, order; marketplace only: legacy, legacyPublished, legacySource.
  • site_releases: immutable snapshot (theme, frame, nav with paths, settings, brand, pages[] by path, systemPages[]). Publish = new release + pointer; rollback = pointer only.

Page kinds: custom, template:home|about|courses|contacts|events|teachers|pricing|faq, legal:privacy|cookie|terms, marketplace (fixed /marketplace, one per site, editable with blocks, deletable since 27/10/2026, created from the marketplace page template or from a published storefront), system:<name> (app pages, not edited with blocks).

Premounted site

On the first GET /v2/sites/me the site is created idempotently: theme from Branding, Home / About / Courses / Contacts with blocks bound to real data, legal pages from workspace and billing data, system pages, and, once per site (marketplaceSyncedAt), the Marketplace page from the storefront (marketplace_showcases) only if the storefront was published (draft = converted storefront, legacyPublished = published storefront). Without a page there is no Marketplace (decision of 27/10/2026); the page never follows the storefront again and a deleted page does not come back.

Blocks

Shared format in libs/common/src/common/site/site-blocks.ts, validated with zod in site-schema.ts: hero, richText, courseGrid, eventList, contactForm, faq, cta, columns, plus the marketplace blocks marketplaceHero, marketplaceSearch, courseCatalog (grid or list, category/space/type filters, sort, pagination), categorySection, courseCarousel (sources include space, tag, latest), topCourses, newCourses, topTeachers, and testimonials, stats, imageText, courseSpotlight, storefrontCategories. Unknown types are rejected, unknown props dropped, links limited to same-site paths, anchors, mailto:, tel: and http(s); rich text goes through a short tag allow-list. No custom CSS, HTML or scripts.

API

Builder (flag site-builder, permission marketplace.update on the active workspace): GET|PATCH /v2/sites/me, GET|PATCH|DELETE /v2/sites/me/pages/:pageId, POST /v2/sites/me/pages, POST /v2/sites/me/publish, POST /v2/sites/me/rollback, GET /v2/sites/me/releases. Saves with expectedDraftUpdatedAt return 409 site-draft-changed when someone saved in the meantime.

Public (x-aladia-tenant, flags custom-domain and site-builder): GET /v2/public/site/release/:id (current release only, with signed files) and GET /v2/public/site/marketplace (source: release|showcase, or { source: 'none', draft } when the site has no Marketplace online: web-next shows the "Create the Marketplace page" empty state to site managers, the site Home or a 404 to everyone else), GET /v2/public/site/contact-form (the site contact form: name, email, phone, message, privacy; one per workspace, created with the site, submitted through POST /v2/public/forms/:id/submit into Requests, also without forms-multi). Hand-picked courses: POST /v2/courses/search?courseIds=a,b (max 100, same workspace and visibility rules). GET /v2/public/tenants/resolve adds site: { version, releaseId, paths, membersLanding } when the site is published and the flag is on.

web-next routing

proxy.ts rewrites published paths (site.paths from the resolve, never /marketplace) to the internal /sites/<tenant>/<version>/<path> route (ISR per version); a direct /sites/… request is a 404 on every host. System pages get the site header, footer and theme; /marketplace becomes view-only. Draft preview: /site/preview/:pageId (session) and /site/share#t=… (24 h signed link, POST /v2/public/site/preview). Renderer contract: web-next/lib/site/render-contract.ts.

SEO and sharing

  • Page seo: title (Google title as is; empty = "Page — Site"), description (empty = site description), imageFileId (share image), socialTitle/socialDescription (Open Graph/X, empty = Google ones), noindex. defaultPageSeo() (common/site/site-defaults.ts) fills title and description for premounted pages and templates (library templates pass { label, description }).
  • Panel: Pages › "Settings and SEO" (components/site-builder/page-seo.tsx) with counters, Google result preview, share image, social card preview, "Do not index" and soft warnings (title, description, images without alt).
  • Public metadata (lib/site/seo.ts): absolute canonical on release.origin (active custom domain or <slug>.aladia.io), full Open Graph/X with a stable /brand-og/page-<id>.img image, site language on the content; single-language sites, so no hreflang.
  • robots.txt and sitemap.xml per site host (app/robots.txt, app/sitemap.xml): only on a published site host, 404 elsewhere as before. Sitemap = published non-noindex pages + public course and event pages.
  • JSON-LD: Organization/WebSite on the home page, BreadcrumbList, FAQPage, Course (course spotlight), Event (event list blocks); real data only.

Reserved slugs

common/site/site-slugs.ts lists the first segment of every web-next/app route plus infrastructure paths. tests/unit/site-builder.spec.ts fails when a new top-level route is missing from the list.

Migration

scripts/migrations/2026-10-site-builder.js: indexes, the site-builder flag document (off), and the marketplace page converted from each storefront. Idempotent; pages edited in the builder are never touched.

scripts/migrations/2026-10-marketplace-page.js (27/10/2026): sites that already have the storefront marketplace page move to the new model (legacy: false, marketplaceSyncedAt); no release is touched, so the public /marketplace keeps showing what it shows today until the site is published; other sites move on their first opening. PHASE=rollback restores legacy: true on the marked pages.

On this page