Add site builder service to Docker Compose and remove obsolete scripts

- Introduced a new service `igny8_site_builder` in `docker-compose.app.yml` for site building functionality, including environment variables and volume mappings.
- Deleted several outdated scripts: `create_test_users.py`, `test_image_write_access.py`, `update_free_plan.py`, and the database file `db.sqlite3` to clean up the backend.
- Updated Django settings and URL configurations to integrate the new site builder module.
This commit is contained in:
IGNY8 VPS (Salman)
2025-11-17 16:08:51 +00:00
parent e3d4ba2c02
commit 5a36686844
74 changed files with 7217 additions and 374 deletions

24
site-builder/.gitignore vendored Normal file
View File

@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
dist
dist-ssr
*.local
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

View File

@@ -0,0 +1,18 @@
# Site Builder Dev Image (Node 22 to satisfy Vite requirements)
FROM node:22-alpine
WORKDIR /app
# Copy package manifests first for better caching
COPY package*.json ./
RUN npm install
# Copy source (still bind-mounted at runtime, but needed for initial run)
COPY . .
EXPOSE 5175
CMD ["npm", "run", "dev", "--", "--host", "0.0.0.0", "--port", "5175"]

73
site-builder/README.md Normal file
View File

@@ -0,0 +1,73 @@
# React + TypeScript + Vite
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
Currently, two official plugins are available:
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) (or [oxc](https://oxc.rs) when used in [rolldown-vite](https://vite.dev/guide/rolldown)) for Fast Refresh
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
## React Compiler
The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).
## Expanding the ESLint configuration
If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
```js
export default defineConfig([
globalIgnores(['dist']),
{
files: ['**/*.{ts,tsx}'],
extends: [
// Other configs...
// Remove tseslint.configs.recommended and replace with this
tseslint.configs.recommendedTypeChecked,
// Alternatively, use this for stricter rules
tseslint.configs.strictTypeChecked,
// Optionally, add this for stylistic rules
tseslint.configs.stylisticTypeChecked,
// Other configs...
],
languageOptions: {
parserOptions: {
project: ['./tsconfig.node.json', './tsconfig.app.json'],
tsconfigRootDir: import.meta.dirname,
},
// other options...
},
},
])
```
You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
```js
// eslint.config.js
import reactX from 'eslint-plugin-react-x'
import reactDom from 'eslint-plugin-react-dom'
export default defineConfig([
globalIgnores(['dist']),
{
files: ['**/*.{ts,tsx}'],
extends: [
// Other configs...
// Enable lint rules for React
reactX.configs['recommended-typescript'],
// Enable lint rules for React DOM
reactDom.configs.recommended,
],
languageOptions: {
parserOptions: {
project: ['./tsconfig.node.json', './tsconfig.app.json'],
tsconfigRootDir: import.meta.dirname,
},
// other options...
},
},
])
```

View File

@@ -0,0 +1,23 @@
import js from '@eslint/js'
import globals from 'globals'
import reactHooks from 'eslint-plugin-react-hooks'
import reactRefresh from 'eslint-plugin-react-refresh'
import tseslint from 'typescript-eslint'
import { defineConfig, globalIgnores } from 'eslint/config'
export default defineConfig([
globalIgnores(['dist']),
{
files: ['**/*.{ts,tsx}'],
extends: [
js.configs.recommended,
tseslint.configs.recommended,
reactHooks.configs.flat.recommended,
reactRefresh.configs.vite,
],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
},
},
])

13
site-builder/index.html Normal file
View File

@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>site-builder</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>

3894
site-builder/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

36
site-builder/package.json Normal file
View File

@@ -0,0 +1,36 @@
{
"name": "site-builder",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc -b && vite build",
"lint": "eslint .",
"preview": "vite preview"
},
"dependencies": {
"axios": "^1.13.2",
"lucide-react": "^0.554.0",
"react": "^19.2.0",
"react-dom": "^19.2.0",
"react-hook-form": "^7.66.0",
"react-router-dom": "^7.9.6",
"zustand": "^5.0.8"
},
"devDependencies": {
"@eslint/js": "^9.39.1",
"@types/node": "^24.10.0",
"@types/react": "^19.2.2",
"@types/react-dom": "^19.2.2",
"@types/react-router-dom": "^5.3.3",
"@vitejs/plugin-react": "^5.1.0",
"eslint": "^9.39.1",
"eslint-plugin-react-hooks": "^7.0.1",
"eslint-plugin-react-refresh": "^0.4.24",
"globals": "^16.5.0",
"typescript": "~5.9.3",
"typescript-eslint": "^8.46.3",
"vite": "^7.2.2"
}
}

View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

330
site-builder/src/App.css Normal file
View File

