Skip to content

Site Builder

The Site Builder app is a full website creation platform where users manage projects, design pages in a visual editor, choose from templates, and publish sites to subdomains. It includes AI-assisted content generation with usage tracking.

  • Project-based website management with thumbnail previews
  • Visual page editor at /editor/[projectId]
  • Template gallery with category filtering, search, and live preview
  • AI content generation with text token and image usage tracking
  • Multi-page support within a single project
  • Publish/unpublish to subdomains with forms email configuration
  • Form submission collection for published sites
  • Project CRUD with inline delete on hover
RoutePurpose
/business/apps/sitebuilderProject dashboard with stats and grid of projects
/business/apps/sitebuilder/[projectId]Project detail with pages, publishing, and form submissions
/business/apps/sitebuilder/templatesTemplate gallery with filtering, preview, and use actions
/business/apps/sitebuilder/aiAI generation history with usage stats

The main page shows aggregate stats (total projects, published, live sites) in the header and renders all projects in a responsive grid. Each project card displays a thumbnail (or placeholder), name, last updated date, status badge (draft or published), and an external link icon for published sites. A hover-revealed delete button appears on each card. The “New Project” dialog collects a project name and creates the project via form action, then redirects to the editor.

The [projectId] page is the project management hub. It loads the project with all its pages, the published site (if any), and form submissions for the published site. Actions available:

  • Publish — deploys the site to a subdomain with optional forms email
  • Unpublish — takes the site offline
  • Add page — creates a new page within the project (uses createPageSchema)
  • Delete page — removes a page
  • Update project — renames the project (uses updateProjectSchema)

The templates page provides a browsable gallery with category and search filtering. Users can preview a template (fetching its pages via the preview action) and use a template to create a new project (via the use action), which redirects to the editor.

The AI history page shows usage statistics in three cards (Text Tokens used this month, Images generated this month, Total Generations all time) and a chronological list of past AI generations loaded via the AiHistory component with infinite scroll.

TableDescription
ext_sitebuilder.projectsWebsite projects (name, slug, status, thumbnail_url, user_id)
ext_sitebuilder.pagesPages within a project
ext_sitebuilder.templatesPre-built templates with category and slug
ext_sitebuilder.template_pagesPages belonging to a template
ext_sitebuilder.published_sitesDeployed sites with subdomain mapping
ext_sitebuilder.form_submissionsForm submissions collected from published sites
ext_sitebuilder.ai_generationsLog of AI generation requests and results
  • Project — id, user_id, name, slug, status (draft | published), thumbnail_url, created_at, updated_at
  • Template — id, name, slug, description, category, thumbnail_url
  • TemplatePage — id, template_id, name, slug, content
ComponentLocation
Project dashboard + create dialogsrc/routes/(app)/business/apps/sitebuilder/+page.svelte
Project detail (pages, publish, forms)src/routes/(app)/business/apps/sitebuilder/[projectId]/+page.svelte
TemplateGrid$lib/modules/sitebuilder/templates/index.js
TemplatePreview$lib/modules/sitebuilder/templates/index.js
AiHistory$lib/modules/sitebuilder/ai/index.js

All server-side logic is in $lib/modules/sitebuilder/services/index.js:

  • listProjects(userId) — list all projects
  • getProjectStats(userId) — aggregate stats (total, published, live)
  • createProject(userId, data) — create project (optionally from template)
  • deleteProject(id) — delete a project
  • getProjectWithPages(id) — fetch project with nested pages
  • updateProject(id, data) — rename a project
  • publishSite(projectId, userId, opts) / unpublishSite(projectId) — deployment lifecycle
  • getPublishedSite(projectId) — fetch published site info
  • listFormSubmissions(siteId) — form submission data
  • createPage(projectId, data) / deletePage(pageId) — page CRUD
  • listTemplates(filters) / getTemplatePages(templateId) — template browsing
  • listAiGenerations(userId, pagination) / getUsageStats(userId) — AI history
ActionDescription
createCreate a new project with a name, redirect to editor
deleteDelete a project by ID
ActionDescription
publishPublish site to subdomain with optional forms email
unpublishTake the site offline
addPageAdd a new page to the project
deletePageRemove a page
updateProjectRename the project
ActionDescription
useCreate a project from a template, redirect to editor
previewFetch template pages for the preview modal