faizee07 commited on
Commit
e55def7
ยท
verified ยท
1 Parent(s): bf50e9c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +958 -713
app.py CHANGED
@@ -7,500 +7,745 @@ import traceback
7
  import shutil
8
  import glob
9
  import json
 
10
 
11
  load_dotenv()
12
 
13
- # --- SYSTEM CONSTANTS ---
14
- PROMPTS_FOR_AI = [
15
- # === SINGLE-PAGE WEBSITES ===
16
- "๐ŸŽจ Portfolio - Minimalist designer portfolio with projects grid and contact form (Single Page)",
17
- "๐Ÿš€ SaaS Landing Page - Modern software startup with pricing cards and demo CTA (Single Page)",
18
- "๐Ÿ’ผ Personal CV - Professional resume website with timeline and skills section (Single Page)",
19
- "๐ŸŽฏ Product Launch - Single product showcase with features and pre-order form (Single Page)",
20
- "๐Ÿ“ฑ App Landing - Mobile app presentation with screenshots and download buttons (Single Page)",
21
- "๐ŸŽช Event Landing - Conference or workshop page with schedule and registration (Single Page)",
22
- "๐Ÿ‹๏ธ Fitness Landing - Gym or trainer page with services and transformation gallery (Single Page)",
23
- "๐Ÿ• Restaurant Landing - Menu showcase with reservations and location info (Single Page)",
24
- "๐Ÿ“š Course Landing - Online course sales page with curriculum and testimonials (Single Page)",
25
- "๐ŸŽต Music Artist - Musician portfolio with discography and tour dates (Single Page)",
26
- "๐Ÿ’ Wedding Invitation - Elegant RSVP page with event details and gallery (Single Page)",
27
- "๐Ÿ  Real Estate Listing - Property showcase with virtual tour and contact form (Single Page)",
28
- "๐Ÿš— Car Dealership - Vehicle showcase with specifications and test drive booking (Single Page)",
29
- "๐Ÿ’„ Beauty Salon - Services menu with pricing and appointment booking (Single Page)",
30
- "๐ŸŽฎ Gaming Landing - Game showcase with trailer and download links (Single Page)",
31
- "โ˜• Coffee Shop - Cozy cafe page with menu and ambiance gallery (Single Page)",
32
- "๐Ÿ“ท Photography Portfolio - Visual gallery with categories and booking info (Single Page)",
33
- "๐Ÿข Corporate Landing - Business services with team and contact sections (Single Page)",
34
- "๐ŸŒฟ Wellness Center - Holistic services with practitioner profiles (Single Page)",
35
- "๐ŸŽฌ Film Production - Studio portfolio with showreel and services (Single Page)",
36
-
37
- # === MULTI-PAGE WEBSITES ===
38
- "๐Ÿ›๏ธ E-commerce Platform - Full online store with products, cart, and checkout (Multi-Page)",
39
- "๐Ÿ“ฐ News Magazine - Multi-category blog with articles and authors (Multi-Page)",
40
- "๐ŸŽ“ University Website - Campus site with departments and student portal (Multi-Page)",
41
- "๐Ÿฅ Healthcare Portal - Medical center with departments and patient services (Multi-Page)",
42
- "๐Ÿจ Hotel Website - Accommodation with rooms, amenities, and booking system (Multi-Page)",
43
- "๐Ÿ“Š Dashboard Application - Analytics platform with multiple data views (Multi-Page)",
44
- "๐ŸŽญ Theatre Website - Shows, tickets, and venue information (Multi-Page)",
45
- "โš–๏ธ Law Firm - Practice areas, team, and case studies (Multi-Page)",
46
- "๐Ÿ—๏ธ Construction Company - Projects portfolio, services, and team (Multi-Page)",
47
- "๐ŸŒ Travel Agency - Destinations, packages, and booking system (Multi-Page)"
48
- ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
 
50
- PROMPT_FOR_IMAGE_GENERATION = """
51
- When creating image placeholders, use the static.photos service:
 
52
 
53
- Format: http://static.photos/[category]/[dimensions]/[seed]
 
54
 
55
- IMPORTANT RULES:
56
- - Dimensions MUST be one of: 200x200, 320x240, 640x360, 1024x576, or 1200x630
57
- - Seed: Any number (1-999+) for consistent images, or omit for random
58
- - Categories: nature, office, people, technology, minimal, abstract, aerial, blurred, bokeh, gradient,
59
- monochrome, vintage, white, black, blue, red, green, yellow, cityscape, workspace, food, travel,
60
- textures, industry, indoor, outdoor, studio, finance, medical, season, holiday, event, sport,
61
- science, legal, estate, restaurant, retail, wellness, agriculture, construction, craft, cosmetic,
62
- automotive, gaming, or education
63
 
64
- USAGE EXAMPLES:
65
- - Hero section: http://static.photos/gradient/1200x630/42
66
- - Team photos: http://static.photos/people/320x240/[1-6] (use different seeds)
67
- - Product cards: http://static.photos/technology/640x360/100
68
- - Background: http://static.photos/abstract/1200x630/777
69
- - Testimonial avatars: http://static.photos/people/200x200/[201-203]
70
- - Gallery: http://static.photos/nature/640x360/[301-306]
71
 
72
- BEST PRACTICES:
73
- - Use consistent seeds within sections for cohesive design
74
- - Match category to content (e.g., 'office' for corporate, 'food' for restaurant)
75
- - Hero images: Use 1200x630 for full-width sections
76
- - Cards/Features: Use 640x360 for medium-sized images
77
- - Thumbnails: Use 320x240 or 200x200 for small images
78
- - Always include descriptive alt text
79
- - Add loading="lazy" for performance
80
  """
81
 
82
- PROMPT_FOR_PROJECT_NAME = """
83
- Generate a creative, memorable project name that:
84
- 1. Starts with a relevant emoji that represents the project
85
- 2. Is 2-3 words maximum
86
- 3. Is catchy and brandable
87
- 4. Reflects the project's purpose or vibe
88
- 5. Could work as a domain name
89
- 6. Avoids generic terms
90
- Examples: "๐Ÿš€ LaunchPad Pro", "๐ŸŽจ PixelCraft Studio", "๐Ÿ’ซ Stellar Pages"
91
- Format: Always return as "[emoji] [ProjectName]"
 
 
 
 
 
 
 
 
 
 
 
 
92
  """
93
 
94
- # --- 1. SET UP THE GEMINI LLM ---
95
  try:
96
  llm = LLM(
97
  model="gemini/gemini-2.0-flash-exp",
98
- temperature=0.6,
99
  api_key=os.environ.get("GOOGLE_API_KEY")
100
  )
101
  except Exception as e:
102
- print("\n\n---")
103
- print("Error initializing Gemini LLM. Make sure you have set your GOOGLE_API_KEY.")
104
- print(f"Error: {e}")
105
- print("---\n\n")
106
  llm = None
107
 
108
- # --- 2. DEFINE TOOLS AND OUTPUT DIRECTORY ---
109
  os.makedirs("outputs", exist_ok=True)
110
  file_write_tool = FileWriterTool()
111
 
112
- # --- 3. DEFINE THE AGENT TEAM WITH ENHANCED PROMPTS ---
113
  designer = Agent(
114
- role='Principal Brand & UI/UX Designer',
115
- goal='Translate a user\'s "vibe" into a concrete, professional design brief with modern UI specifications.',
116
- backstory=(
117
- "You are a world-class brand and UI/UX designer with 15+ years of experience at top tech companies. "
118
- "You have deep expertise in:\n"
119
- "- Modern design systems (Material Design, Apple HIG, Fluent Design)\n"
120
- "- Color theory and accessible color palettes (WCAG AA/AAA compliance)\n"
121
- "- Typography hierarchies and font pairing psychology\n"
122
- "- Micro-interactions and motion design principles\n"
123
- "- Current web design trends (glassmorphism, neumorphism, brutalism, minimalism)\n"
124
- "- Spacing systems (4px/8px grids, golden ratio)\n"
125
- "- Visual hierarchy and F/Z-pattern layouts\n\n"
126
- "You always consider:\n"
127
- "- User psychology and emotional design\n"
128
- "- Mobile-first responsive breakpoints\n"
129
- "- Accessibility (contrast ratios, focus states, ARIA)\n"
130
- "- Performance (optimized assets, loading strategies)\n"
131
- "- Brand consistency and design tokens\n\n"
132
- f"IMAGE GENERATION GUIDELINES:\n{PROMPT_FOR_IMAGE_GENERATION}"
133
- ),
134
- verbose=True,
135
- llm=llm,
136
- allow_delegation=False
 
 
 
137
  )
138
 
139
  copywriter = Agent(
140
- role='Senior UX Copywriter & Content Strategist',
141
- goal='Write compelling, conversion-focused copy that matches brand voice and guides user behavior.',
142
- backstory=(
143
- "You are an expert UX copywriter who combines psychology, marketing, and user experience. "
144
- "Your expertise includes:\n"
145
- "- Microcopy that guides users intuitively\n"
146
- "- Conversion-focused CTAs with action-oriented language\n"
147
- "- Voice and tone frameworks for brand consistency\n"
148
- "- SEO-optimized content structure\n"
149
- "- Accessibility considerations (clear language, screen reader friendly)\n"
150
- "- Storytelling techniques that create emotional connections\n\n"
151
- "You follow principles:\n"
152
- "- Clarity over cleverness\n"
153
- "- Active voice and direct language\n"
154
- "- Scannable content with proper heading hierarchy\n"
155
- "- Benefits-focused rather than features-focused\n"
156
- "- Appropriate reading level for target audience\n\n"
157
- f"PROJECT NAMING GUIDELINES:\n{PROMPT_FOR_PROJECT_NAME}"
158
- ),
159
- verbose=True,
160
- llm=llm,
161
- allow_delegation=False
162
  )
163
 
164
  developer = Agent(
165
- role='Senior Frontend Developer & UI Engineer',
166
- goal='Build pixel-perfect, performant, and accessible websites using modern web technologies.',
167
- backstory=(
168
- "You are an elite frontend developer with expertise in modern web development. "
169
- "Your technical stack and knowledge includes:\n\n"
170
- "**CSS Frameworks & Libraries:**\n"
171
- "- Tailwind CSS (utility-first approach, responsive design)\n"
172
- "- Custom CSS with CSS Grid, Flexbox, and CSS Variables\n"
173
- "- Modern CSS features (clamp, aspect-ratio, container queries)\n\n"
174
- "**Animation Libraries:**\n"
175
- "- AOS (Animate On Scroll) for scroll-triggered animations\n"
176
- "- CSS animations and transitions (cubic-bezier, keyframes)\n"
177
- "- Intersection Observer API for performance\n\n"
178
- "**Multi-Page Support:**\n"
179
- "- Create separate HTML files for multi-page projects\n"
180
- "- Implement consistent navigation across pages\n"
181
- "- Use relative links between pages\n"
182
- "- Maintain design consistency across all pages\n\n"
183
- "**UI Components:**\n"
184
- "- Hero sections with parallax/gradient backgrounds\n"
185
- "- Cards with hover effects and shadows\n"
186
- "- Smooth scroll navigation with offset\n"
187
- "- Modal/overlay patterns\n"
188
- "- Form validation and interactive states\n"
189
- "- Loading states and skeleton screens\n\n"
190
- "**Best Practices:**\n"
191
- "- Semantic HTML5 (proper heading hierarchy, landmarks, ARIA)\n"
192
- "- Mobile-first responsive design (320px to 4K)\n"
193
- "- Performance optimization (minimal dependencies, defer/async scripts)\n"
194
- "- Cross-browser compatibility\n"
195
- "- SEO meta tags and Open Graph\n"
196
- "- Accessibility (keyboard navigation, focus management, color contrast)\n"
197
- "- Clean, maintainable code with comments\n\n"
198
- "You ALWAYS include:\n"
199
- "- Tailwind CSS via CDN for rapid, consistent styling\n"
200
- "- AOS library for smooth scroll animations\n"
201
- "- Google Fonts with font-display: swap\n"
202
- "- Responsive images and proper alt text\n"
203
- "- Smooth scrolling behavior\n"
204
- "- Hover states and micro-interactions\n"
205
- "- Mobile hamburger menu when needed\n"
206
- "- Consistent spacing using design tokens\n\n"
207
- f"IMAGE IMPLEMENTATION:\n{PROMPT_FOR_IMAGE_GENERATION}"
208
- ),
209
- verbose=True,
210
- llm=llm,
211
- tools=[file_write_tool],
212
- allow_delegation=False
213
  )
214
 
215
- # --- 4. DEFINE THE WORKFLOW WITH ENHANCED TASK DESCRIPTIONS ---
216
- design_task = Task(
217
- description=(
218
- "Analyze the user's prompt: '{prompt}' and create a comprehensive Design System Brief.\n\n"
219
- "**PROJECT NAME:** Generate a creative project name following the naming guidelines.\n\n"
220
- "**Required Deliverables:**\n\n"
221
- "1. **Project Overview:**\n"
222
- " - Creative project name with emoji\n"
223
- " - Project type (single-page or multi-page) - Check if prompt mentions 'Single Page' or 'Multi-Page'\n"
224
- " - If multi-page, list all pages needed (e.g., index.html, about.html, contact.html)\n\n"
225
- "2. **Color Palette (5-7 colors with specific usage):**\n"
226
- " - Primary color (brand identity, CTAs)\n"
227
- " - Secondary color (accents, highlights)\n"
228
- " - Background colors (light/dark mode if applicable)\n"
229
- " - Text colors (headings, body, muted)\n"
230
- " - Semantic colors (success, warning, error)\n"
231
- " - Provide exact hex codes and ensure WCAG AA contrast ratios\n\n"
232
- "3. **Typography System:**\n"
233
- " - Primary font (headings) from Google Fonts with fallbacks\n"
234
- " - Secondary font (body text) from Google Fonts with fallbacks\n"
235
- " - Font size scale (h1: Xpx, h2: Xpx, body: Xpx, small: Xpx)\n"
236
- " - Line heights and letter spacing recommendations\n"
237
- " - Font weights to use (300, 400, 600, 700)\n\n"
238
- "4. **Spacing & Layout System:**\n"
239
- " - Base spacing unit (4px or 8px)\n"
240
- " - Section padding/margins (mobile and desktop)\n"
241
- " - Container max-width\n"
242
- " - Grid system (columns, gaps)\n\n"
243
- "5. **UI Components & Patterns:**\n"
244
- " - Button styles (primary, secondary, ghost)\n"
245
- " - Card designs with shadows/borders\n"
246
- " - Navigation style (sticky header, transparent, solid)\n"
247
- " - Form input styles\n"
248
- " - Image treatment (rounded corners, shadows, overlays)\n\n"
249
- "6. **Animation & Interaction Guidelines:**\n"
250
- " - Scroll animations (fade, slide, zoom)\n"
251
- " - Hover effects (buttons, cards, links)\n"
252
- " - Transition timings (fast: 150ms, normal: 300ms, slow: 500ms)\n"
253
- " - Easing functions to use\n\n"
254
- "7. **Image & Media Strategy:**\n"
255
- " - Use static.photos service for all placeholder images\n"
256
- " - Specify exact URLs for each section using format: http://static.photos/[category]/[dimensions]/[seed]\n"
257
- " - Hero image: Use 1200x630 dimension\n"
258
- " - Feature cards: Use 640x360 dimension\n"
259
- " - Thumbnails: Use 320x240 or 200x200\n"
260
- " - Profile/avatar images: Use 200x200\n"
261
- " - Choose appropriate categories for the project type\n"
262
- " - Use consistent seed numbers within sections\n"
263
- " - Include alt text descriptions for each image\n\n"
264
- "8. **Page Structure:**\n"
265
- " - Header/Navigation (consistent across pages if multi-page)\n"
266
- " - Hero section (with specific layout description)\n"
267
- " - 3-5 main content sections with purposes\n"
268
- " - Footer with sitemap\n"
269
- " - Additional pages structure if multi-page project\n\n"
270
- "9. **Design Style & Aesthetic:**\n"
271
- " - Overall aesthetic (minimalist, bold, playful, corporate, etc.)\n"
272
- " - Imagery style (photos, illustrations, abstract)\n"
273
- " - Border radius approach (sharp, slightly rounded, very rounded)\n"
274
- " - Shadow style (subtle, pronounced, none)\n"
275
- " - Any specific design trends to incorporate"
276
- ),
277
- expected_output=(
278
- "A detailed, structured Design System Brief in markdown format with all 9 sections completed. "
279
- "Include the creative project name with emoji at the top. "
280
- "Clearly specify if this is a single-page or multi-page project based on the prompt. "
281
- "Include specific static.photos URLs with proper dimensions and categories. "
282
- "Include specific values, measurements, and clear implementation guidelines. "
283
- "The brief should be detailed enough for a developer to implement without additional questions."
284
- ),
285
- agent=designer
286
- )
 
287
 
288
- copywriting_task = Task(
289
- description=(
290
- "Using the Design Brief, write comprehensive, professional website copy.\n\n"
291
- "**IMPORTANT:** Use the project name from the Design Brief throughout the content.\n\n"
292
- "**Content Requirements:**\n\n"
293
- "1. **Project Identity:**\n"
294
- " - Use the creative project name with emoji from the Design Brief\n"
295
- " - Create a tagline that complements the project name\n"
296
- " - Establish brand voice based on the project type\n\n"
297
- "2. **Hero Section:**\n"
298
- " - Main headline (6-10 words, powerful, benefit-focused)\n"
299
- " - Subheadline (15-25 words, supporting the headline)\n"
300
- " - Primary CTA text (2-4 words, action-oriented)\n"
301
- " - Secondary CTA text if needed\n\n"
302
- "3. **About/Value Proposition Section:**\n"
303
- " - Section headline\n"
304
- " - 2-3 paragraphs explaining who/what/why (100-150 words)\n"
305
- " - Key value propositions (3-4 bullet points)\n\n"
306
- "4. **Features/Services Section:**\n"
307
- " - Section headline\n"
308
- " - 3-6 feature/service cards, each with:\n"
309
- " * Title (3-5 words)\n"
310
- " * Description (30-50 words)\n"
311
- " * Icon suggestion (describe the icon)\n\n"
312
- "5. **Social Proof/Testimonials (if applicable):**\n"
313
- " - Section headline\n"
314
- " - 2-3 testimonials with:\n"
315
- " * Quote (20-40 words)\n"
316
- " * Name and title/company\n\n"
317
- "6. **Call-to-Action Section:**\n"
318
- " - Headline (compelling, urgent)\n"
319
- " - Supporting text (20-40 words)\n"
320
- " - CTA button text\n\n"
321
- "7. **Footer Content:**\n"
322
- " - Brief tagline or description\n"
323
- " - Navigation links (for all pages if multi-page)\n"
324
- " - Copyright text with project name\n"
325
- " - Social media platform suggestions\n\n"
326
- "8. **Additional Pages Content (if multi-page):**\n"
327
- " - Content for each additional page specified in the Design Brief\n"
328
- " - Maintain consistent voice and tone\n"
329
- " - Include page-specific CTAs and navigation\n\n"
330
- "**Writing Guidelines:**\n"
331
- "- Match the vibe/tone from the design brief perfectly\n"
332
- "- Use active voice and power words\n"
333
- "- Keep sentences concise (max 20 words)\n"
334
- "- Include emotional triggers appropriate to the brand\n"
335
- "- Make CTAs clear and action-oriented\n"
336
- "- Ensure natural keyword integration for SEO\n"
337
- "- Write at appropriate reading level for target audience"
338
- ),
339
- expected_output=(
340
- "A complete Content Map in markdown format with all sections filled out. "
341
- "The project name with emoji should be prominently featured. "
342
- "Content should be polished, professional, and ready to copy-paste into HTML. "
343
- "Include clear labels for each content piece and its placement on the page. "
344
- "If multi-page, provide content for all pages specified in the Design Brief."
345
- ),
346
- agent=copywriter,
347
- context=[design_task]
348
- )
349
 
350
- development_task = Task(
351
- description=(
352
- "Build a complete, production-ready website using modern web technologies.\n\n"
353
- "**CRITICAL INSTRUCTIONS:**\n"
354
- "1. Check the Design Brief for project type (single-page vs multi-page)\n"
355
- "2. If SINGLE-PAGE: Save as 'outputs/index.html'\n"
356
- "3. If MULTI-PAGE: Save each page separately (e.g., 'outputs/index.html', 'outputs/about.html', etc.)\n"
357
- "4. Use the project name from the Design Brief in all page titles and metadata\n"
358
- "5. Use the exact static.photos URLs specified in the Design Brief\n\n"
359
- "**MANDATORY TECHNICAL REQUIREMENTS:**\n\n"
360
- "1. **HTML Structure (for each page):**\n"
361
- " ```html\n"
362
- " <!DOCTYPE html>\n"
363
- " <html lang=\"en\">\n"
364
- " <head>\n"
365
- " - Meta charset UTF-8\n"
366
- " - Viewport meta tag\n"
367
- " - Title with project name\n"
368
- " - SEO meta tags (title, description, keywords)\n"
369
- " - Open Graph tags for social sharing\n"
370
- " - Favicon (data URI or emoji)\n"
371
- " - Tailwind CSS CDN: <script src=\"https://cdn.tailwindcss.com\"></script>\n"
372
- " - Google Fonts from design brief\n"
373
- " - AOS library:\n"
374
- " <link href=\"https://unpkg.com/aos@2.3.1/dist/aos.css\" rel=\"stylesheet\">\n"
375
- " <script src=\"https://unpkg.com/aos@2.3.1/dist/aos.js\"></script>\n"
376
- " - Custom CSS in <style> tags\n"
377
- " </head>\n"
378
- " ```\n\n"
379
- "2. **Multi-Page Navigation (if applicable):**\n"
380
- " - Consistent navigation bar across all pages\n"
381
- " - Use relative links (e.g., href=\"about.html\")\n"
382
- " - Active page highlighting in navigation\n"
383
- " - Mobile-responsive hamburger menu\n\n"
384
- "3. **CSS Implementation:**\n"
385
- " - Use Tailwind utility classes for layout, spacing, and responsive design\n"
386
- " - Define custom CSS variables for colors from design brief:\n"
387
- " ```css\n"
388
- " :root {\n"
389
- " --color-primary: #HEXCODE;\n"
390
- " --color-secondary: #HEXCODE;\n"
391
- " --color-text: #HEXCODE;\n"
392
- " --color-bg: #HEXCODE;\n"
393
- " /* etc */\n"
394
- " }\n"
395
- " ```\n"
396
- " - Add custom CSS for:\n"
397
- " * Smooth scroll behavior\n"
398
- " * Custom button hover effects\n"
399
- " * Gradient backgrounds if specified\n"
400
- " * Any design-specific styles not achievable with Tailwind\n\n"
401
- "4. **Image Implementation:**\n"
402
- " - Use the exact static.photos URLs from the Design Brief\n"
403
- " - Format: <img src=\"http://static.photos/[category]/[dimensions]/[seed]\" alt=\"[description]\">\n"
404
- " - Include proper alt text for all images\n"
405
- " - Add loading=\"lazy\" for performance (except hero images)\n"
406
- " - Add class=\"w-full h-auto\" for responsive images\n"
407
- " - Example hero: <img src=\"http://static.photos/gradient/1200x630/42\" alt=\"Hero background\" class=\"w-full h-auto\">\n"
408
- " - Example card: <img src=\"http://static.photos/technology/640x360/100\" alt=\"Feature image\" class=\"w-full h-auto rounded-lg\">\n\n"
409
- "5. **Animation Implementation:**\n"
410
- " - Initialize AOS in script: `AOS.init({duration: 800, once: true});`\n"
411
- " - Add AOS attributes to elements:\n"
412
- " * `data-aos=\"fade-up\"` for hero elements\n"
413
- " * `data-aos=\"fade-in\"` for content sections\n"
414
- " * `data-aos=\"zoom-in\"` for cards/features\n"
415
- " * `data-aos=\"slide-up\"` for CTAs\n"
416
- " - Add CSS transitions for hover effects:\n"
417
- " * Buttons: transform, shadow, background changes\n"
418
- " * Cards: lift effect (translateY + shadow)\n"
419
- " * Links: color/underline transitions\n"
420
- " - Use staggered animations with `data-aos-delay`\n\n"
421
- "6. **Responsive Design (Mobile-First):**\n"
422
- " - Base styles for mobile (320px+)\n"
423
- " - Tablet breakpoint (768px): `md:` prefix\n"
424
- " - Desktop breakpoint (1024px): `lg:` prefix\n"
425
- " - Large desktop (1280px): `xl:` prefix\n"
426
- " - Test all sections at each breakpoint\n"
427
- " - Mobile navigation (hamburger menu with smooth toggle)\n\n"
428
- "7. **Required Sections (use semantic HTML):**\n"
429
- " - `<header>` with `<nav>` (sticky or fixed)\n"
430
- " - `<main>` containing:\n"
431
- " * `<section>` for hero with unique background\n"
432
- " * `<section>` for about/value prop\n"
433
- " * `<section>` for features/services (grid layout)\n"
434
- " * `<section>` for testimonials/social proof (if applicable)\n"
435
- " * `<section>` for final CTA\n"
436
- " - `<footer>` with navigation and credits\n\n"
437
- "8. **File Saving Instructions:**\n"
438
- " - Single-page: Save to 'outputs/index.html'\n"
439
- " - Multi-page: Save each page with descriptive names\n"
440
- " - Ensure all internal links work correctly\n"
441
- " - Test navigation between pages\n\n"
442
- "9. **Accessibility Requirements:**\n"
443
- " - Semantic HTML5 elements\n"
444
- " - ARIA labels where needed\n"
445
- " - Keyboard navigable (focus visible)\n"
446
- " - Alt text for all images\n"
447
- " - Sufficient color contrast (test against WCAG)\n"
448
- " - Skip to content link\n\n"
449
- "10. **Code Quality:**\n"
450
- " - Proper indentation (2 spaces)\n"
451
- " - Comments for major sections\n"
452
- " - Clean, readable code\n"
453
- " - No console errors\n\n"
454
- "**CRITICAL:** Save all HTML files to 'outputs/' directory using FileWriterTool.\n"
455
- "Files must be immediately viewable in a browser without any modifications.\n"
456
- "Images must use static.photos URLs exactly as specified in the Design Brief.\n\n"
457
- "**Design Brief Reference:** Use exact colors, fonts, spacing, images, and project name from the Design Brief.\n"
458
- "**Content Reference:** Use exact copy from the Content Map.\n\n"
459
- "Think step-by-step:\n"
460
- "1. Identify if single-page or multi-page from Design Brief\n"
461
- "2. Set up HTML boilerplate with all CDN links\n"
462
- "3. Define CSS variables for the color palette\n"
463
- "4. Build header/navigation (with multi-page links if applicable)\n"
464
- "5. Create hero section with static.photos image and animations\n"
465
- "6. Build each content section with appropriate Tailwind classes\n"
466
- "7. Add static.photos images with proper dimensions\n"
467
- "8. Add AOS animations to key elements\n"
468
- "9. Implement hover effects and transitions\n"
469
- "10. Build responsive footer\n"
470
- "11. Add mobile menu functionality\n"
471
- "12. For multi-page: Repeat for each additional page\n"
472
- "13. Test responsive breakpoints\n"
473
- "14. Save all files to outputs/ directory"
474
- ),
475
- expected_output=(
476
- "Complete, self-contained HTML file(s) saved to 'outputs/' directory that:\n"
477
- "- Renders perfectly in all modern browsers\n"
478
- "- Is fully responsive (mobile to 4K)\n"
479
- "- Includes smooth animations and transitions\n"
480
- "- Uses Tailwind CSS and AOS library\n"
481
- "- Implements the exact design and content from previous tasks\n"
482
- "- Uses static.photos images with correct dimensions\n"
483
- "- Uses the project name consistently\n"
484
- "- Has working navigation for multi-page projects\n"
485
- "- Has no errors or missing dependencies\n"
486
- "- Is production-ready and deployable"
487
- ),
488
- agent=developer,
489
- context=[design_task, copywriting_task],
490
- tools=[file_write_tool]
491
- )
492
 
493
- # --- 5. ASSEMBLE THE CREW ---
494
- vibe_crew = Crew(
495
- agents=[designer, copywriter, developer],
496
- tasks=[design_task, copywriting_task, development_task],
497
- process=Process.sequential,
498
- verbose=True
499
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
500
 
501
- # --- 6. HELPER FUNCTIONS ---
 
 
502
  def clean_outputs_directory():
503
- """Clean the outputs directory before generating new files."""
504
  if os.path.exists("outputs"):
505
  for file in glob.glob("outputs/*"):
506
  try:
@@ -509,13 +754,10 @@ def clean_outputs_directory():
509
  print(f"Error removing {file}: {e}")
510
 
511
  def create_zip_archive():
512
- """Create a ZIP archive of all files in the outputs directory."""
513
  try:
514
- # Get all HTML files in outputs directory
515
  html_files = glob.glob("outputs/*.html")
516
-
517
  if len(html_files) > 1:
518
- # Create ZIP file
519
  shutil.make_archive("outputs/project", 'zip', "outputs")
520
  return "outputs/project.zip"
521
  return None
@@ -523,126 +765,158 @@ def create_zip_archive():
523
  print(f"Error creating ZIP: {e}")
524
  return None
525
 
526
- def extract_project_name(result_text):
527
- """Extract project name from the crew result."""
528
- try:
529
- # Look for emoji + project name pattern
530
- import re
531
- pattern = r'([๐Ÿš€๐ŸŽจ๐Ÿ’ซ๐ŸŒŸโœจ๐ŸŽฏ๐Ÿ”ฅ๐Ÿ’Ž๐ŸŒˆ๐ŸŽญ๐ŸŽช๐ŸŽธ๐ŸŽฌ๐ŸŽฎ๐ŸŽฏ๐Ÿ’ผ๐Ÿ†๐ŸŒธ๐Ÿฆ„๐Ÿ•๐Ÿ”๐Ÿ›๏ธ๐Ÿ“š๐Ÿ ๐Ÿ‹๏ธ๐Ÿ“ฐ๐ŸŽต๐Ÿ’ณ๐ŸŽ“๐Ÿš—๐ŸŽจ๐Ÿ“ฑ๐ŸŽช๐Ÿ•๐ŸŽต๐Ÿ’๐Ÿ ๐Ÿš—๐Ÿ’„๐ŸŽฎโ˜•๐Ÿ“ท๐Ÿข๐ŸŒฟ๐ŸŽฌ๐Ÿฅ๐Ÿจ๐Ÿ“Š๐ŸŽญโš–๏ธ๐Ÿ—๏ธ๐ŸŒ][^\n]*(?:Pro|Studio|Hub|Lab|Plus|App|Site|Portal|Platform|Space|Zone|World|Center|Market|Shop|Store|Pages?))'
532
- match = re.search(pattern, str(result_text))
533
- if match:
534
- return match.group(1).strip()
535
- return "โœจ Awesome Project"
536
- except:
537
- return "โœจ Awesome Project"
538
-
539
- # --- 7. CREATE THE GRADIO WEB INTERFACE ---
540
- def run_crew(prompt, use_template):
541
  try:
542
  if llm is None:
543
  return (
544
- "โŒ **Error:** Gemini LLM not initialized. Please check your GOOGLE_API_KEY in environment variables.",
545
- None,
546
- gr.update(visible=False),
547
- gr.update(visible=False),
548
- gr.update(visible=False),
549
- ""
550
  )
551
 
552
- # Determine the actual prompt to use
553
- if use_template and prompt in PROMPTS_FOR_AI:
554
- final_prompt = prompt
555
- elif not use_template and prompt and prompt.strip() != "":
556
- final_prompt = prompt
557
  else:
558
- return (
559
- "โŒ **Error:** Please select a template or enter a custom prompt.",
560
- None,
561
- gr.update(visible=False),
562
- gr.update(visible=False),
563
- gr.update(visible=False),
564
- ""
565
- )
566
 
567
- # Clean up previous output
 
 
568
  clean_outputs_directory()
569
 
570
- print(f"\n๐Ÿš€ Starting generation with prompt: {final_prompt[:100]}...")
 
 
 
 
 
571
 
572
- # Run the crew
573
- inputs = {'prompt': final_prompt}
574
- result = vibe_crew.kickoff(inputs=inputs)
 
 
 
 
575
 
576
- # Extract project name
577
- project_name = extract_project_name(result)
578
- print(f"\nโœ… Project Name: {project_name}")
579
 
580
- # Check generated files
581
  html_files = glob.glob("outputs/*.html")
582
-
583
  if not html_files:
584
  return (
585
- "โŒ **Error:** No HTML files were generated. Please try again.",
586
- None,
587
- gr.update(visible=False),
588
- gr.update(visible=False),
589
- gr.update(visible=False),
590
- ""
591
  )
592
 
593
- # Determine if single or multi-page
594
- is_multipage = len(html_files) > 1
595
-
596
- # Create preview (show index.html or first file)
597
  preview_file = "outputs/index.html" if os.path.exists("outputs/index.html") else html_files[0]
598
  with open(preview_file, "r", encoding="utf-8") as file:
599
  html_content = file.read()
600
 
601
  preview_html = f'<iframe srcdoc="{html_content.replace(chr(34), "&quot;")}" width="100%" height="800px" style="border: 2px solid #e0e0e0; border-radius: 8px;"></iframe>'
602
 
603
- # Prepare success message
 
 
 
 
 
 
604
  if is_multipage:
605
- file_list = ", ".join([os.path.basename(f) for f in html_files])
606
- success_message = f"โœ… **Project Generated: {project_name}**\n\nMulti-page website created with {len(html_files)} pages: {file_list}"
607
-
608
- # Create ZIP archive
609
  zip_path = create_zip_archive()
610
- if zip_path:
611
- return (
612
- success_message,
613
- preview_html,
614
- gr.update(value=preview_file, visible=True),
615
- gr.update(value=zip_path, visible=True, label=f"๐Ÿ“ฆ Download {project_name} (ZIP)"),
616
- gr.update(visible=True),
617
- project_name
618
- )
619
  else:
620
- success_message = f"โœ… **Project Generated: {project_name}**\n\nSingle-page website ready to download!"
621
  return (
622
  success_message,
623
  preview_html,
624
- gr.update(value=preview_file, visible=True, label=f"๐Ÿ“ฅ Download {project_name} (HTML)"),
625
  gr.update(visible=False),
626
- gr.update(visible=True),
627
- project_name
628
  )
629
-
630
  except Exception as e:
631
  error_trace = traceback.format_exc()
632
- error_message = f"โŒ **Error occurred during execution:**\n\n```python\n{str(e)}\n```\n\nPlease try again or check your API keys."
633
  print(error_trace)
634
  return (
635
- error_message,
636
- None,
637
- gr.update(visible=False),
638
- gr.update(visible=False),
639
- gr.update(visible=False),
640
- ""
641
  )
642
 
643
- # --- 8. CREATE THE GRADIO INTERFACE ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
644
  with gr.Blocks(theme=gr.themes.Soft(), css="""
645
  .container { max-width: 1400px; margin: auto; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
646
  .status-box {
647
  padding: 20px;
648
  border-radius: 12px;
@@ -651,225 +925,196 @@ with gr.Blocks(theme=gr.themes.Soft(), css="""
651
  color: white;
652
  font-weight: 500;
653
  }
654
- .download-section {
655
- text-align: center;
656
- padding: 20px;
657
- background: #f7fafc;
658
- border-radius: 12px;
659
- margin: 10px;
660
- }
661
- .template-selector {
662
- border: 2px solid #e2e8f0;
663
- border-radius: 12px;
664
  padding: 15px;
 
665
  background: #f8fafc;
 
666
  }
667
- .project-name-display {
668
- font-size: 1.5rem;
669
- font-weight: bold;
670
- text-align: center;
671
- padding: 15px;
672
- background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
673
- -webkit-background-clip: text;
674
- -webkit-text-fill-color: transparent;
675
- margin: 20px 0;
676
- }
677
- .template-badge {
678
  display: inline-block;
679
- padding: 3px 8px;
680
- border-radius: 4px;
681
- font-size: 0.75rem;
682
  font-weight: 600;
683
- margin-left: 8px;
684
- }
685
- .single-page-badge {
686
- background: #48bb78;
687
- color: white;
688
- }
689
- .multi-page-badge {
690
- background: #4299e1;
691
  color: white;
692
  }
693
  """) as iface:
694
 
695
  gr.Markdown(
696
  """
697
- # ๐ŸŽจ Vibe Coder AI - Professional Edition
698
- ### Create stunning websites with Tailwind CSS & AOS Animations
699
- Generate complete, production-ready websites with our AI team. Support for both single-page and multi-page projects!
700
 
701
- **๐Ÿš€ Features:** Tailwind CSS โ€ข AOS Animations โ€ข Static.photos Images โ€ข Semantic HTML5 โ€ข Multi-page Support โ€ข Auto ZIP Export
702
- **๐Ÿ–ผ๏ธ Images:** Professional placeholders from static.photos with 30+ categories
703
  """
704
  )
705
 
706
- # Template Selection Section
707
- with gr.Group(elem_classes="template-selector"):
708
- gr.Markdown("### ๐Ÿ“‹ Choose Your Project Type")
709
-
710
- use_template = gr.Radio(
711
- choices=["Use Template", "Custom Prompt"],
712
- value="Use Template",
713
- label="Selection Mode",
714
- interactive=True
715
- )
716
-
717
- template_dropdown = gr.Dropdown(
718
- choices=PROMPTS_FOR_AI,
719
- value=PROMPTS_FOR_AI[0],
720
- label="๐ŸŽฏ Select a Template (20 Single-Page | 10 Multi-Page)",
721
- interactive=True,
722
- visible=True
723
- )
724
-
725
- custom_prompt = gr.Textbox(
726
- lines=4,
727
- placeholder="Example: A minimalist portfolio website for a photographer with smooth animations and a gallery section. Single page design with modern layout.",
728
- label="โœ๏ธ Or Describe Your Custom Website",
729
- visible=False,
730
- elem_classes="container"
731
- )
732
-
733
- # Hidden project name display
734
- project_name_display = gr.Markdown(
735
- visible=False,
736
- elem_classes="project-name-display"
737
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
738
 
739
  with gr.Row():
740
  generate_btn = gr.Button(
741
  "๐Ÿš€ Generate Professional Website",
742
  variant="primary",
743
- size="lg",
744
- scale=1
745
- )
746
-
747
- with gr.Row():
748
- gr.Examples(
749
- examples=[
750
- ["๐ŸŽจ Portfolio - Minimalist designer portfolio with projects grid and contact form (Single Page)"],
751
- ["๐Ÿš€ SaaS Landing Page - Modern software startup with pricing cards and demo CTA (Single Page)"],
752
- ["๐Ÿ• Restaurant Landing - Menu showcase with reservations and location info (Single Page)"],
753
- ["๐Ÿ“š Course Landing - Online course sales page with curriculum and testimonials (Single Page)"],
754
- ["๐Ÿ›๏ธ E-commerce Platform - Full online store with products, cart, and checkout (Multi-Page)"],
755
- ],
756
- inputs=template_dropdown,
757
- label="๐Ÿ’ก Popular Templates"
758
- )
759
-
760
- with gr.Row():
761
- status_output = gr.Markdown(
762
- value="",
763
- label="Status",
764
- elem_classes="status-box"
765
  )
766
 
767
- with gr.Row():
768
- preview_output = gr.HTML(
769
- label="๐Ÿ–ฅ๏ธ Live Preview (with animations)",
770
- visible=True
771
- )
772
 
773
- with gr.Row():
774
- with gr.Column(scale=1):
775
- download_single = gr.File(
776
- label="๐Ÿ“ฅ Download Website (HTML)",
777
- visible=False,
778
- elem_classes="download-section"
779
- )
780
- with gr.Column(scale=1):
781
- download_zip = gr.File(
782
- label="๐Ÿ“ฆ Download Project (ZIP)",
783
- visible=False,
784
- elem_classes="download-section"
785
  )
786
- with gr.Column(scale=1):
787
- view_code_btn = gr.Button(
788
- "๐Ÿ‘๏ธ View Source Code",
789
- visible=False,
790
- variant="secondary"
791
  )
 
 
 
 
 
 
 
 
792
 
793
- # Hidden code display
794
  with gr.Row(visible=False) as code_row:
795
  code_output = gr.Code(
796
- label="๐Ÿ“„ Generated HTML Source Code (Tailwind CSS + AOS + Static.photos)",
797
  language="html",
798
- lines=15,
799
- elem_classes="container"
800
  )
801
 
802
- # Event handlers
803
- def toggle_input_mode(mode):
804
- if mode == "Use Template":
805
- return gr.update(visible=True), gr.update(visible=False)
806
- else:
807
- return gr.update(visible=False), gr.update(visible=True)
808
-
809
- use_template.change(
810
- fn=toggle_input_mode,
811
- inputs=[use_template],
812
- outputs=[template_dropdown, custom_prompt]
813
  )
814
 
815
- def generate_website(use_template_val, template_val, custom_val):
816
- # Determine which prompt to use
817
- if use_template_val == "Use Template":
818
- prompt = template_val
819
- is_template = True
820
- else:
821
- prompt = custom_val
822
- is_template = False
823
-
824
- status, preview, download_s, download_z, view_btn, project_name = run_crew(prompt, is_template)
825
-
826
- # Update project name display
827
- if project_name:
828
- project_display = gr.update(
829
- value=f"### {project_name}",
830
- visible=True
831
- )
832
- else:
833
- project_display = gr.update(visible=False)
834
-
835
  return (
836
- status,
837
- preview,
838
- download_s,
839
- download_z,
840
- view_btn,
841
- project_display
842
  )
843
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
844
  generate_btn.click(
845
  fn=generate_website,
846
- inputs=[use_template, template_dropdown, custom_prompt],
847
- outputs=[
848
- status_output,
849
- preview_output,
850
- download_single,
851
- download_zip,
852
- view_code_btn,
853
- project_name_display
854
- ]
855
  )
856
 
857
  view_code_btn.click(
858
  fn=lambda: (
859
- gr.update(visible=True),
860
- open("outputs/index.html", "r", encoding="utf-8").read() if os.path.exists("outputs/index.html") else open(glob.glob("outputs/*.html")[0], "r", encoding="utf-8").read() if glob.glob("outputs/*.html") else ""
861
  ),
862
- inputs=None,
863
  outputs=[code_row, code_output]
864
  )
865
 
866
  if __name__ == "__main__":
867
  print("\n" + "="*50)
868
- print("๐ŸŽจ Vibe Coder AI - Professional Edition")
869
  print("="*50)
870
- print("\nโœ… System initialized successfully!")
871
- print(f"๐Ÿ“‹ {len(PROMPTS_FOR_AI)} templates loaded (20 single-page, 10 multi-page)")
872
- print("๐Ÿ–ผ๏ธ Static.photos integration enabled")
873
- print("๐Ÿš€ Launching Gradio interface...\n")
874
 
875
  iface.launch(share=False)
 
7
  import shutil
8
  import glob
9
  import json
10
+ from datetime import datetime
11
 
12
  load_dotenv()
13
 
14
+ # --- WEBSITE TYPE SYSTEM DEFINITIONS ---
15
+ WEBSITE_TYPES = {
16
+ "SaaS Platform": {
17
+ "emoji": "๐Ÿš€",
18
+ "description": "Software as a Service platform website",
19
+ "pages": {
20
+ "single": ["Landing Page"],
21
+ "multi": ["Home", "Features", "Pricing", "About", "Blog", "Contact", "Login/Signup"]
22
+ },
23
+ "sections": {
24
+ "Hero": "Value proposition with clear CTA for free trial",
25
+ "Features": "Key features with icons and descriptions",
26
+ "How It Works": "3-step process visualization",
27
+ "Pricing": "Tiered pricing cards with feature comparison",
28
+ "Testimonials": "Customer success stories with metrics",
29
+ "Integration": "Logos of integrated platforms",
30
+ "FAQ": "Common questions addressed",
31
+ "CTA": "Final conversion section with trial offer"
32
+ },
33
+ "color_scheme": {
34
+ "primary": "#4F46E5", # Indigo
35
+ "secondary": "#06B6D4", # Cyan
36
+ "accent": "#10B981", # Emerald
37
+ "background": "#FFFFFF",
38
+ "text": "#1F2937",
39
+ "muted": "#6B7280"
40
+ },
41
+ "design_style": "Modern, clean, professional with subtle gradients",
42
+ "fonts": {
43
+ "heading": "Inter",
44
+ "body": "Inter"
45
+ },
46
+ "must_have_elements": [
47
+ "Sticky navigation with CTA button",
48
+ "Animated feature cards",
49
+ "Pricing toggle (monthly/yearly)",
50
+ "Trust badges and security icons",
51
+ "Live chat widget placeholder",
52
+ "Cookie consent banner"
53
+ ]
54
+ },
55
+
56
+ "E-commerce Store": {
57
+ "emoji": "๐Ÿ›๏ธ",
58
+ "description": "Online shopping platform",
59
+ "pages": {
60
+ "single": ["Product Showcase"],
61
+ "multi": ["Home", "Shop", "Product Details", "Cart", "Checkout", "Account", "About", "Contact"]
62
+ },
63
+ "sections": {
64
+ "Hero": "Featured products carousel with offers",
65
+ "Categories": "Product categories grid",
66
+ "Featured Products": "Best sellers and new arrivals",
67
+ "Deals": "Special offers and discounts",
68
+ "Benefits": "Free shipping, returns, security",
69
+ "Newsletter": "Email subscription for deals",
70
+ "Reviews": "Customer testimonials",
71
+ "Brands": "Partner brand logos"
72
+ },
73
+ "color_scheme": {
74
+ "primary": "#DC2626", # Red
75
+ "secondary": "#F59E0B", # Amber
76
+ "accent": "#10B981", # Green for CTAs
77
+ "background": "#FFFFFF",
78
+ "text": "#111827",
79
+ "muted": "#6B7280"
80
+ },
81
+ "design_style": "Clean, product-focused with high-quality imagery",
82
+ "fonts": {
83
+ "heading": "Poppins",
84
+ "body": "Open Sans"
85
+ },
86
+ "must_have_elements": [
87
+ "Shopping cart icon with counter",
88
+ "Search bar with filters",
89
+ "Product quick view modals",
90
+ "Wishlist functionality",
91
+ "Product image zoom",
92
+ "Rating stars",
93
+ "Size/color selectors",
94
+ "Secure payment badges"
95
+ ]
96
+ },
97
+
98
+ "Portfolio/Creative": {
99
+ "emoji": "๐ŸŽจ",
100
+ "description": "Creative professional or agency portfolio",
101
+ "pages": {
102
+ "single": ["Portfolio Showcase"],
103
+ "multi": ["Home", "Portfolio", "About", "Services", "Process", "Contact"]
104
+ },
105
+ "sections": {
106
+ "Hero": "Creative statement with animated text",
107
+ "Work": "Portfolio grid with hover effects",
108
+ "About": "Story and expertise",
109
+ "Services": "What we offer",
110
+ "Process": "Creative workflow",
111
+ "Clients": "Client logos and testimonials",
112
+ "Awards": "Recognition and achievements",
113
+ "Contact": "Get in touch form"
114
+ },
115
+ "color_scheme": {
116
+ "primary": "#000000",
117
+ "secondary": "#FFFFFF",
118
+ "accent": "#FF6B6B",
119
+ "background": "#FAFAFA",
120
+ "text": "#1A1A1A",
121
+ "muted": "#666666"
122
+ },
123
+ "design_style": "Bold, minimalist, typography-focused with creative layouts",
124
+ "fonts": {
125
+ "heading": "Playfair Display",
126
+ "body": "Roboto"
127
+ },
128
+ "must_have_elements": [
129
+ "Masonry or grid portfolio layout",
130
+ "Smooth scroll animations",
131
+ "Before/after sliders",
132
+ "Video backgrounds",
133
+ "Parallax effects",
134
+ "Custom cursor",
135
+ "Loading animation",
136
+ "Social media links"
137
+ ]
138
+ },
139
+
140
+ "Corporate/Business": {
141
+ "emoji": "๐Ÿข",
142
+ "description": "Professional business or corporate website",
143
+ "pages": {
144
+ "single": ["Company Overview"],
145
+ "multi": ["Home", "About", "Services", "Industries", "Case Studies", "Team", "Careers", "Contact"]
146
+ },
147
+ "sections": {
148
+ "Hero": "Company vision with professional imagery",
149
+ "Services": "Core service offerings",
150
+ "About": "Company history and values",
151
+ "Statistics": "Key metrics and achievements",
152
+ "Industries": "Sectors served",
153
+ "Team": "Leadership profiles",
154
+ "Partners": "Strategic partnerships",
155
+ "News": "Latest updates and press"
156
+ },
157
+ "color_scheme": {
158
+ "primary": "#1E40AF", # Blue
159
+ "secondary": "#0F766E", # Teal
160
+ "accent": "#F59E0B", # Amber
161
+ "background": "#FFFFFF",
162
+ "text": "#1F2937",
163
+ "muted": "#6B7280"
164
+ },
165
+ "design_style": "Professional, trustworthy, clean with structured layouts",
166
+ "fonts": {
167
+ "heading": "Montserrat",
168
+ "body": "Source Sans Pro"
169
+ },
170
+ "must_have_elements": [
171
+ "Professional navigation",
172
+ "Dropdown menus",
173
+ "Team member cards",
174
+ "Timeline components",
175
+ "Statistics counters",
176
+ "Certificate badges",
177
+ "Newsletter signup",
178
+ "Office locations map"
179
+ ]
180
+ },
181
+
182
+ "Restaurant/Food": {
183
+ "emoji": "๐Ÿ•",
184
+ "description": "Restaurant, cafe, or food service website",
185
+ "pages": {
186
+ "single": ["Restaurant Landing"],
187
+ "multi": ["Home", "Menu", "About", "Gallery", "Reservations", "Events", "Contact"]
188
+ },
189
+ "sections": {
190
+ "Hero": "Appetizing hero with reservation CTA",
191
+ "Menu Preview": "Featured dishes showcase",
192
+ "About": "Our story and chef",
193
+ "Specials": "Daily specials and offers",
194
+ "Gallery": "Food and ambiance photos",
195
+ "Testimonials": "Customer reviews",
196
+ "Hours": "Opening hours and location",
197
+ "Reservation": "Table booking form"
198
+ },
199
+ "color_scheme": {
200
+ "primary": "#DC2626", # Red
201
+ "secondary": "#854D0E", # Brown
202
+ "accent": "#16A34A", # Green
203
+ "background": "#FEF3C7",
204
+ "text": "#1F2937",
205
+ "muted": "#78716C"
206
+ },
207
+ "design_style": "Warm, inviting, appetizing with rich imagery",
208
+ "fonts": {
209
+ "heading": "Merriweather",
210
+ "body": "Open Sans"
211
+ },
212
+ "must_have_elements": [
213
+ "Menu with prices",
214
+ "Online reservation system",
215
+ "Photo gallery",
216
+ "Google Maps integration",
217
+ "Social media feed",
218
+ "Special offers banner",
219
+ "Delivery/takeout options",
220
+ "Customer reviews"
221
+ ]
222
+ },
223
+
224
+ "Healthcare/Medical": {
225
+ "emoji": "๐Ÿฅ",
226
+ "description": "Medical, healthcare, or wellness website",
227
+ "pages": {
228
+ "single": ["Clinic Overview"],
229
+ "multi": ["Home", "Services", "Doctors", "Appointments", "Patient Portal", "Resources", "About", "Contact"]
230
+ },
231
+ "sections": {
232
+ "Hero": "Welcome with appointment booking",
233
+ "Services": "Medical services offered",
234
+ "Doctors": "Medical team profiles",
235
+ "Why Choose Us": "Credentials and approach",
236
+ "Testimonials": "Patient stories",
237
+ "Insurance": "Accepted providers",
238
+ "Resources": "Health tips and articles",
239
+ "Emergency": "Emergency contact info"
240
+ },
241
+ "color_scheme": {
242
+ "primary": "#0891B2", # Cyan
243
+ "secondary": "#10B981", # Green
244
+ "accent": "#3B82F6", # Blue
245
+ "background": "#F0FDFA",
246
+ "text": "#0F172A",
247
+ "muted": "#64748B"
248
+ },
249
+ "design_style": "Clean, professional, trustworthy with calming colors",
250
+ "fonts": {
251
+ "heading": "Nunito Sans",
252
+ "body": "Open Sans"
253
+ },
254
+ "must_have_elements": [
255
+ "Appointment booking system",
256
+ "Doctor profiles with credentials",
257
+ "Service descriptions",
258
+ "Patient portal login",
259
+ "Insurance information",
260
+ "Emergency contacts",
261
+ "Health resources/blog",
262
+ "HIPAA compliance notice"
263
+ ]
264
+ },
265
+
266
+ "Education/E-learning": {
267
+ "emoji": "๐ŸŽ“",
268
+ "description": "Educational institution or online learning platform",
269
+ "pages": {
270
+ "single": ["Course Landing"],
271
+ "multi": ["Home", "Courses", "Programs", "Instructors", "Resources", "Student Portal", "About", "Contact"]
272
+ },
273
+ "sections": {
274
+ "Hero": "Learn and grow message with enrollment CTA",
275
+ "Courses": "Popular courses grid",
276
+ "Features": "Learning platform benefits",
277
+ "Instructors": "Expert teacher profiles",
278
+ "Testimonials": "Student success stories",
279
+ "Stats": "Graduation and success rates",
280
+ "Process": "How to get started",
281
+ "FAQ": "Common questions"
282
+ },
283
+ "color_scheme": {
284
+ "primary": "#7C3AED", # Purple
285
+ "secondary": "#2563EB", # Blue
286
+ "accent": "#F59E0B", # Amber
287
+ "background": "#FAFAF9",
288
+ "text": "#18181B",
289
+ "muted": "#71717A"
290
+ },
291
+ "design_style": "Modern, engaging, accessible with clear information hierarchy",
292
+ "fonts": {
293
+ "heading": "Raleway",
294
+ "body": "Inter"
295
+ },
296
+ "must_have_elements": [
297
+ "Course catalog with filters",
298
+ "Enrollment/registration forms",
299
+ "Student dashboard mockup",
300
+ "Video player placeholder",
301
+ "Progress indicators",
302
+ "Certificate badges",
303
+ "Calendar/schedule",
304
+ "Resource library"
305
+ ]
306
+ },
307
+
308
+ "Real Estate": {
309
+ "emoji": "๐Ÿ ",
310
+ "description": "Real estate agency or property listing website",
311
+ "pages": {
312
+ "single": ["Property Showcase"],
313
+ "multi": ["Home", "Properties", "Property Details", "Agents", "Services", "About", "Contact"]
314
+ },
315
+ "sections": {
316
+ "Hero": "Property search with filters",
317
+ "Featured": "Featured properties carousel",
318
+ "Search": "Advanced search options",
319
+ "Services": "Buying, selling, renting",
320
+ "Agents": "Team of realtors",
321
+ "Testimonials": "Client experiences",
322
+ "Market": "Market trends and insights",
323
+ "Contact": "Schedule viewing"
324
+ },
325
+ "color_scheme": {
326
+ "primary": "#0F766E", # Teal
327
+ "secondary": "#B45309", # Brown
328
+ "accent": "#3B82F6", # Blue
329
+ "background": "#FFFFFF",
330
+ "text": "#1F2937",
331
+ "muted": "#6B7280"
332
+ },
333
+ "design_style": "Professional, clean, image-heavy with property showcases",
334
+ "fonts": {
335
+ "heading": "Playfair Display",
336
+ "body": "Source Sans Pro"
337
+ },
338
+ "must_have_elements": [
339
+ "Property search with filters",
340
+ "Property cards with details",
341
+ "Image galleries",
342
+ "Virtual tour buttons",
343
+ "Mortgage calculator",
344
+ "Agent contact cards",
345
+ "Map integration",
346
+ "Property comparison tool"
347
+ ]
348
+ },
349
+
350
+ "Fitness/Gym": {
351
+ "emoji": "๐Ÿ‹๏ธ",
352
+ "description": "Gym, fitness center, or personal training website",
353
+ "pages": {
354
+ "single": ["Fitness Landing"],
355
+ "multi": ["Home", "Classes", "Trainers", "Membership", "Schedule", "Blog", "Contact"]
356
+ },
357
+ "sections": {
358
+ "Hero": "Transform your body message with join CTA",
359
+ "Classes": "Class types and schedules",
360
+ "Trainers": "Expert trainer profiles",
361
+ "Membership": "Pricing plans",
362
+ "Transformation": "Before/after gallery",
363
+ "Features": "Gym facilities and equipment",
364
+ "Schedule": "Class timetable",
365
+ "Blog": "Fitness tips and nutrition"
366
+ },
367
+ "color_scheme": {
368
+ "primary": "#DC2626", # Red
369
+ "secondary": "#000000", # Black
370
+ "accent": "#22C55E", # Green
371
+ "background": "#FAFAFA",
372
+ "text": "#171717",
373
+ "muted": "#525252"
374
+ },
375
+ "design_style": "Energetic, bold, motivational with dynamic imagery",
376
+ "fonts": {
377
+ "heading": "Bebas Neue",
378
+ "body": "Roboto"
379
+ },
380
+ "must_have_elements": [
381
+ "Class schedule/timetable",
382
+ "Membership pricing cards",
383
+ "Trainer profiles",
384
+ "Transformation gallery",
385
+ "Class booking system",
386
+ "Nutrition tips section",
387
+ "BMI calculator",
388
+ "Free trial CTA"
389
+ ]
390
+ },
391
+
392
+ "Technology/Startup": {
393
+ "emoji": "๐Ÿ’ก",
394
+ "description": "Tech startup or innovation company website",
395
+ "pages": {
396
+ "single": ["Startup Landing"],
397
+ "multi": ["Home", "Product", "Solutions", "Technology", "Company", "Blog", "Contact"]
398
+ },
399
+ "sections": {
400
+ "Hero": "Innovation message with demo request",
401
+ "Problem/Solution": "What we solve",
402
+ "Product": "Product features showcase",
403
+ "Technology": "Our tech stack",
404
+ "Partners": "Integration partners",
405
+ "Team": "Founding team",
406
+ "Investors": "Backed by",
407
+ "Press": "Media mentions"
408
+ },
409
+ "color_scheme": {
410
+ "primary": "#8B5CF6", # Purple
411
+ "secondary": "#3B82F6", # Blue
412
+ "accent": "#10B981", # Green
413
+ "background": "#0F0F1E",
414
+ "text": "#FFFFFF",
415
+ "muted": "#9CA3AF"
416
+ },
417
+ "design_style": "Futuristic, gradient-heavy, dark mode with neon accents",
418
+ "fonts": {
419
+ "heading": "Space Grotesk",
420
+ "body": "Inter"
421
+ },
422
+ "must_have_elements": [
423
+ "Animated hero section",
424
+ "Interactive product demo",
425
+ "Tech stack icons",
426
+ "Gradient backgrounds",
427
+ "Particle effects",
428
+ "Timeline roadmap",
429
+ "API documentation link",
430
+ "Developer resources"
431
+ ]
432
+ }
433
+ }
434
 
435
+ # --- ENHANCED PROMPTS ---
436
+ ENHANCED_IMAGE_PROMPT = """
437
+ Image Guidelines for {website_type}:
438
 
439
+ Use static.photos service with appropriate categories:
440
+ - {category_suggestions}
441
 
442
+ Recommended dimensions:
443
+ - Hero: 1200x630
444
+ - Features: 640x360
445
+ - Testimonials: 200x200
446
+ - Gallery: 640x360
447
+ - Icons: 200x200
 
 
448
 
449
+ Example URLs:
450
+ {example_urls}
 
 
 
 
 
451
 
452
+ Match images to the {design_style} style.
 
 
 
 
 
 
 
453
  """
454
 
455
+ PROJECT_CONTEXT_PROMPT = """
456
+ You are creating a {website_type} website with the following specifications:
457
+
458
+ Project Name: {project_name}
459
+ Type: {page_type}
460
+ Style: {design_style}
461
+ Primary Purpose: {description}
462
+
463
+ Color Palette:
464
+ {color_details}
465
+
466
+ Typography:
467
+ - Headings: {heading_font}
468
+ - Body: {body_font}
469
+
470
+ Required Sections:
471
+ {sections}
472
+
473
+ Must-Have Elements:
474
+ {must_have_elements}
475
+
476
+ Target Audience: {target_audience}
477
  """
478
 
479
+ # --- SYSTEM SETUP ---
480
  try:
481
  llm = LLM(
482
  model="gemini/gemini-2.0-flash-exp",
483
+ temperature=0.7,
484
  api_key=os.environ.get("GOOGLE_API_KEY")
485
  )
486
  except Exception as e:
487
+ print(f"Error initializing Gemini LLM: {e}")
 
 
 
488
  llm = None
489
 
 
490
  os.makedirs("outputs", exist_ok=True)
491
  file_write_tool = FileWriterTool()
492
 
493
+ # --- ENHANCED AGENTS ---
494
  designer = Agent(
495
+ role='Senior Design Systems Architect',
496
+ goal='Create comprehensive design systems tailored to specific website types',
497
+ backstory=(
498
+ "You are a design systems expert who specializes in creating cohesive, "
499
+ "type-specific design languages. You understand that different website types "
500
+ "have distinct requirements:\n\n"
501
+ "- SaaS needs trust indicators and clear value props\n"
502
+ "- E-commerce requires product focus and purchase flow\n"
503
+ "- Portfolio demands creative expression\n"
504
+ "- Corporate needs professionalism and structure\n\n"
505
+ "You always consider:\n"
506
+ "- Industry-specific design patterns\n"
507
+ "- User expectations for each website type\n"
508
+ "- Conversion optimization for the specific goal\n"
509
+ "- Accessibility and performance\n"
510
+ "- Mobile-first responsive design\n\n"
511
+ "You create detailed design tokens including:\n"
512
+ "- Precise color values with semantic naming\n"
513
+ "- Typography scales with exact sizes\n"
514
+ "- Spacing systems (4px/8px grid)\n"
515
+ "- Component specifications\n"
516
+ "- Animation timings and easings"
517
+ ),
518
+ verbose=True,
519
+ llm=llm,
520
+ allow_delegation=False
521
  )
522
 
523
  copywriter = Agent(
524
+ role='Conversion Copywriter & Content Strategist',
525
+ goal='Write compelling, type-specific copy that converts visitors into customers',
526
+ backstory=(
527
+ "You are a conversion-focused copywriter who understands that different "
528
+ "website types require different voices and messaging strategies:\n\n"
529
+ "- SaaS: Focus on benefits, ROI, and problem-solving\n"
530
+ "- E-commerce: Product benefits, urgency, and trust\n"
531
+ "- Portfolio: Creativity, expertise, and personality\n"
532
+ "- Corporate: Authority, reliability, and professionalism\n"
533
+ "- Healthcare: Empathy, trust, and expertise\n\n"
534
+ "You craft:\n"
535
+ "- Headlines that grab attention\n"
536
+ "- Subheadings that maintain interest\n"
537
+ "- CTAs that drive action\n"
538
+ "- Microcopy that guides users\n"
539
+ "- SEO-optimized content\n\n"
540
+ "You always match tone to the target audience and industry expectations."
541
+ ),
542
+ verbose=True,
543
+ llm=llm,
544
+ allow_delegation=False
 
545
  )
546
 
547
  developer = Agent(
548
+ role='Full-Stack Frontend Developer',
549
+ goal='Build pixel-perfect, performant websites tailored to specific industries',
550
+ backstory=(
551
+ "You are an expert frontend developer who specializes in building "
552
+ "industry-specific websites with modern technologies:\n\n"
553
+ "**Technical Expertise:**\n"
554
+ "- Tailwind CSS for rapid, consistent styling\n"
555
+ "- Custom CSS for unique requirements\n"
556
+ "- JavaScript for interactivity\n"
557
+ "- AOS for scroll animations\n"
558
+ "- Performance optimization\n\n"
559
+ "**Industry-Specific Knowledge:**\n"
560
+ "- SaaS: Pricing toggles, feature comparisons, dashboards\n"
561
+ "- E-commerce: Product grids, cart functionality, filters\n"
562
+ "- Portfolio: Galleries, sliders, creative layouts\n"
563
+ "- Corporate: Professional navigation, team sections\n"
564
+ "- Healthcare: Appointment forms, service listings\n\n"
565
+ "You always implement:\n"
566
+ "- Semantic HTML5\n"
567
+ "- ARIA labels for accessibility\n"
568
+ "- Responsive design (mobile-first)\n"
569
+ "- SEO best practices\n"
570
+ "- Performance optimizations\n"
571
+ "- Cross-browser compatibility"
572
+ ),
573
+ verbose=True,
574
+ llm=llm,
575
+ tools=[file_write_tool],
576
+ allow_delegation=False
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
577
  )
578
 
579
+ # --- ENHANCED TASK CREATION ---
580
+ def create_design_task(website_type, project_name, custom_requirements, page_type):
581
+ """Create a design task specific to the website type"""
582
+
583
+ type_config = WEBSITE_TYPES[website_type]
584
+
585
+ # Build context
586
+ context = PROJECT_CONTEXT_PROMPT.format(
587
+ website_type=website_type,
588
+ project_name=project_name,
589
+ page_type=page_type,
590
+ design_style=type_config["design_style"],
591
+ description=type_config["description"],
592
+ color_details=json.dumps(type_config["color_scheme"], indent=2),
593
+ heading_font=type_config["fonts"]["heading"],
594
+ body_font=type_config["fonts"]["body"],
595
+ sections=json.dumps(type_config["sections"], indent=2),
596
+ must_have_elements="\n".join(f"- {elem}" for elem in type_config["must_have_elements"]),
597
+ target_audience=f"Target audience for {website_type}"
598
+ )
599
+
600
+ # Build image guidelines
601
+ category_map = {
602
+ "SaaS Platform": "technology, office, abstract, gradient",
603
+ "E-commerce Store": "retail, product, lifestyle, fashion",
604
+ "Portfolio/Creative": "abstract, minimal, artistic, workspace",
605
+ "Corporate/Business": "office, business, professional, cityscape",
606
+ "Restaurant/Food": "food, restaurant, culinary, ambiance",
607
+ "Healthcare/Medical": "medical, wellness, healthcare, people",
608
+ "Education/E-learning": "education, study, classroom, books",
609
+ "Real Estate": "estate, architecture, interior, exterior",
610
+ "Fitness/Gym": "fitness, sport, gym, wellness",
611
+ "Technology/Startup": "technology, innovation, abstract, futuristic"
612
+ }
613
+
614
+ image_guidelines = ENHANCED_IMAGE_PROMPT.format(
615
+ website_type=website_type,
616
+ category_suggestions=category_map.get(website_type, "abstract, gradient"),
617
+ design_style=type_config["design_style"],
618
+ example_urls="\n".join([
619
+ f"- Hero: http://static.photos/{category_map.get(website_type, 'abstract').split(',')[0].strip()}/1200x630/100",
620
+ f"- Features: http://static.photos/{category_map.get(website_type, 'abstract').split(',')[0].strip()}/640x360/200",
621
+ f"- Team: http://static.photos/people/200x200/300"
622
+ ])
623
+ )
624
+
625
+ return Task(
626
+ description=(
627
+ f"{context}\n\n"
628
+ f"Additional Requirements from User:\n{custom_requirements}\n\n"
629
+ f"{image_guidelines}\n\n"
630
+ "Create a comprehensive Design System that includes:\n"
631
+ "1. Complete color palette with exact hex codes\n"
632
+ "2. Typography system with sizes and weights\n"
633
+ "3. Spacing and grid system\n"
634
+ "4. Component specifications\n"
635
+ "5. Animation guidelines\n"
636
+ "6. Image URLs using static.photos\n"
637
+ "7. Layout structure for all sections\n"
638
+ "8. Responsive breakpoints\n"
639
+ "9. Interaction patterns\n"
640
+ "10. Accessibility requirements"
641
+ ),
642
+ expected_output=(
643
+ "A detailed Design System document in markdown format with:\n"
644
+ "- All specifications clearly defined\n"
645
+ "- Exact measurements and values\n"
646
+ "- Static.photos URLs for all images\n"
647
+ "- Component states and variations\n"
648
+ "- Clear implementation guidelines"
649
+ ),
650
+ agent=designer
651
+ )
652
 
653
+ def create_copywriting_task(website_type, project_name):
654
+ """Create a copywriting task specific to the website type"""
655
+
656
+ type_config = WEBSITE_TYPES[website_type]
657
+
658
+ return Task(
659
+ description=(
660
+ f"Write compelling copy for a {website_type} called '{project_name}'.\n\n"
661
+ f"Website Sections:\n{json.dumps(type_config['sections'], indent=2)}\n\n"
662
+ "For each section, provide:\n"
663
+ "- Headlines (powerful, benefit-focused)\n"
664
+ "- Subheadlines (supporting, clarifying)\n"
665
+ "- Body copy (clear, engaging)\n"
666
+ "- CTAs (action-oriented)\n"
667
+ "- Microcopy (helpful, guiding)\n\n"
668
+ f"Match the tone to {website_type} expectations.\n"
669
+ "Include industry-specific terminology and benefits."
670
+ ),
671
+ expected_output=(
672
+ "Complete website copy in markdown format with:\n"
673
+ "- All sections populated with relevant content\n"
674
+ "- Consistent brand voice throughout\n"
675
+ "- SEO-optimized headlines\n"
676
+ "- Clear CTAs for each section\n"
677
+ "- Professional, polished copy"
678
+ ),
679
+ agent=copywriter
680
+ )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
681
 
682
+ def create_development_task(website_type, page_type):
683
+ """Create a development task specific to the website type"""
684
+
685
+ type_config = WEBSITE_TYPES[website_type]
686
+ pages = type_config["pages"]["multi" if page_type == "Multi-Page" else "single"]
687
+
688
+ return Task(
689
+ description=(
690
+ f"Build a complete {website_type} website.\n\n"
691
+ f"Pages to create: {', '.join(pages)}\n"
692
+ f"Must-have elements: {', '.join(type_config['must_have_elements'])}\n\n"
693
+ "Technical Requirements:\n"
694
+ "- Use Tailwind CSS via CDN\n"
695
+ "- Implement AOS animations\n"
696
+ "- Use static.photos for all images\n"
697
+ "- Create responsive layouts\n"
698
+ "- Add interactive elements\n"
699
+ "- Implement smooth scrolling\n"
700
+ "- Add hover effects\n"
701
+ "- Include mobile menu\n\n"
702
+ f"Save files to 'outputs/' directory:\n"
703
+ f"- {'index.html' if page_type == 'Single-Page' else 'Multiple HTML files'}"
704
+ ),
705
+ expected_output=(
706
+ "Complete, production-ready HTML files that:\n"
707
+ "- Implement the exact design system\n"
708
+ "- Use all specified copy\n"
709
+ "- Include all required elements\n"
710
+ "- Are fully responsive\n"
711
+ "- Have smooth animations\n"
712
+ "- Work in all browsers"
713
+ ),
714
+ agent=developer,
715
+ tools=[file_write_tool]
716
+ )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
717
 
718
+ # --- CHAT HISTORY MANAGEMENT ---
719
+ class ChatHistory:
720
+ def __init__(self):
721
+ self.history = []
722
+ self.current_project = None
723
+ self.website_type = None
724
+ self.project_name = None
725
+
726
+ def add_message(self, role, content):
727
+ self.history.append({
728
+ "role": role,
729
+ "content": content,
730
+ "timestamp": datetime.now().isoformat()
731
+ })
732
+
733
+ def get_context(self):
734
+ if not self.history:
735
+ return ""
736
+ return "\n".join([f"{msg['role']}: {msg['content']}" for msg in self.history[-5:]])
737
+
738
+ def reset(self):
739
+ self.history = []
740
+ self.current_project = None
741
+ self.website_type = None
742
+ self.project_name = None
743
 
744
+ chat_history = ChatHistory()
745
+
746
+ # --- HELPER FUNCTIONS ---
747
  def clean_outputs_directory():
748
+ """Clean the outputs directory"""
749
  if os.path.exists("outputs"):
750
  for file in glob.glob("outputs/*"):
751
  try:
 
754
  print(f"Error removing {file}: {e}")
755
 
756
  def create_zip_archive():
757
+ """Create a ZIP archive of output files"""
758
  try:
 
759
  html_files = glob.glob("outputs/*.html")
 
760
  if len(html_files) > 1:
 
761
  shutil.make_archive("outputs/project", 'zip', "outputs")
762
  return "outputs/project.zip"
763
  return None
 
765
  print(f"Error creating ZIP: {e}")
766
  return None
767
 
768
+ # --- MAIN GENERATION FUNCTION ---
769
+ def generate_website(website_type, project_name_input, name_method, page_type, custom_requirements, is_modification=False):
 
 
 
 
 
 
 
 
 
 
 
 
 
770
  try:
771
  if llm is None:
772
  return (
773
+ "โŒ **Error:** Gemini LLM not initialized. Please check your GOOGLE_API_KEY.",
774
+ None, gr.update(visible=False), gr.update(visible=False), gr.update(visible=False)
 
 
 
 
775
  )
776
 
777
+ # Handle project name
778
+ if name_method == "Enter manually":
779
+ project_name = project_name_input if project_name_input else "My Project"
 
 
780
  else:
781
+ # Generate project name with AI
782
+ project_name = f"{WEBSITE_TYPES[website_type]['emoji']} {website_type.split('/')[0]} Pro"
783
+
784
+ # Store in chat history
785
+ if not is_modification:
786
+ chat_history.reset()
787
+ chat_history.website_type = website_type
788
+ chat_history.project_name = project_name
789
 
790
+ chat_history.add_message("User", f"Generate {website_type} - {page_type}")
791
+
792
+ # Clean outputs
793
  clean_outputs_directory()
794
 
795
+ # Create tasks
796
+ design_task = create_design_task(website_type, project_name, custom_requirements, page_type)
797
+ copywriting_task = create_copywriting_task(website_type, project_name)
798
+ copywriting_task.context = [design_task]
799
+ development_task = create_development_task(website_type, page_type)
800
+ development_task.context = [design_task, copywriting_task]
801
 
802
+ # Create and run crew
803
+ crew = Crew(
804
+ agents=[designer, copywriter, developer],
805
+ tasks=[design_task, copywriting_task, development_task],
806
+ process=Process.sequential,
807
+ verbose=True
808
+ )
809
 
810
+ result = crew.kickoff()
 
 
811
 
812
+ # Check output files
813
  html_files = glob.glob("outputs/*.html")
 
814
  if not html_files:
815
  return (
816
+ "โŒ No files generated. Please try again.",
817
+ None, gr.update(visible=False), gr.update(visible=False), gr.update(visible=False)
 
 
 
 
818
  )
819
 
820
+ # Create preview
 
 
 
821
  preview_file = "outputs/index.html" if os.path.exists("outputs/index.html") else html_files[0]
822
  with open(preview_file, "r", encoding="utf-8") as file:
823
  html_content = file.read()
824
 
825
  preview_html = f'<iframe srcdoc="{html_content.replace(chr(34), "&quot;")}" width="100%" height="800px" style="border: 2px solid #e0e0e0; border-radius: 8px;"></iframe>'
826
 
827
+ # Prepare response
828
+ is_multipage = len(html_files) > 1
829
+ success_message = f"โœ… **{project_name}** generated successfully!\n"
830
+ success_message += f"Type: {website_type} | Pages: {len(html_files)}"
831
+
832
+ chat_history.add_message("System", f"Generated {project_name}")
833
+
834
  if is_multipage:
 
 
 
 
835
  zip_path = create_zip_archive()
836
+ return (
837
+ success_message,
838
+ preview_html,
839
+ gr.update(value=preview_file, visible=True),
840
+ gr.update(value=zip_path, visible=True) if zip_path else gr.update(visible=False),
841
+ gr.update(visible=True)
842
+ )
 
 
843
  else:
 
844
  return (
845
  success_message,
846
  preview_html,
847
+ gr.update(value=preview_file, visible=True),
848
  gr.update(visible=False),
849
+ gr.update(visible=True)
 
850
  )
851
+
852
  except Exception as e:
853
  error_trace = traceback.format_exc()
 
854
  print(error_trace)
855
  return (
856
+ f"โŒ Error: {str(e)}",
857
+ None, gr.update(visible=False), gr.update(visible=False), gr.update(visible=False)
 
 
 
 
858
  )
859
 
860
+ def modify_website(modification_request):
861
+ """Modify the existing website based on user request"""
862
+ if not chat_history.current_project:
863
+ return "โŒ Please generate a website first before requesting modifications."
864
+
865
+ chat_history.add_message("User", modification_request)
866
+
867
+ # Create modification task
868
+ modification_task = Task(
869
+ description=(
870
+ f"Modify the existing {chat_history.website_type} website.\n\n"
871
+ f"Previous context:\n{chat_history.get_context()}\n\n"
872
+ f"Modification request: {modification_request}\n\n"
873
+ "Update the HTML files accordingly."
874
+ ),
875
+ expected_output="Modified HTML files with requested changes",
876
+ agent=developer,
877
+ tools=[file_write_tool]
878
+ )
879
+
880
+ crew = Crew(
881
+ agents=[developer],
882
+ tasks=[modification_task],
883
+ process=Process.sequential
884
+ )
885
+
886
+ try:
887
+ result = crew.kickoff()
888
+ chat_history.add_message("System", f"Modified: {modification_request[:50]}...")
889
+ return "โœ… Modifications applied successfully!"
890
+ except Exception as e:
891
+ return f"โŒ Error applying modifications: {str(e)}"
892
+
893
+ # --- GRADIO INTERFACE ---
894
  with gr.Blocks(theme=gr.themes.Soft(), css="""
895
  .container { max-width: 1400px; margin: auto; }
896
+ .type-card {
897
+ border: 2px solid #e2e8f0;
898
+ border-radius: 12px;
899
+ padding: 15px;
900
+ margin: 10px 0;
901
+ background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
902
+ cursor: pointer;
903
+ transition: all 0.3s ease;
904
+ }
905
+ .type-card:hover {
906
+ transform: translateY(-2px);
907
+ box-shadow: 0 8px 20px rgba(0,0,0,0.1);
908
+ border-color: #4F46E5;
909
+ }
910
+ .type-title {
911
+ font-size: 1.2rem;
912
+ font-weight: 600;
913
+ color: #1a202c;
914
+ margin-bottom: 8px;
915
+ }
916
+ .type-description {
917
+ color: #4a5568;
918
+ font-size: 0.9rem;
919
+ }
920
  .status-box {
921
  padding: 20px;
922
  border-radius: 12px;
 
925
  color: white;
926
  font-weight: 500;
927
  }
928
+ .chat-box {
929
+ border: 1px solid #e2e8f0;
930
+ border-radius: 8px;
 
 
 
 
 
 
 
931
  padding: 15px;
932
+ margin: 10px 0;
933
  background: #f8fafc;
934
+ min-height: 100px;
935
  }
936
+ .feature-badge {
 
 
 
 
 
 
 
 
 
 
937
  display: inline-block;
938
+ padding: 4px 12px;
939
+ border-radius: 20px;
940
+ font-size: 0.85rem;
941
  font-weight: 600;
942
+ margin: 4px;
943
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
 
 
 
 
 
 
944
  color: white;
945
  }
946
  """) as iface:
947
 
948
  gr.Markdown(
949
  """
950
+ # ๐Ÿš€ Professional Website Builder AI
951
+ ### Industry-Specific Website Generation with Tailwind CSS & Modern Animations
 
952
 
953
+ Generate complete, production-ready websites tailored to your industry with our specialized AI team.
954
+ Each website type comes with industry-specific components, design patterns, and content.
955
  """
956
  )
957
 
958
+ with gr.Row():
959
+ with gr.Column(scale=1):
960
+ gr.Markdown("### ๐ŸŽฏ Step 1: Choose Website Type")
961
+
962
+ website_type = gr.Radio(
963
+ choices=list(WEBSITE_TYPES.keys()),
964
+ value="SaaS Platform",
965
+ label="Select Industry/Type",
966
+ interactive=True
967
+ )
968
+
969
+ # Display type details
970
+ with gr.Box():
971
+ type_details = gr.Markdown(
972
+ value=f"**{WEBSITE_TYPES['SaaS Platform']['description']}**\n\n"
973
+ f"Design Style: {WEBSITE_TYPES['SaaS Platform']['design_style']}\n\n"
974
+ f"Key Elements: {', '.join(WEBSITE_TYPES['SaaS Platform']['must_have_elements'][:3])}..."
975
+ )
976
+
977
+ with gr.Column(scale=1):
978
+ gr.Markdown("### ๐Ÿ“ Step 2: Project Details")
979
+
980
+ name_method = gr.Radio(
981
+ choices=["Generate with AI", "Enter manually"],
982
+ value="Generate with AI",
983
+ label="Project Name Method"
984
+ )
985
+
986
+ project_name_input = gr.Textbox(
987
+ placeholder="Enter your project name (e.g., TechFlow Pro)",
988
+ label="Project Name",
989
+ visible=False
990
+ )
991
+
992
+ page_type = gr.Radio(
993
+ choices=["Single-Page", "Multi-Page"],
994
+ value="Single-Page",
995
+ label="Website Structure"
996
+ )
997
+
998
+ custom_requirements = gr.Textbox(
999
+ lines=3,
1000
+ placeholder="Any specific requirements? (e.g., 'Add a video hero section', 'Include testimonial carousel', 'Dark mode design')",
1001
+ label="Custom Requirements (Optional)"
1002
+ )
1003
 
1004
  with gr.Row():
1005
  generate_btn = gr.Button(
1006
  "๐Ÿš€ Generate Professional Website",
1007
  variant="primary",
1008
+ size="lg"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1009
  )
1010
 
1011
+ # Status and Preview
1012
+ status_output = gr.Markdown(elem_classes="status-box")
 
 
 
1013
 
1014
+ with gr.Tabs():
1015
+ with gr.TabItem("๐Ÿ–ฅ๏ธ Live Preview"):
1016
+ preview_output = gr.HTML()
1017
+
1018
+ with gr.TabItem("๐Ÿ’ฌ Modify Website"):
1019
+ gr.Markdown(
1020
+ """
1021
+ ### Make Changes to Your Generated Website
1022
+ After generating a website, you can request modifications here.
1023
+ """
 
 
1024
  )
1025
+ modification_input = gr.Textbox(
1026
+ lines=3,
1027
+ placeholder="E.g., 'Change the hero background to blue gradient', 'Add more testimonials', 'Make the navigation sticky'",
1028
+ label="What would you like to change?"
 
1029
  )
1030
+ modify_btn = gr.Button("๐Ÿ”ง Apply Modifications", variant="secondary")
1031
+ modification_status = gr.Markdown()
1032
+
1033
+ # Download Section
1034
+ with gr.Row():
1035
+ download_single = gr.File(label="๐Ÿ“ฅ Download HTML", visible=False)
1036
+ download_zip = gr.File(label="๐Ÿ“ฆ Download Project (ZIP)", visible=False)
1037
+ view_code_btn = gr.Button("๐Ÿ‘๏ธ View Source Code", visible=False)
1038
 
1039
+ # Code Display
1040
  with gr.Row(visible=False) as code_row:
1041
  code_output = gr.Code(
1042
+ label="Generated HTML Source Code",
1043
  language="html",
1044
+ lines=20
 
1045
  )
1046
 
1047
+ # Feature showcase
1048
+ gr.Markdown(
1049
+ """
1050
+ ### โœจ Features by Website Type
1051
+ """
 
 
 
 
 
 
1052
  )
1053
 
1054
+ with gr.Row():
1055
+ for i, (type_name, config) in enumerate(list(WEBSITE_TYPES.items())[:3]):
1056
+ with gr.Column():
1057
+ gr.Markdown(
1058
+ f"""
1059
+ **{config['emoji']} {type_name}**
1060
+
1061
+ {' '.join([f'<span class="feature-badge">{elem.split()[0]}</span>' for elem in config['must_have_elements'][:3]])}
1062
+ """
1063
+ )
1064
+
1065
+ # Event Handlers
1066
+ def update_type_details(selected_type):
1067
+ config = WEBSITE_TYPES[selected_type]
 
 
 
 
 
 
1068
  return (
1069
+ f"**{config['description']}**\n\n"
1070
+ f"Design Style: {config['design_style']}\n\n"
1071
+ f"Fonts: {config['fonts']['heading']} / {config['fonts']['body']}\n\n"
1072
+ f"Key Elements: {', '.join(config['must_have_elements'][:3])}..."
 
 
1073
  )
1074
 
1075
+ def toggle_name_input(method):
1076
+ return gr.update(visible=(method == "Enter manually"))
1077
+
1078
+ # Connect events
1079
+ website_type.change(
1080
+ fn=update_type_details,
1081
+ inputs=[website_type],
1082
+ outputs=[type_details]
1083
+ )
1084
+
1085
+ name_method.change(
1086
+ fn=toggle_name_input,
1087
+ inputs=[name_method],
1088
+ outputs=[project_name_input]
1089
+ )
1090
+
1091
  generate_btn.click(
1092
  fn=generate_website,
1093
+ inputs=[website_type, project_name_input, name_method, page_type, custom_requirements],
1094
+ outputs=[status_output, preview_output, download_single, download_zip, view_code_btn]
1095
+ )
1096
+
1097
+ modify_btn.click(
1098
+ fn=modify_website,
1099
+ inputs=[modification_input],
1100
+ outputs=[modification_status]
 
1101
  )
1102
 
1103
  view_code_btn.click(
1104
  fn=lambda: (
1105
+ gr.update(visible=True),
1106
+ open("outputs/index.html", "r", encoding="utf-8").read() if os.path.exists("outputs/index.html") else ""
1107
  ),
 
1108
  outputs=[code_row, code_output]
1109
  )
1110
 
1111
  if __name__ == "__main__":
1112
  print("\n" + "="*50)
1113
+ print("๐Ÿš€ Professional Website Builder AI")
1114
  print("="*50)
1115
+ print(f"\nโœ… {len(WEBSITE_TYPES)} website types loaded")
1116
+ print("๐ŸŽจ Industry-specific design systems ready")
1117
+ print("๐Ÿ’ฌ Chat modification system enabled")
1118
+ print("\n๐ŸŒ Launching interface...\n")
1119
 
1120
  iface.launch(share=False)