@@ -0,0 +1,330 @@
.app-shell {
display: grid;
grid-template-columns: 280px 1fr;
min-height: 100vh;
background: #f5f7fb;
color: #0f172a;
}
.app-sidebar {
border-right: 1px solid rgba(15, 23, 42, 0.08);
padding: 2rem 1.5rem;
display: flex;
flex-direction: column;
gap: 2rem;
background: #ffffff;
}
.app-sidebar .brand span {
font-size: 1.25rem;
font-weight: 700;
display: block;
}
.app-sidebar .brand small {
color: #64748b;
}
.app-sidebar nav {
display: flex;
flex-direction: column;
gap: 0.75rem;
}
.app-sidebar a {
display: flex;
align-items: center;
gap: 0.75rem;
padding: 0.6rem 0.75rem;
border-radius: 10px;
text-decoration: none;
color: inherit;
font-weight: 500;
}
.app-sidebar a.active {
background: #eef2ff;
color: #4338ca;
}
.app-main {
padding: 2rem 3rem;
overflow-y: auto;
}
.wizard-page {
display: flex;
flex-direction: column;
gap: 1.5rem;
}
.wizard-progress {
display: flex;
gap: 1rem;
flex-wrap: wrap;
}
.wizard-progress__dot {
display: flex;
flex-direction: column;
align-items: center;
gap: 0.35rem;
border: none;
background: transparent;
color: #94a3b8;
font-weight: 500;
cursor: pointer;
}
.wizard-progress__dot span {
width: 34px;
height: 34px;
border-radius: 50%;
border: 2px solid currentColor;
display: grid;
place-items: center;
}
.wizard-progress__dot.is-active {
color: #4338ca;
}
.wizard-step {
margin-top: 1rem;
}
.wizard-actions {
display: flex;
justify-content: space-between;
gap: 1rem;
}
.wizard-actions button {
padding: 0.75rem 1.5rem;
border-radius: 12px;
border: 1px solid rgba(67, 56, 202, 0.3);
background: #fff;
cursor: pointer;
}
.wizard-actions button.primary {
background: #4338ca;
color: #fff;
border-color: transparent;
display: inline-flex;
align-items: center;
gap: 0.4rem;
}
.wizard-actions button.ghost,
.ghost {
background: transparent;
border-color: rgba(67, 56, 202, 0.35);
color: #4338ca;
}
.wizard-actions button:disabled {
opacity: 0.5;
cursor: not-allowed;
}
.sb-error {
color: #dc2626;
margin: 0.5rem 0 0;
}
.sb-grid {
display: grid;
gap: 1rem;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}
.sb-field {
display: flex;
flex-direction: column;
gap: 0.4rem;
font-size: 0.95rem;
color: #0f172a;
}
.sb-field input,
.sb-field select,
.sb-field textarea {
border: 1px solid rgba(15, 23, 42, 0.15);
border-radius: 10px;
padding: 0.65rem 0.85rem;
font-size: 0.95rem;
font-family: inherit;
background: #f8fafc;
}
.sb-pill-list {
display: flex;
flex-wrap: wrap;
gap: 0.5rem;
}
.sb-pill {
padding: 0.35rem 0.75rem;
border-radius: 999px;
background: rgba(67, 56, 202, 0.1);
color: #4338ca;
display: inline-flex;
align-items: center;
gap: 0.35rem;
}
.sb-pill button {
border: none;
background: transparent;
color: inherit;
cursor: pointer;
}
.sb-objective-input {
display: flex;
gap: 0.5rem;
}
.sb-objective-input input {
flex: 1;
}
.sb-objective-input button {
border: none;
background: #0f172a;
color: #fff;
border-radius: 10px;
padding: 0.65rem 1rem;
cursor: pointer;
}
.sb-blueprint-meta {
display: flex;
justify-content: space-between;
align-items: center;
}
.status-dot {
display: inline-flex;
align-items: center;
gap: 0.35rem;
text-transform: capitalize;
}
.status-dot::before {
content: '';
width: 10px;
height: 10px;
border-radius: 50%;
background: currentColor;
}
.status-ready {
color: #10b981;
}
.status-generating {
color: #f97316;
}
.status-draft {
color: #94a3b8;
}
.preview-canvas {
background: #fff;
border-radius: 18px;
padding: 1.5rem;
box-shadow: 0 8px 26px rgba(15, 23, 42, 0.08);
}
.preview-nav {
display: flex;
gap: 0.5rem;
flex-wrap: wrap;
margin-bottom: 1rem;
}
.preview-nav button {
border: 1px solid rgba(15, 23, 42, 0.1);
background: #f8fafc;
border-radius: 999px;
padding: 0.35rem 0.85rem;
cursor: pointer;
}
.preview-nav button.is-active {
background: #4338ca;
color: white;
border-color: transparent;
}
.preview-hero {
margin-bottom: 1.25rem;
}
.preview-hero .preview-label {
text-transform: uppercase;
font-size: 0.7rem;
letter-spacing: 0.08em;
color: #94a3b8;
}
.preview-blocks {
display: grid;
gap: 1rem;
}
.preview-block {
border: 1px dashed rgba(67, 56, 202, 0.2);
border-radius: 14px;
padding: 1rem;
background: rgba(67, 56, 202, 0.04);
}
.sb-blueprint-list {
list-style: none;
padding: 0;
margin: 0;
display: flex;
flex-direction: column;
gap: 1rem;
}
.sb-blueprint-list li {
display: flex;
justify-content: space-between;
align-items: center;
padding-bottom: 0.75rem;
border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}
.sb-blueprint-list strong {
display: block;
}
.sb-blueprint-list span {
color: #475569;
font-size: 0.9rem;
}
.sb-loading {
display: flex;
align-items: center;
gap: 0.5rem;
color: #475569;
}
.spin {
animation: spin 1s linear infinite;
}
@keyframes spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}

43
site-builder/src/App.tsx Normal file
View File

@@ -0,0 +1,43 @@
import { NavLink, Route, Routes } from 'react-router-dom';
import { Wand2, LayoutTemplate, PanelsTopLeft } from 'lucide-react';
import { WizardPage } from './pages/wizard/WizardPage';
import { PreviewCanvas } from './pages/preview/PreviewCanvas';
import { SiteDashboard } from './pages/dashboard/SiteDashboard';
import './App.css';
function App() {
return (
<div className="app-shell">
<aside className="app-sidebar">
<div className="brand">
<span>Site Builder</span>
<small>Phase 3 · wizard + preview</small>
</div>
<nav>
<NavLink to="/" end>
<Wand2 size={18} />
Wizard
</NavLink>
<NavLink to="/preview">
<LayoutTemplate size={18} />
Preview
</NavLink>
<NavLink to="/dashboard">
<PanelsTopLeft size={18} />
Blueprint history
</NavLink>
</nav>
</aside>
<main className="app-main">
<Routes>
<Route path="/" element={<WizardPage />} />
<Route path="/preview" element={<PreviewCanvas />} />
<Route path="/dashboard" element={<SiteDashboard />} />
</Routes>
</main>
</div>
);
}
export default App;

View File

@@ -0,0 +1,61 @@
import axios from 'axios';
import type {
BuilderFormData,
PageBlueprint,
SiteBlueprint,
SiteStructure,
} from '../types/siteBuilder';
const API_ROOT = import.meta.env.VITE_API_URL ?? 'http://localhost:8010/api';
const BASE_PATH = `${API_ROOT}/v1/site-builder`;
const client = axios.create({
baseURL: BASE_PATH,
withCredentials: true,
});
export interface CreateBlueprintPayload {
name: string;
description?: string;
site_id: number;
sector_id: number;
hosting_type: BuilderFormData['hostingType'];
config_json: Record<string, unknown>;
}
export interface GenerateStructurePayload {
business_brief: string;
objectives: string[];
style: BuilderFormData['style'];
metadata?: Record<string, unknown>;
}
export const builderApi = {
async listBlueprints(): Promise<SiteBlueprint[]> {
const res = await client.get('/blueprints/');
if (Array.isArray(res.data?.results)) {
return res.data.results as SiteBlueprint[];
}
return Array.isArray(res.data) ? res.data : [];
},
async createBlueprint(payload: CreateBlueprintPayload): Promise<SiteBlueprint> {
const res = await client.post('/blueprints/', payload);
return res.data;
},
async generateStructure(
blueprintId: number,
payload: GenerateStructurePayload,
): Promise<{ task_id?: string; success?: boolean; structure?: SiteStructure }> {
const res = await client.post(`/blueprints/${blueprintId}/generate_structure/`, payload);
return res.data;
},
async listPages(blueprintId: number): Promise<PageBlueprint[]> {
const res = await client.get(`/pages/?site_blueprint=${blueprintId}`);
return Array.isArray(res.data?.results) ? res.data.results : res.data;
},
};

