Skip to content

ayushgundecha/landing-ai

Repository files navigation

🚀 PageCraft AI

A world-class AI-powered landing page generator built with Next.js 16, Lamatic.ai, and json-render. Generate beautiful, conversion-optimized landing pages in seconds using Lamatic.ai flows powered by free Groq models.

Next.js React TypeScript Tailwind CSS Lamatic.ai

✨ Features

  • AI-Powered Generation: Uses Lamatic.ai flows to generate complete landing pages from natural language prompts
  • 22 Professional Components: Hero sections, features, testimonials, pricing, CTAs, and more
  • Beautiful Design: Modern, responsive UI with Tailwind CSS v4
  • Type-Safe: Fully typed with TypeScript and Zod validation
  • Guardrailed AI: Uses json-render to constrain AI output to predefined safe components
  • Zero Dependencies: No shadcn or external UI libraries - pure custom components
  • Enterprise-Ready: Powered by Lamatic.ai's production-grade AI middleware

🏗️ Architecture

Tech Stack

  • Framework: Next.js 16.1.4 with App Router
  • AI Platform: Lamatic.ai - AI Middleware Platform
  • Rendering: json-render for safe, structured AI output
  • Styling: Tailwind CSS v4
  • Icons: Lucide React
  • Type Safety: TypeScript + Zod

Project Structure

pagecraft-ai/
├── src/
│   ├── app/
│   │   ├── api/
│   │   │   └── generate/
│   │   │       └── route.ts           # Lamatic.ai API integration
│   │   ├── page.tsx                   # Main generator UI with preview
│   │   ├── layout.tsx                 # Root layout with metadata
│   │   └── globals.css                # Global Tailwind styles
│   │
│   ├── components/
│   │   ├── error-boundary.tsx         # Error boundary for safe rendering
│   │   └── landing/                   # 22 landing page components
│   │       ├── index.ts               # Component registry export
│   │       ├── badge.tsx              # Badge component
│   │       ├── button.tsx             # Button with variants
│   │       ├── container.tsx          # Max-width container
│   │       ├── cta-section.tsx        # Call-to-action section
│   │       ├── feature.tsx            # Single feature card
│   │       ├── feature-grid.tsx       # Features grid layout
│   │       ├── footer.tsx             # Footer with links
│   │       ├── grid.tsx               # Responsive grid
│   │       ├── heading.tsx            # Typography headings
│   │       ├── hero.tsx               # Hero section
│   │       ├── hero-with-image.tsx    # Hero with side image
│   │       ├── image.tsx              # Responsive image
│   │       ├── logo-cloud.tsx         # Logo showcase
│   │       ├── navbar.tsx             # Navigation bar
│   │       ├── paragraph.tsx          # Text paragraph
│   │       ├── pricing-card.tsx       # Pricing plan card
│   │       ├── pricing-grid.tsx       # Pricing plans grid
│   │       ├── section.tsx            # Full-width section
│   │       ├── stack.tsx              # Flexbox stack layout
│   │       ├── stats.tsx              # Statistics showcase
│   │       ├── testimonial.tsx        # Testimonial card
│   │       └── testimonial-grid.tsx   # Testimonials grid
│   │
│   ├── lib/
│   │   ├── catalog.ts                 # json-render catalog with Zod schemas
│   │   ├── component-helpers.ts       # Type-safe design token helpers
│   │   ├── design-system.ts           # Centralized design tokens
│   │   └── tree-parser.ts             # Response parser & validator
│   │
│   └── types/
│       └── index.ts                   # TypeScript type definitions
│
├── .env.example                        # Environment variables template
├── .gitignore                          # Git ignore rules
├── package.json                        # Dependencies & scripts
├── pnpm-lock.yaml                      # Lock file
├── README.md                           # This file
├── tailwind.config.ts                  # Tailwind CSS configuration
└── tsconfig.json                       # TypeScript configuration

🚀 Getting Started

Prerequisites

Quick Setup

  1. Install dependencies:
pnpm install
  1. Set up Lamatic.ai:

    • Sign up at lamatic.ai
    • Create a project and get your Project ID and API Key
    • Create a Flow that accepts { prompt: string } and outputs landing page data
    • Deploy the flow and get your Flow ID
  2. Configure environment - Create .env.local:

# Get your credentials from Lamatic.ai dashboard
LAMATIC_ENDPOINT=https://your-org-your-project.lamatic.dev/graphql
LAMATIC_PROJECT_ID=00000000-0000-0000-0000-000000000000
LAMATIC_API_KEY=your_api_key_here
LAMATIC_FLOW_ID=00000000-0000-0000-0000-0000000000000
  1. Run the app:
