generate site using llm prompt

This commit is contained in:
Krrish Ghimire
2026-07-02 01:15:16 +05:45
parent 18fed113f9
commit 3ccbd2ebec
75 changed files with 2220 additions and 3173 deletions

View File

@@ -11,37 +11,6 @@ export interface ComponentItem {
orderIndex: number;
}
export interface ComponentResponse {
id: string;
pageId: string;
type: ComponentType;
config: Record<string, unknown>;
styles: Record<string, unknown>;
orderIndex: number;
}
export interface PageWithComponentsResponse {
id: string;
siteId: string;
title: string;
slug: string;
seoTitle: string;
seoDescription: string;
orderIndex: number;
createdAt: string;
components: ComponentResponse[];
}
export interface SaveComponentsRequest {
components: {
id?: string;
type: ComponentType;
config: Record<string, unknown>;
styles: Record<string, unknown>;
orderIndex: number;
}[];
}
export function getDefaultConfig(type: ComponentType): Record<string, unknown> {
switch (type) {
case 'HEADING': return { text: 'Heading', level: 'h2' };
@@ -72,34 +41,36 @@ export function getDefaultStyles(type: ComponentType): Record<string, unknown> {
}
}
export function getComponentLabel(type: ComponentType): string {
const labels: Record<ComponentType, string> = {
HEADING: 'Heading',
TEXT: 'Text',
IMAGE: 'Image',
BUTTON: 'Button',
DIVIDER: 'Divider',
GALLERY: 'Gallery',
VIDEO: 'Video',
CONTACT_FORM: 'Contact Form',
MAP: 'Map',
CUSTOM_HTML: 'Custom HTML',
};
return labels[type];
const LABELS: Record<string, string> = {
HEADING: 'Heading',
TEXT: 'Text',
IMAGE: 'Image',
BUTTON: 'Button',
DIVIDER: 'Divider',
GALLERY: 'Gallery',
VIDEO: 'Video',
CONTACT_FORM: 'Contact Form',
MAP: 'Map',
CUSTOM_HTML: 'Custom HTML',
};
const ICONS: Record<string, string> = {
HEADING: 'title',
TEXT: 'text_fields',
IMAGE: 'image',
BUTTON: 'smart_button',
DIVIDER: 'horizontal_rule',
GALLERY: 'photo_library',
VIDEO: 'videocam',
CONTACT_FORM: 'contact_mail',
MAP: 'map',
CUSTOM_HTML: 'code',
};
export function getComponentLabel(type: string): string {
return LABELS[type] || LABELS[type.toUpperCase()] || type;
}
export function getComponentIcon(type: ComponentType): string {
const icons: Record<ComponentType, string> = {
HEADING: 'title',
TEXT: 'text_fields',
IMAGE: 'image',
BUTTON: 'smart_button',
DIVIDER: 'horizontal_rule',
GALLERY: 'photo_library',
VIDEO: 'videocam',
CONTACT_FORM: 'contact_mail',
MAP: 'map',
CUSTOM_HTML: 'code',
};
return icons[type];
export function getComponentIcon(type: string): string {
return ICONS[type] || ICONS[type.toUpperCase()] || 'code';
}

View File

@@ -0,0 +1,76 @@
import { ComponentType } from './component';
export interface LLMGenerateRequest {
prompt: string;
siteId: string;
references?: Reference[];
}
export interface LLMRefineRequest {
prompt: string;
siteId: string;
currentStructure: SiteStructure;
references?: Reference[];
}
export interface Reference {
type: 'URL' | 'IMAGE';
url: string;
altText: string;
}
export interface SiteStructure {
theme: ThemeConfig;
pages: PageStructure[];
}
export interface ThemeConfig {
colors: Record<string, string>;
fonts: Record<string, string>;
spacing: Record<string, string>;
}
export interface PageStructure {
id?: string;
title: string;
slug: string;
seoTitle?: string;
seoDescription?: string;
orderIndex: number;
components: ComponentStructure[];
}
export interface ComponentStructure {
id?: string;
type: ComponentType;
orderIndex: number;
config: Record<string, unknown>;
styles: Record<string, unknown>;
}
export interface TokenUsage {
prompt: number;
completion: number;
total: number;
}
export interface LLMSession {
id?: string;
siteId: string;
prompt: string;
generatedStructure: SiteStructure | null;
refinedPrompt: string | null;
acceptedAt: string | null;
createdAt: string;
}
export interface GenerationVersion {
id: string;
siteId: string;
userId: string;
versionNumber: number;
prompt: string;
references: Reference[];
fullStructure: string;
createdAt: string;
}