View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="35.93" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 228"><path fill="#00D8FF" d="M210.483 73.824a171.49 171.49 0 0 0-8.24-2.597c.465-1.9.893-3.777 1.273-5.621c6.238-30.281 2.16-54.676-11.769-62.708c-13.355-7.7-35.196.329-57.254 19.526a171.23 171.23 0 0 0-6.375 5.848a155.866 155.866 0 0 0-4.241-3.917C100.759 3.829 77.587-4.822 63.673 3.233C50.33 10.957 46.379 33.89 51.995 62.588a170.974 170.974 0 0 0 1.892 8.48c-3.28.932-6.445 1.924-9.474 2.98C17.309 83.498 0 98.307 0 113.668c0 15.865 18.582 31.778 46.812 41.427a145.52 145.52 0 0 0 6.921 2.165a167.467 167.467 0 0 0-2.01 9.138c-5.354 28.2-1.173 50.591 12.134 58.266c13.744 7.926 36.812-.22 59.273-19.855a145.567 145.567 0 0 0 5.342-4.923a168.064 168.064 0 0 0 6.92 6.314c21.758 18.722 43.246 26.282 56.54 18.586c13.731-7.949 18.194-32.003 12.4-61.268a145.016 145.016 0 0 0-1.535-6.842c1.62-.48 3.21-.974 4.76-1.488c29.348-9.723 48.443-25.443 48.443-41.52c0-15.417-17.868-30.326-45.517-39.844Zm-6.365 70.984c-1.4.463-2.836.91-4.3 1.345c-3.24-10.257-7.612-21.163-12.963-32.432c5.106-11 9.31-21.767 12.459-31.957c2.619.758 5.16 1.557 7.61 2.4c23.69 8.156 38.14 20.213 38.14 29.504c0 9.896-15.606 22.743-40.946 31.14Zm-10.514 20.834c2.562 12.94 2.927 24.64 1.23 33.787c-1.524 8.219-4.59 13.698-8.382 15.893c-8.067 4.67-25.32-1.4-43.927-17.412a156.726 156.726 0 0 1-6.437-5.87c7.214-7.889 14.423-17.06 21.459-27.246c12.376-1.098 24.068-2.894 34.671-5.345a134.17 134.17 0 0 1 1.386 6.193ZM87.276 214.515c-7.882 2.783-14.16 2.863-17.955.675c-8.075-4.657-11.432-22.636-6.853-46.752a156.923 156.923 0 0 1 1.869-8.499c10.486 2.32 22.093 3.988 34.498 4.994c7.084 9.967 14.501 19.128 21.976 27.15a134.668 134.668 0 0 1-4.877 4.492c-9.933 8.682-19.886 14.842-28.658 17.94ZM50.35 144.747c-12.483-4.267-22.792-9.812-29.858-15.863c-6.35-5.437-9.555-10.836-9.555-15.216c0-9.322 13.897-21.212 37.076-29.293c2.813-.98 5.757-1.905 8.812-2.773c3.204 10.42 7.406 21.315 12.477 32.332c-5.137 11.18-9.399 22.249-12.634 32.792a134.718 134.718 0 0 1-6.318-1.979Zm12.378-84.26c-4.811-24.587-1.616-43.134 6.425-47.789c8.564-4.958 27.502 2.111 47.463 19.835a144.318 144.318 0 0 1 3.841 3.545c-7.438 7.987-14.787 17.08-21.808 26.988c-12.04 1.116-23.565 2.908-34.161 5.309a160.342 160.342 0 0 1-1.76-7.887Zm110.427 27.268a347.8 347.8 0 0 0-7.785-12.803c8.168 1.033 15.994 2.404 23.343 4.08c-2.206 7.072-4.956 14.465-8.193 22.045a381.151 381.151 0 0 0-7.365-13.322Zm-45.032-43.861c5.044 5.465 10.096 11.566 15.065 18.186a322.04 322.04 0 0 0-30.257-.006c4.974-6.559 10.069-12.652 15.192-18.18ZM82.802 87.83a323.167 323.167 0 0 0-7.227 13.238c-3.184-7.553-5.909-14.98-8.134-22.152c7.304-1.634 15.093-2.97 23.209-3.984a321.524 321.524 0 0 0-7.848 12.897Zm8.081 65.352c-8.385-.936-16.291-2.203-23.593-3.793c2.26-7.3 5.045-14.885 8.298-22.6a321.187 321.187 0 0 0 7.257 13.246c2.594 4.48 5.28 8.868 8.038 13.147Zm37.542 31.03c-5.184-5.592-10.354-11.779-15.403-18.433c4.902.192 9.899.29 14.978.29c5.218 0 10.376-.117 15.453-.343c-4.985 6.774-10.018 12.97-15.028 18.486Zm52.198-57.817c3.422 7.8 6.306 15.345 8.596 22.52c-7.422 1.694-15.436 3.058-23.88 4.071a382.417 382.417 0 0 0 7.859-13.026a347.403 347.403 0 0 0 7.425-13.565Zm-16.898 8.101a358.557 358.557 0 0 1-12.281 19.815a329.4 329.4 0 0 1-23.444.823c-7.967 0-15.716-.248-23.178-.732a310.202 310.202 0 0 1-12.513-19.846h.001a307.41 307.41 0 0 1-10.923-20.627a310.278 310.278 0 0 1 10.89-20.637l-.001.001a307.318 307.318 0 0 1 12.413-19.761c7.613-.576 15.42-.876 23.31-.876H128c7.926 0 15.743.303 23.354.883a329.357 329.357 0 0 1 12.335 19.695a358.489 358.489 0 0 1 11.036 20.54a329.472 329.472 0 0 1-11 20.722Zm22.56-122.124c8.572 4.944 11.906 24.881 6.52 51.026c-.344 1.668-.73 3.367-1.15 5.09c-10.622-2.452-22.155-4.275-34.23-5.408c-7.034-10.017-14.323-19.124-21.64-27.008a160.789 160.789 0 0 1 5.888-5.4c18.9-16.447 36.564-22.941 44.612-18.3ZM128 90.808c12.625 0 22.86 10.235 22.86 22.86s-10.235 22.86-22.86 22.86s-22.86-10.235-22.86-22.86s10.235-22.86 22.86-22.86Z"></path></svg>

After

Width:  |  Height:  |  Size: 4.0 KiB

View File

@@ -0,0 +1,45 @@
.sb-card {
background: #ffffff;
border-radius: 16px;
border: 1px solid rgba(15, 23, 42, 0.08);
padding: 1.5rem;
box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05);
display: flex;
flex-direction: column;
gap: 1rem;
}
.sb-card__header {
display: flex;
flex-direction: column;
gap: 0.35rem;
}
.sb-card__title {
font-size: 1.1rem;
font-weight: 600;
color: #0f172a;
margin: 0;
}
.sb-card__description {
color: #475569;
margin: 0;
font-size: 0.95rem;
}
.sb-card__body {
display: flex;
flex-direction: column;
gap: 1rem;
}
.sb-card__footer {
border-top: 1px solid rgba(15, 23, 42, 0.06);
padding-top: 1rem;
display: flex;
justify-content: flex-end;
gap: 0.75rem;
}

View File

@@ -0,0 +1,25 @@
import type { PropsWithChildren, ReactNode } from 'react';
import './Card.css';
interface CardProps extends PropsWithChildren {
title?: ReactNode;
description?: ReactNode;
footer?: ReactNode;
}
export function Card({ title, description, footer, children }: CardProps) {
return (
<section className="sb-card">
{(title || description) && (
<header className="sb-card__header">
{title && <h2 className="sb-card__title">{title}</h2>}
{description && <p className="sb-card__description">{description}</p>}
</header>
)}
<div className="sb-card__body">{children}</div>
{footer && <footer className="sb-card__footer">{footer}</footer>}
</section>
);
}

View File

@@ -0,0 +1,28 @@
import './HeroBlock.css';
interface HeroBlockProps {
heading: string;
subheading?: string;
ctaLabel?: string;
secondaryCta?: string;
badge?: string;
}
export function HeroBlock({ heading, subheading, ctaLabel, secondaryCta, badge }: HeroBlockProps) {
return (
<div className="sb-hero-block">
{badge && <span className="sb-hero-block__badge">{badge}</span>}
<h1>{heading}</h1>
{subheading && <p>{subheading}</p>}
<div className="sb-hero-block__ctas">
{ctaLabel && <button>{ctaLabel}</button>}
{secondaryCta && (
<button className="ghost" type="button">
{secondaryCta}
</button>
)}
</div>
</div>
);
}

View File

@@ -0,0 +1,13 @@
.sb-page-canvas {
border-radius: 24px;
padding: 2.5rem;
box-shadow: 0 30px 80px rgba(15, 23, 42, 0.12);
border: 1px solid rgba(15, 23, 42, 0.08);
}
.sb-page-canvas__body {
display: flex;
flex-direction: column;
gap: 2.25rem;
}

View File

@@ -0,0 +1,12 @@
import type { PropsWithChildren } from 'react';
import { palette } from '../theme';
import './PageCanvas.css';
export function PageCanvas({ children }: PropsWithChildren) {
return (
<article className="sb-page-canvas" style={{ background: palette.background }}>
<div className="sb-page-canvas__body">{children}</div>
</article>
);
}

View File

@@ -0,0 +1,39 @@
.sb-section {
border-radius: 20px;
padding: 1.75rem;
border: 1px solid rgba(15, 23, 42, 0.07);
background: #ffffff;
display: flex;
flex-direction: column;
gap: 1.25rem;
}
.sb-section--soft {
background: #f4f6ff;
}
.sb-section__header h3 {
margin: 0.15rem 0;
font-size: 1.8rem;
font-weight: 700;
}
.sb-section__subtitle {
margin: 0;
color: #64748b;
}
.sb-section__overline {
font-size: 0.75rem;
letter-spacing: 0.08em;
text-transform: uppercase;
color: #6366f1;
margin: 0;
}
.sb-section__content {
display: flex;
flex-direction: column;
gap: 1rem;
}

View File

@@ -0,0 +1,25 @@
import type { PropsWithChildren, ReactNode } from 'react';
import './Section.css';
interface SectionProps extends PropsWithChildren {
overline?: string;
title?: ReactNode;
subtitle?: ReactNode;
background?: 'surface' | 'soft';
}
export function Section({ overline, title, subtitle, background = 'surface', children }: SectionProps) {
return (
<section className={`sb-section sb-section--${background}`}>
{(overline || title || subtitle) && (
<header className="sb-section__header">
{overline && <p className="sb-section__overline">{overline}</p>}
{title && <h3>{title}</h3>}
{subtitle && <p className="sb-section__subtitle">{subtitle}</p>}
</header>
)}
<div className="sb-section__content">{children}</div>
</section>
);
}

View File

@@ -0,0 +1,29 @@
export const palette = {
background: '#f8fbff',
surface: '#ffffff',
accent: '#6366f1',
accentSoft: '#eef2ff',
text: '#0f172a',
textMuted: '#64748b',
border: 'rgba(15, 23, 42, 0.08)',
};
export const typography = {
title: {
fontSize: '2.5rem',
fontWeight: 700,
lineHeight: 1.1,
},
subtitle: {
fontSize: '1.15rem',
color: palette.textMuted,
lineHeight: 1.5,
},
label: {
fontSize: '0.75rem',
textTransform: 'uppercase',
letterSpacing: '0.08em',
color: palette.accent,
},
};

View File