pnpm dev
  1. Open http://localhost:3000

Lamatic Flow Setup

Input: { "prompt": "string" }

Output: A single JSON object with this structure:

{
  "root": "main-stack",
  "elements": {
    "navbar": {
      "key": "navbar",
      "type": "Navbar",
      "props": { "brandName": "MyApp" }
    }
    // ... more elements
  }
}

Note: The parser also supports JSONL format for backwards compatibility, but JSON is recommended for reliability.

Build for Production

pnpm build
pnpm start

📖 Usage

  1. Describe your landing page in the text area:

    • Example: "A modern SaaS product for team collaboration"
    • Example: "An AI-powered writing assistant for content creators"
  2. Click "Generate Landing Page" and watch as the AI creates your page in real-time

  3. Review the result - a complete landing page with:

    • Navigation bar
    • Hero section
    • Features section
    • Testimonials or social proof
    • Pricing (if applicable)
    • Call-to-action sections
    • Footer

🎨 Available Components

Layout Components

  • Section: Full-width container with color schemes
  • Container: Max-width content wrapper
  • Grid: Responsive grid layout
  • Stack: Flexible vertical/horizontal stack

Hero Components

  • Hero: Main hero with headline, subheading, CTAs
  • HeroWithImage: Hero with side-by-side image

Feature Components

  • Feature: Single feature with icon, title, description
  • FeatureGrid: Grid container for features

Social Proof

  • Testimonial: Customer testimonial card
  • TestimonialGrid: Grid of testimonials
  • LogoCloud: Company logos display
  • Stats: Key statistics showcase

Pricing

  • PricingCard: Pricing plan card
  • PricingGrid: Grid of pricing plans

Navigation

  • Navbar: Top navigation bar
  • Footer: Footer with links and info

Content

  • Heading, Paragraph, Image, Button, Badge, CTASection

🧠 How It Works

  1. Component Catalog: All components are defined in src/lib/catalog.ts with Zod schemas
  2. Lamatic.ai Flow: Your custom AI flow processes prompts and generates landing page data
  3. API Integration: Next.js API route calls Lamatic.ai SDK with user prompts
  4. json-render: Validates and renders AI output using predefined components
  5. Real-time Preview: Frontend displays the generated landing page instantly

🎯 Prompt Tips

For best results, include:

  • Target audience: "for small businesses", "for developers"
  • Key features: "with real-time collaboration", "AI-powered analytics"
  • Unique value: "10x faster than competitors", "Privacy-first approach"
  • Industry: SaaS, e-commerce, consulting, etc.

🛡️ Safety & Guardrails

  • AI can only use predefined components - no arbitrary code generation
  • All props are validated with Zod schemas
  • Type-safe throughout with TypeScript
  • No XSS or injection vulnerabilities

📝 License

MIT

🙏 Acknowledgments

🔧 Technical Details

How It Works

  1. User submits prompt → API route
  2. Lamatic SDK executes your flow → lamatic.executeFlow(flowId, { prompt })
  3. Parser normalizes response → Handles JSONL or tree format
  4. Validator checks structure → Ensures valid json-render tree
  5. Renderer displays page → <Renderer tree={tree} registry={componentRegistry} />

Key Files

  • src/app/api/generate/route.ts - Lamatic.ai API integration & flow execution
  • src/lib/tree-parser.ts - Response parser, validator & normalizer
  • src/lib/catalog.ts - Component catalog with Zod schemas
  • src/lib/design-system.ts - Design tokens & Tailwind class mappings
  • src/lib/component-helpers.ts - Type-safe design system helpers
  • src/types/index.ts - TypeScript type definitions
  • src/components/landing/* - 22 landing page components
  • src/components/error-boundary.tsx - Error boundary for safe rendering
  • prompt/LAMATIC_SYSTEM_PROMPT.txt - AI system prompt for Lamatic flow

📚 Resources


Built with ❤️ using Next.js 16, Lamatic.ai (with free Groq models), and json-render

💝 Support This Project

PageCraft AI is powered by Lamatic.ai using free Groq models. If you find this useful, consider buying me a coffee to help cover API token costs and keep this service free for everyone!

About

Prompt → production-ready landing page in seconds. Guardrailed agentic AI generates structured JSON via Zod schemas — no raw code, no XSS, no template drag-and-drop.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors