Delivered remotely for a business based in Melbourne, Australia. Names withheld by agreement.
Project Overview
Launching a credible web presence remains unexpectedly hard for local trades, clinics, hospitality venues, and solo consultancies. Conventional no-code builders still confront users with hundreds of empty grid containers, typography sliders, and placeholder Latin text. Meanwhile, naive prompt-to-HTML prototypes produce fragile markup that collapses on mobile viewports and cannot be safely edited after initial generation.
We built a production multi-tenant AI website builder anchored on Next.js, Python, and PostgreSQL. Instead of emitting arbitrary HTML strings, the Python synthesis engine translates a brief intake questionnaire into a strongly typed page-section graph paired with curated design tokens. Owners inspect, rewrite, reorder, and re-theme every section inside a browser-based React studio, then publish instantaneously to custom domains served through Next.js edge routing.
Publishing Friction
Early discovery across SMB onboarding workflows revealed four recurring failure modes in automated site builders:
- Uneditable AI output: Generating raw HTML/CSS blobs locks users out of structured visual editing because moving a call-to-action button or swapping a hero layout breaks inline styles.
- Brand inconsistency across pages: Independent prompts for Home, Services, and Contact pages routinely drift in tone, color contrast, and navigation structure.
- Custom domain propagation delays: Requiring manual server blocks or slow static rebuilds stalls launch momentum right when a business owner is ready to go live.
- Mixed draft and live state: Editing a live marketing page directly without atomic snapshot publishing risks exposing half-finished copy to visitors.
Architectural Strategy
Our central architectural choice was decoupling semantic content synthesis from presentational component rendering. The Python backend never touches JSX or CSS; it outputs a validated site manifest describing navigation links, page slugs, section types, copy slots, and palette tokens.
Next.js consumes that manifest and renders production pages from a library of accessible, responsive React components styled with Tailwind CSS variables. Because both the visual editor and the public edge renderer share the exact same component primitives, what a business owner sees inside the Melbourne studio canvas matches the live published site pixel for pixel.
Core Capabilities
- Guided Multi-Page Synthesis: A short intake flow captures business category, service offerings, geographic focus, and tone, producing a coherent multi-page site architecture in one pass.
- Block-Level AI Regeneration: Users can regenerate a single hero headline, pricing tier, or FAQ accordion without disturbing adjacent sections or manual edits.
- Design Token Theme Engine: Global font pairings, spacing scales, and WCAG-checked color palettes update the entire site atomically via CSS custom properties.
- Atomic Draft & Snapshot Publishing: Background edits auto-save into draft revisions while live traffic continues reading the latest immutable published snapshot.
- Zero-Rebuild Custom Domain Routing: Tenants bind apex or subdomain records via guided DNS verification and receive automated TLS termination.
Technical Architecture
The platform splits interactive authoring from heavy model inference and public content delivery. The Next.js frontend communicates with FastAPI endpoints in Python for prompt orchestration, sitemap planning, and image selection, while PostgreSQL serves as the authoritative store for tenant schemas, JSONB page trees, and domain mappings. Redis coordinates async generation jobs and caches domain-to-tenant lookups so public page requests avoid cold database round-trips.
Flow: Next.js Studio Intake → Python FastAPI Orchestrator (Pydantic AST + Design Tokens) → PostgreSQL Draft JSONB Storage → Visual Editor Refinement → Atomic Snapshot Publish → Redis Cache Invalidation → Next.js Middleware Custom Domain Edge Render
Within PostgreSQL, sites are modeled with normalized tenant and domain tables alongside versioned JSONB document payloads for page trees. Separating structural metadata (domains, TLS status, publishing state) from section payloads allows fast routing queries in middleware while preserving full rollback history across published revisions.
Technology Stack
| Category | Technology detail |
|---|---|
| Frontend & Edge Rendering | Next.js App Router with React Server Components and middleware domain routing |
| Visual Editor & UI | React and TypeScript block inspector with Tailwind CSS design tokens |
| AI Generation Service | Python FastAPI service orchestrating structured JSON layout and copy synthesis |
| Primary Database | PostgreSQL storing tenant sites, JSONB component trees, and revision snapshots |
| Caching & Job Queues | Redis for generation job state, rate limiting, and published page invalidation |
| Media Pipeline | Object storage with server-side image resizing and aspect-ratio enforcement |
| Domain & TLS Layer | Automated CNAME verification and on-demand TLS certificate provisioning |
| Schema Validation | Pydantic models in Python mirrored by Zod schemas in TypeScript |
| Observability | Structured trace IDs linking prompt synthesis latency to editor save events |
Engineering Trade-offs & Solutions
| Engineering Challenge | Solution & Trade-off |
|---|---|
| Raw LLM HTML output breaks responsive layouts and complicates editing | Enforced a closed catalog of typed section schemas validated by Pydantic and Zod; trades arbitrary freeform canvas positioning for guaranteed mobile responsiveness and clean editing. |
| Full-site regeneration overwrites user edits on untouched pages | Scoped regeneration endpoints to individual section UUIDs and locked manual overrides in PostgreSQL, adding state-merging logic in exchange for safe iterative AI assistance. |
| Static site rebuilds per tenant do not scale to thousands of custom domains | Adopted Next.js dynamic multi-tenant routing backed by on-demand ISR and Redis tag invalidation, avoiding CI build queues at the cost of careful cache-key isolation. |
| Streaming a full multi-page site over a single HTTP call hits gateway timeouts | Moved initial site compilation to Redis-backed Python worker jobs with Server-Sent Events progress updates to the Next.js studio. |
Security & Reliability
Multi-tenant publishing platforms carry significant cross-tenant and abuse risks, ranging from phishing page generation to host-header spoofing. Incoming requests pass strict host validation against verified domain records in PostgreSQL before any tenant content resolves. Every tenant workspace enforces row-level ownership checks in both FastAPI and Next.js API routes.
To prevent malicious script injection on published custom domains, rich-text fields permit only a constrained subset of inline formatting nodes rather than raw HTML fragments. Uploaded media goes through server-side transcoding to strip EXIF payloads and neutralize polyglot files, while automated content moderation hooks inspect newly generated copy before custom domains activate.
Performance & Scale
Public tenant traffic is decoupled entirely from the AI generation and editor control planes. Published pages render from cached Next.js Server Components using immutable snapshot IDs; when an owner hits Publish, only that tenant's cache tags purge.
During initial onboarding bursts, Python workers stream partial section completions over SSE so users watch their homepage assemble progressively instead of staring at a spinner. Rate limiters in Redis cap expensive LLM regeneration calls per tenant tier without ever throttling public visitors browsing published sites.
Operational Outcomes
Consolidating structured AI synthesis, visual block editing, and edge domain routing into one coherent stack eliminated the typical friction between "generated demo" and "production business site":
- Editable, resilient layouts: Small business owners can adjust text, reorder sections, and swap color themes indefinitely without breaking mobile breakpoints or CSS alignment.
- Instantaneous launch path: Connecting a custom domain and publishing updates requires no static rebuild pipeline or developer intervention.
- Safe iterative experimentation: Immutable revision snapshots in PostgreSQL let non-technical users test seasonal promotions or AI rewrites with confidence that live pages remain intact until published.
- Predictable platform maintainability: Engineering teams add new industry section templates by registering a single React component and Pydantic schema pair, immediately expanding both the visual editor and the AI compiler.