@@ -0,0 +1,28 @@
:root {
font-family: 'Inter', 'Inter var', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
color: #0f172a;
background-color: #f5f7fb;
font-synthesis: none;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
*,
*::before,
*::after {
box-sizing: border-box;
}
body {
margin: 0;
background: #f5f7fb;
}
button {
font-family: inherit;
}
a {
color: inherit;
}

13
site-builder/src/main.tsx Normal file
View File

@@ -0,0 +1,13 @@
import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';
import { BrowserRouter } from 'react-router-dom';
import './index.css';
import App from './App.tsx';
createRoot(document.getElementById('root')!).render(
<StrictMode>
<BrowserRouter>
<App />
</BrowserRouter>
</StrictMode>,
);

View File

@@ -0,0 +1,56 @@
import { useEffect, useState } from 'react';
import { Loader2 } from 'lucide-react';
import { builderApi } from '../../api/builder.api';
import type { SiteBlueprint } from '../../types/siteBuilder';
import { Card } from '../../components/common/Card';
export function SiteDashboard() {
const [blueprints, setBlueprints] = useState<SiteBlueprint[]>([]);
const [loading, setLoading] = useState(false);
const [error, setError] = useState<string | undefined>();
useEffect(() => {
const fetchData = async () => {
setLoading(true);
try {
const data = await builderApi.listBlueprints();
setBlueprints(data);
} catch (err) {
setError(err instanceof Error ? err.message : 'Unable to load blueprints');
} finally {
setLoading(false);
}
};
fetchData();
}, []);
return (
<Card title="Blueprint history" description="Every generated structure is stored and can be reopened.">
{loading && (
<div className="sb-loading">
<Loader2 className="spin" size={18} /> Loading blueprints
</div>
)}
{error && <p className="sb-error">{error}</p>}
{!loading && !blueprints.length && (
<p className="sb-muted">You havent generated any sites yet. Launch the wizard to create your first one.</p>
)}
<ul className="sb-blueprint-list">
{blueprints.map((bp) => (
<li key={bp.id}>
<div>
<strong>{bp.name}</strong>
<span>{bp.description}</span>
</div>
<span className={`status-dot status-${bp.status}`}>{bp.status}</span>
</li>
))}
</ul>
</Card>
);
}

View File

@@ -0,0 +1,291 @@
import { useMemo } from 'react';
import {
FeatureGridBlock,
HeroBlock,
MarketingTemplate,
StatsPanel,
type FeatureGridBlockProps,
type StatItem,
} from '@shared';
import { useSiteDefinitionStore } from '../../state/siteDefinitionStore';
import type { PageBlock, PageBlueprint, SiteStructure } from '../../types/siteBuilder';
type StructuredContent = Record<string, unknown> & {
items?: unknown[];
eyebrow?: string;
ctaLabel?: string;
supportingCopy?: string;
columns?: number;
};
export function PreviewCanvas() {
const { structure, pages, selectedSlug, selectPage } = useSiteDefinitionStore();
const page = useMemo(() => {
if (structure?.pages?.length) {
return structure.pages.find((p) => p.slug === selectedSlug) ?? structure.pages[0];
}
return pages.find((p) => p.slug === selectedSlug) ?? pages[0];
}, [structure, pages, selectedSlug]);
if (!structure && !pages.length) {
return (
<div className="preview-placeholder">
<p>Generate a blueprint to see live previews of every page.</p>
</div>
);
}
const navItems = structure?.site?.primary_navigation ?? pages.map((p) => p.slug);
const blocks = getBlocks(page);
const heroBlock = blocks.find((block) => normalizeType(block.type) === 'hero');
const contentBlocks = heroBlock ? blocks.filter((block) => block !== heroBlock) : blocks;
const heroSection =
heroBlock || page
? renderBlock(heroBlock ?? buildFallbackHero(page, structure))
: null;
const sectionNodes =
contentBlocks.length > 0
? contentBlocks.map((block, index) => <div key={`${block.type}-${index}`}>{renderBlock(block)}</div>)
: buildFallbackSections(page);
const sidebar = (
<div className="preview-sidebar">
<p className="preview-label">Page objective</p>
<h4>{page?.objective ?? 'Launch a high-converting page'}</h4>
<ul className="preview-sidebar__list">
{buildSidebarInsights(page, structure).map((insight) => (
<li key={insight.label}>
<span>{insight.label}</span>
<strong>{insight.value}</strong>
</li>
))}
</ul>
</div>
);
return (
<div className="preview-canvas">
<div className="preview-nav">
{navItems?.map((slug) => (
<button
key={slug}
type="button"
onClick={() => selectPage(slug)}
className={slug === (page?.slug ?? '') ? 'is-active' : ''}
>
{slug.replace('-', ' ')}
</button>
))}
</div>
<MarketingTemplate hero={heroSection} sections={sectionNodes} sidebar={sidebar} />
</div>
);
}
function getBlocks(
page: (SiteStructure['pages'][number] & { blocks_json?: PageBlock[] }) | PageBlueprint | undefined,
) {
if (!page) return [];
const fromStructure = (page as { blocks?: PageBlock[] }).blocks;
if (Array.isArray(fromStructure)) return fromStructure;
const fromBlueprint = (page as PageBlueprint).blocks_json;
return Array.isArray(fromBlueprint) ? fromBlueprint : [];
}
function renderBlock(block?: PageBlock) {
if (!block) return null;
const type = normalizeType(block.type);
const structuredContent = extractStructuredContent(block);
const listContent = extractListContent(block, structuredContent);
if (type === 'hero') {
return (
<HeroBlock
eyebrow={structuredContent.eyebrow as string | undefined}
title={block.heading ?? 'Untitled hero'}
subtitle={block.subheading ?? (structuredContent.supportingCopy as string | undefined)}
ctaLabel={(structuredContent.ctaLabel as string | undefined) ?? undefined}
supportingContent={
listContent.length > 0 ? (
<ul>
{listContent.map((item) => (
<li key={String(item)}>{String(item)}</li>
))}
</ul>
) : undefined
}
/>
);
}
if (type === 'feature-grid' || type === 'features' || type === 'value-props') {
const features = toFeatureList(listContent, structuredContent.items);
const columns = normalizeColumns(structuredContent.columns, features.length);
return <FeatureGridBlock heading={block.heading} features={features} columns={columns} />;
}
if (type === 'stats' || type === 'metrics') {
const stats = toStatItems(listContent, structuredContent.items, block);
if (!stats.length) return defaultBlock(block);
return <StatsPanel heading={block.heading} stats={stats} />;
}
return defaultBlock(block);
}
function defaultBlock(block: PageBlock) {
return (
<div className="preview-block preview-block--legacy">
{block.heading && <h4>{block.heading}</h4>}
{block.subheading && <p>{block.subheading}</p>}
{Array.isArray(block.content) && (
<ul>
{block.content.map((item) => (
<li key={item}>{item}</li>
))}
</ul>
)}
</div>
);
}
function normalizeType(type?: string) {
return (type ?? '').toLowerCase();
}
function extractStructuredContent(block: PageBlock): StructuredContent {
if (Array.isArray(block.content)) {
return {};
}
return (block.content ?? {}) as StructuredContent;
}
function extractListContent(block: PageBlock, structuredContent: StructuredContent): unknown[] {
if (Array.isArray(block.content)) {
return block.content;
}
if (Array.isArray(structuredContent.items)) {
return structuredContent.items;
}
return [];
}
function toFeatureList(listItems: unknown[], structuredItems?: unknown[]): FeatureGridBlockProps['features'] {
const source = structuredItems && Array.isArray(structuredItems) && structuredItems.length > 0 ? structuredItems : listItems;
return source.map((item) => {
if (typeof item === 'string') {
return { title: item };
}
if (typeof item === 'object' && item) {
const record = item as Record<string, unknown>;
return {
title: String(record.title ?? record.heading ?? 'Feature'),
description: record.description ? String(record.description) : undefined,
icon: record.icon ? String(record.icon) : undefined,
};
}
return { title: String(item) };
});
}
function toStatItems(
listItems: unknown[],
structuredItems: unknown[] | undefined,
block: PageBlock,
): StatItem[] {
const source = structuredItems && Array.isArray(structuredItems) && structuredItems.length > 0 ? structuredItems : listItems;
return source
.map((item, index) => {
if (typeof item === 'string') {
return {
label: block.heading ?? `Metric ${index + 1}`,
value: item,
};
}
if (typeof item === 'object' && item) {
const record = item as Record<string, unknown>;
const label = record.label ?? record.title ?? `Metric ${index + 1}`;
const value = record.value ?? record.metric ?? record.score;
if (!value) return null;
return {
label: String(label),
value: String(value),
description: record.description ? String(record.description) : undefined,
};
}
return null;
})
.filter((stat): stat is StatItem => Boolean(stat));
}
function normalizeColumns(
candidate: StructuredContent['columns'],
featureCount: number,
): FeatureGridBlockProps['columns'] {
const inferred = typeof candidate === 'number' ? candidate : featureCount >= 4 ? 4 : featureCount === 2 ? 2 : 3;
if (inferred <= 2) return 2;
if (inferred >= 4) return 4;
return 3;
}
function buildFallbackHero(
page: SiteStructure['pages'][number] | PageBlueprint | undefined,
structure: SiteStructure | undefined,
): PageBlock {
return {
type: 'hero',
heading: page?.title ?? 'Site Builder preview',
subheading: structure?.site?.hero_message ?? 'Preview updates as the AI hydrates your blueprint.',
content: Array.isArray(structure?.site?.secondary_navigation) ? structure?.site?.secondary_navigation : [],
};
}
function buildFallbackSections(page: SiteStructure['pages'][number] | PageBlueprint | undefined) {
return [
<FeatureGridBlock
key="fallback-features"
heading="Generated sections"
features={[
{ title: 'AI messaging kit', description: 'Structured copy generated for each funnel stage.' },
{ title: 'Audience resonance', description: 'Language tuned to your target segment.' },
{ title: 'Conversion spine', description: 'CTA hierarchy anchored to your objectives.' },
]}
/>,
<StatsPanel
key="fallback-stats"
heading="Blueprint signals"
stats={[
{ label: 'Page type', value: page?.type ?? 'Landing' },
{ label: 'Status', value: page?.status ?? 'Draft' },
{ label: 'Blocks', value: '0' },
]}
/>,
];
}
function buildSidebarInsights(
page: SiteStructure['pages'][number] | PageBlueprint | undefined,
structure: SiteStructure | undefined,
) {
return [
{
label: 'Primary CTA',
value: page?.primary_cta ?? 'Book a demo',
},
{
label: 'Tone',
value: structure?.site?.tone ?? 'Confident & clear',
},
{
label: 'Status',
value: page?.status ?? 'Draft',
},
];
}

View File

@@ -0,0 +1,119 @@
import { useMemo } from 'react';
import { Loader2, PlayCircle, RefreshCw } from 'lucide-react';
import { useBuilderStore } from '../../state/builderStore';
import { useSiteDefinitionStore } from '../../state/siteDefinitionStore';
import { BusinessDetailsStep } from './steps/BusinessDetailsStep';
import { BriefStep } from './steps/BriefStep';
import { ObjectivesStep } from './steps/ObjectivesStep';
import { StyleStep } from './steps/StyleStep';
import { Card } from '../../components/common/Card';
const stepTitles = ['Business', 'Brief', 'Objectives', 'Style'];
export function WizardPage() {
const {
form,
currentStep,
setField,
updateStyle,
addObjective,
removeObjective,
nextStep,
previousStep,
setStep,
submitWizard,
isSubmitting,
error,
activeBlueprint,
refreshPages,
} = useBuilderStore();
const { structure } = useSiteDefinitionStore();
const stepComponents = useMemo(
() => [
<BusinessDetailsStep key="business" data={form} onChange={setField} />,
<BriefStep key="brief" data={form} onChange={setField} />,
<ObjectivesStep key="objectives" data={form} addObjective={addObjective} removeObjective={removeObjective} />,
<StyleStep key="style" style={form.style} onChange={updateStyle} />,
],
[form, setField, addObjective, removeObjective, updateStyle],
);
return (
<div className="wizard-page">
<Card
title="Site builder wizard"
description="Capture your strategy in four lightweight steps. When you hit “Generate structure” well call the Site Builder AI and hydrate the preview canvas."
>
<div className="wizard-progress">
{stepTitles.map((title, idx) => (
<button
key={title}
type="button"
className={`wizard-progress__dot ${idx === currentStep ? 'is-active' : ''}`}
onClick={() => setStep(idx)}
>
<span>{idx + 1}</span>
<small>{title}</small>
</button>
))}
</div>
<div className="wizard-step">{stepComponents[currentStep]}</div>
<div className="wizard-actions">
<button type="button" onClick={previousStep} disabled={currentStep === 0 || isSubmitting}>
Back
</button>
{currentStep < stepComponents.length - 1 ? (
<button type="button" className="primary" onClick={nextStep}>
Next
</button>
) : (
<button type="button" className="primary" onClick={submitWizard} disabled={isSubmitting}>
{isSubmitting ? (
<>
<Loader2 className="spin" size={18} />
Generating
</>
) : (
<>
<PlayCircle size={18} />
Generate structure
</>
)}
</button>
)}
</div>
{error && <p className="sb-error">{error}</p>}
</Card>
{activeBlueprint && (
<Card
title="Latest blueprint"
description="Refresh the preview to fetch the latest AI output."
footer={
<button type="button" className="ghost" onClick={() => refreshPages(activeBlueprint.id)} disabled={isSubmitting}>
<RefreshCw size={16} />
Sync pages
</button>
}
>
<div className="sb-blueprint-meta">
<div>
<strong>Status</strong>
<span className={`status-dot status-${activeBlueprint.status}`}>{activeBlueprint.status}</span>
</div>
<div>
<strong>Structure</strong>
<span>{structure?.pages?.length ?? 0} pages</span>
</div>
</div>
</Card>
)}
</div>
);
}

View File

@@ -0,0 +1,28 @@
import type { BuilderFormData } from '../../../types/siteBuilder';
import { Card } from '../../../components/common/Card';
interface Props {
data: BuilderFormData;
onChange: <K extends keyof BuilderFormData>(key: K, value: BuilderFormData[K]) => void;
}
export function BriefStep({ data, onChange }: Props) {
return (
<Card
title="Business brief"
description="Describe the brand, what it sells, and what makes it unique. The more context we have, the more accurate the structure."
>
<label className="sb-field">
<span>Business brief</span>
<textarea
rows={8}
value={data.businessBrief}
placeholder="Acme Robotics builds autonomous fulfillment robots that reduce warehouse picking time by 60%..."
onChange={(event) => onChange('businessBrief', event.target.value)}
/>
</label>
</Card>
);
}

View File

@@ -0,0 +1,94 @@
import type { BuilderFormData } from '../../../types/siteBuilder';
import { Card } from '../../../components/common/Card';
interface Props {
data: BuilderFormData;
onChange: <K extends keyof BuilderFormData>(key: K, value: BuilderFormData[K]) => void;
}
export function BusinessDetailsStep({ data, onChange }: Props) {
return (
<Card
title="Business context"
description="These details help the AI understand what kind of site we are building."
>
<div className="sb-grid">
<label className="sb-field">
<span>Site ID</span>
<input
type="number"
value={data.siteId ?? ''}
placeholder="123"
onChange={(event) => onChange('siteId', Number(event.target.value) || null)}
/>
</label>
<label className="sb-field">
<span>Sector ID</span>
<input
type="number"
value={data.sectorId ?? ''}
placeholder="456"
onChange={(event) => onChange('sectorId', Number(event.target.value) || null)}
/>
</label>
</div>
<label className="sb-field">
<span>Site name</span>
<input
type="text"
value={data.siteName}
placeholder="Acme Robotics"
onChange={(event) => onChange('siteName', event.target.value)}
/>
</label>
<div className="sb-grid">
<label className="sb-field">
<span>Business type</span>
<input
type="text"
value={data.businessType}
placeholder="B2B SaaS platform"
onChange={(event) => onChange('businessType', event.target.value)}
/>
</label>
<label className="sb-field">
<span>Industry</span>
<input
type="text"
value={data.industry}
placeholder="Supply chain automation"
onChange={(event) => onChange('industry', event.target.value)}
/>
</label>
</div>
<label className="sb-field">
<span>Target audience</span>
<input
type="text"
value={data.targetAudience}
placeholder="Operations leaders at fast-scaling eCommerce brands"
onChange={(event) => onChange('targetAudience', event.target.value)}
/>
</label>
<label className="sb-field">
<span>Hosting preference</span>
<select
value={data.hostingType}
onChange={(event) => onChange('hostingType', event.target.value as BuilderFormData['hostingType'])}
>
<option value="igny8_sites">IGNY8 Sites</option>
<option value="wordpress">WordPress</option>
<option value="shopify">Shopify</option>
<option value="multi">Multiple destinations</option>
</select>
</label>
</Card>
);
}

View File

@@ -0,0 +1,52 @@
import { useState } from 'react';
import type { BuilderFormData } from '../../../types/siteBuilder';
import { Card } from '../../../components/common/Card';
interface Props {
data: BuilderFormData;
addObjective: (value: string) => void;
removeObjective: (index: number) => void;
}
export function ObjectivesStep({ data, addObjective, removeObjective }: Props) {
const [value, setValue] = useState('');
const handleAdd = () => {
const trimmed = value.trim();
if (!trimmed) return;
addObjective(trimmed);
setValue('');
};
return (
<Card
title="Success metrics & flows"
description="List the outcomes the site must accomplish. These become top-level navigation items and hero CTAs."
>
<div className="sb-pill-list">
{data.objectives.map((objective, idx) => (
<span className="sb-pill" key={`${objective}-${idx}`}>
{objective}
<button type="button" onClick={() => removeObjective(idx)} aria-label="Remove objective">
×
</button>
</span>
))}
</div>
<div className="sb-objective-input">
<input
type="text"
value={value}
placeholder="Offer product tour, capture demo requests, educate on ROI…"
onChange={(event) => setValue(event.target.value)}
/>
<button type="button" onClick={handleAdd}>
Add objective
</button>
</div>
</Card>
);
}

View File

@@ -0,0 +1,74 @@
import type { StylePreferences } from '../../../types/siteBuilder';
import { Card } from '../../../components/common/Card';
interface Props {
style: StylePreferences;
onChange: (partial: Partial<StylePreferences>) => void;
}
const palettes = [
'Minimal monochrome with bright accent',
'Rich jewel tones with high contrast',
'Soft gradients and glassmorphism',
'Playful pastel palette',
];
const typographyOptions = [
'Modern sans-serif for headings, serif body text',
'Editorial serif across the site',
'Geometric sans with tight tracking',
'Rounded fonts with friendly tone',
];
export function StyleStep({ style, onChange }: Props) {
return (
<Card
title="Look & Feel"
description="Capture the brand personality so the preview canvas can mirror the right tone."
>
<div className="sb-grid">
<label className="sb-field">
<span>Palette direction</span>
<select value={style.palette} onChange={(event) => onChange({ palette: event.target.value })}>
{palettes.map((option) => (
<option key={option} value={option}>
{option}
</option>
))}
</select>
</label>
<label className="sb-field">
<span>Typography</span>
<select value={style.typography} onChange={(event) => onChange({ typography: event.target.value })}>
{typographyOptions.map((option) => (
<option key={option} value={option}>
{option}
</option>
))}
</select>
</label>
</div>
<label className="sb-field">
<span>Brand personality</span>
<textarea
rows={3}
value={style.personality}
onChange={(event) => onChange({ personality: event.target.value })}
/>
</label>
<label className="sb-field">
<span>Hero imagery direction</span>
<textarea
rows={3}
value={style.heroImagery}
onChange={(event) => onChange({ heroImagery: event.target.value })}
/>
</label>
</Card>
);
}

View File

@@ -0,0 +1,156 @@
import { create } from 'zustand';
import { builderApi } from '../api/builder.api';
import type {
BuilderFormData,
PageBlueprint,
SiteBlueprint,
StylePreferences,
} from '../types/siteBuilder';
import { useSiteDefinitionStore } from './siteDefinitionStore';
const defaultStyle: StylePreferences = {
palette: 'Vibrant modern palette with rich accent color',
typography: 'Sans-serif display for headings, humanist body font',
personality: 'Confident, energetic, optimistic',
heroImagery: 'Real people interacting with the product/service',
};
const defaultForm: BuilderFormData = {
siteId: null,
sectorId: null,
siteName: '',
businessType: '',
industry: '',
targetAudience: '',
hostingType: 'igny8_sites',
businessBrief: '',
objectives: ['Launch a conversion-focused marketing site'],
style: defaultStyle,
};
interface BuilderState {
form: BuilderFormData;
currentStep: number;
isSubmitting: boolean;
error?: string;
activeBlueprint?: SiteBlueprint;
pages: PageBlueprint[];
setField: <K extends keyof BuilderFormData>(key: K, value: BuilderFormData[K]) => void;
updateStyle: (partial: Partial<StylePreferences>) => void;
addObjective: (value: string) => void;
removeObjective: (index: number) => void;
setStep: (step: number) => void;
nextStep: () => void;
previousStep: () => void;
reset: () => void;
submitWizard: () => Promise<void>;
refreshPages: (blueprintId: number) => Promise<void>;
}
export const useBuilderStore = create<BuilderState>((set, get) => ({
form: defaultForm,
currentStep: 0,
isSubmitting: false,
pages: [],
setField: (key, value) =>
set((state) => ({
form: { ...state.form, [key]: value },
})),
updateStyle: (partial) =>
set((state) => ({
form: { ...state.form, style: { ...state.form.style, ...partial } },
})),
addObjective: (value) =>
set((state) => ({
form: { ...state.form, objectives: [...state.form.objectives, value] },
})),
removeObjective: (index) =>
set((state) => ({
form: {
...state.form,
objectives: state.form.objectives.filter((_, idx) => idx !== index),
},
})),
setStep: (step) => set({ currentStep: step }),
nextStep: () =>
set((state) => ({
currentStep: Math.min(state.currentStep + 1, 3),
})),
previousStep: () =>
set((state) => ({
currentStep: Math.max(state.currentStep - 1, 0),
})),
reset: () =>
set({
form: defaultForm,
currentStep: 0,
isSubmitting: false,
error: undefined,
activeBlueprint: undefined,
pages: [],
}),
submitWizard: async () => {
const { form } = get();
if (!form.siteId || !form.sectorId) {
set({ error: 'Site and sector are required to generate a blueprint.' });
return;
}
set({ isSubmitting: true, error: undefined });
try {
const payload = {
name: form.siteName || `Site Blueprint (${form.industry || 'New'})`,
description: `${form.businessType} for ${form.targetAudience}`,
site_id: form.siteId,
sector_id: form.sectorId,
hosting_type: form.hostingType,
config_json: {
business_type: form.businessType,
industry: form.industry,
target_audience: form.targetAudience,
},
};
const blueprint = await builderApi.createBlueprint(payload);
set({ activeBlueprint: blueprint });
const generation = await builderApi.generateStructure(blueprint.id, {
business_brief: form.businessBrief,
objectives: form.objectives,
style: form.style,
metadata: { targetAudience: form.targetAudience },
});
if (generation?.structure) {
useSiteDefinitionStore.getState().setStructure(generation.structure);
}
await get().refreshPages(blueprint.id);
} catch (error) {
set({ error: error instanceof Error ? error.message : 'Unexpected error' });
} finally {
set({ isSubmitting: false });
}
},
refreshPages: async (blueprintId: number) => {
try {
const pages = await builderApi.listPages(blueprintId);
set({ pages });
useSiteDefinitionStore.getState().setPages(pages);
} catch (error) {
set({ error: error instanceof Error ? error.message : 'Unable to load pages' });
}
},
}));

View File

@@ -0,0 +1,28 @@
import { create } from 'zustand';
import type { PageBlueprint, SiteStructure } from '../types/siteBuilder';
interface SiteDefinitionState {
structure?: SiteStructure;
pages: PageBlueprint[];
selectedSlug?: string;
setStructure: (structure: SiteStructure) => void;
setPages: (pages: PageBlueprint[]) => void;
selectPage: (slug: string) => void;
}
export const useSiteDefinitionStore = create<SiteDefinitionState>((set) => ({
pages: [],
setStructure: (structure) =>
set({
structure,
selectedSlug: structure.pages?.[0]?.slug,
}),
setPages: (pages) =>
set((state) => ({
pages,
selectedSlug: state.selectedSlug ?? pages[0]?.slug,
})),
selectPage: (slug) => set({ selectedSlug: slug }),
}));

View File

@@ -0,0 +1,87 @@
export type HostingType = 'igny8_sites' | 'wordpress' | 'shopify' | 'multi';
export interface StylePreferences {
palette: string;
typography: string;
personality: string;
heroImagery: string;
}
export interface BuilderFormData {
siteId: number | null;
sectorId: number | null;
siteName: string;
businessType: string;
industry: string;
targetAudience: string;
hostingType: HostingType;
businessBrief: string;
objectives: string[];
style: StylePreferences;
}
export interface SiteBlueprint {
id: number;
name: string;
description?: string;
status: 'draft' | 'generating' | 'ready' | 'deployed';
hosting_type: HostingType;
config_json: Record<string, unknown>;
structure_json: SiteStructure | null;
created_at: string;
updated_at: string;
}
export interface PageBlueprint {
id: number;
site_blueprint: number;
slug: string;
title: string;
type: string;
status: string;
order: number;
blocks_json: PageBlock[];
}
export interface PageBlock {
type: string;
heading?: string;
subheading?: string;
layout?: string;
content?: string[] | Record<string, unknown>;
}
export interface SiteStructure {
site?: {
name?: string;
primary_navigation?: string[];
secondary_navigation?: string[];
hero_message?: string;
tone?: string;
};
pages: Array<{
slug: string;
title: string;
type: string;
status?: string;
objective?: string;
primary_cta?: string;
blocks?: PageBlock[];
}>;
}
export interface ApiListResponse<T> {
count?: number;
next?: string | null;
previous?: string | null;
results?: T[];
data?: T[] | T;
}
export interface ApiError {
message?: string;
error?: string;
detail?: string;
}

View File

@@ -0,0 +1,31 @@
{
"compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
"target": "ES2022",
"useDefineForClassFields": true,
"lib": ["ES2022", "DOM", "DOM.Iterable"],
"module": "ESNext",
"types": ["vite/client"],
"skipLibCheck": true,
/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"verbatimModuleSyntax": true,
"moduleDetection": "force",
"noEmit": true,
"jsx": "react-jsx",
"baseUrl": ".",
"paths": {
"@shared/*": ["../frontend/src/components/shared/*"]
},
/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"erasableSyntaxOnly": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedSideEffectImports": true
},
"include": ["src"]
}

View File

@@ -0,0 +1,7 @@
{
"files": [],
"references": [
{ "path": "./tsconfig.app.json" },
{ "path": "./tsconfig.node.json" }
]
}

View File

@@ -0,0 +1,26 @@
{
"compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
"target": "ES2023",
"lib": ["ES2023"],
"module": "ESNext",
"types": ["node"],
"skipLibCheck": true,
/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"verbatimModuleSyntax": true,
"moduleDetection": "force",
"noEmit": true,
/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"erasableSyntaxOnly": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedSideEffectImports": true
},
"include": ["vite.config.ts"]
}

View File

@@ -0,0 +1,31 @@
import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const sharedPathCandidates = [
path.resolve(__dirname, '../frontend/src/components/shared'),
path.resolve(__dirname, '../../frontend/src/components/shared'),
'/frontend/src/components/shared',
];
const sharedComponentsPath = sharedPathCandidates.find((candidate) => fs.existsSync(candidate)) ?? sharedPathCandidates[0];
export default defineConfig({
plugins: [react()],
resolve: {
alias: {
'@shared': sharedComponentsPath,
},
},
server: {
host: '0.0.0.0',
port: 5175,
allowedHosts: ['builder.igny8.com'],
fs: {
allow: [path.resolve(__dirname, '..'), sharedComponentsPath],
},
},
});