nextjs-builder Tailwind Templates

Nextjs Builder

NazareAI NextJS Builder is an AI-powered module for building customized Next.js and Tailwind CSS websites using natural language descriptions. This tool leverages LangChain and OpenRouter with Claude-3.5-Sonnet to generate high-quality, production-ready code.

Next.js & Tailwind Website Builder from NazareAI

Python Version Status

An AI-powered module for building customized Next.js and Tailwind CSS websites using natural language descriptions. This tool leverages LangChain and OpenRouter with Claude-3.5-Sonnet to generate high-quality, production-ready code.

๐ŸŒŸ Features

  • Natural Language Input: Describe your website and have it generated automatically
  • Next.js App Router: Modern Next.js 14+ with App Router and TypeScript
  • Tailwind CSS: Clean, responsive designs using core Tailwind (no component libraries)
  • Multiple Templates: Support for general-purpose, blog, e-commerce, and portfolio websites
  • SSR by Default: Server-side rendering for optimal SEO performance
  • React Context & Query: State management with React Context API and React Query
  • Image Optimization: Built-in Next.js Image component for optimized images
  • Optional Features: Authentication and database integration as needed

๐Ÿ“‹ Prerequisites

  • Python 3.9+
  • Node.js 18.17.0+ and npm
  • OpenRouter API key (for Claude-3.5-Sonnet access)

๐Ÿš€ Quick Start

Installation

# Clone the repository
git clone https://github.com/nazareai/nextjs-builder.git
cd nextjs-builder

# Install dependencies
pip install -r requirements.txt

# Set up environment variables
cp .env.example .env
# Edit .env to add your OpenRouter API key

Basic Usage

# Generate a basic website
python test.py "Build a company website with a home page, about page, and contact form"

# Generate with a specific template
python test.py "Create a handmade jewelry store" --template=ecommerce

# Include authentication
python test.py "Build a travel blog with user comments" --template=blog --auth

# Specify database integration
python test.py "Create a photographer portfolio" --template=portfolio --db=mongodb

๐Ÿ—๏ธ Architecture

The Next.js & Tailwind Website Builder consists of several key components:

graph TD
    A[CLI Interface] --> B[Config Parser]
    B --> C[Next.js Project Creator]
    C --> D[Template Selection]
    D --> E[LLM-Powered Code Generation]
    
    E --> F1[Pages Generator]
    E --> F2[Components Generator]
    E --> F3[State Management Generator]
    
    F1 --> G[Integration Layer]
    F2 --> G
    F3 --> G
    
    G --> H[Validation & Testing]
    H --> I[Output]
    
    J[LangChain + OpenRouter] -.-> E
    K[Templates Library] -.-> D
    L[Prompts Library] -.-> E

Key Components

  • CLI Interface: Command-line tool for interacting with the builder
  • Project Creator: Sets up Next.js projects with the right configuration
  • Template System: Manages different website templates
  • LLM Integration: Connects with OpenRouter to access Claude-3.5-Sonnet
  • Code Generation: Creates components, pages, and state management
  • Validation: Ensures generated code meets quality standards

๐Ÿ“Š Project Structure

nextjs-builder/
โ”œโ”€โ”€ README.md                # This file
โ”œโ”€โ”€ requirements.txt         # Python dependencies
โ”œโ”€โ”€ setup.py                 # Package setup
โ”œโ”€โ”€ test.py                  # CLI entry point
โ”‚
โ”œโ”€โ”€ prompts/                 # LLM prompt templates
โ”‚   โ”œโ”€โ”€ system/              # System prompts
โ”‚   โ”œโ”€โ”€ components/          # Component generation prompts
โ”‚   โ”œโ”€โ”€ pages/               # Page generation prompts
โ”‚   โ””โ”€โ”€ templates/           # Website type templates
โ”‚
โ”œโ”€โ”€ templates/               # Starting point templates
โ”‚   โ”œโ”€โ”€ base/                # Common components for all sites
โ”‚   โ”œโ”€โ”€ blog/                # Blog-specific components
โ”‚   โ”œโ”€โ”€ ecommerce/           # E-commerce components
โ”‚   โ””โ”€โ”€ portfolio/           # Portfolio components
โ”‚
โ””โ”€โ”€ src/                     # Module source code
    โ”œโ”€โ”€ cli.py               # CLI argument handling
    โ”œโ”€โ”€ config.py            # Configuration management
    โ”œโ”€โ”€ installer/           # Next.js project installation
    โ”œโ”€โ”€ generator/           # Code generation
    โ”œโ”€โ”€ llm/                 # LangChain integration
    โ”œโ”€โ”€ utils/               # Utility functions
    โ””โ”€โ”€ features/            # Optional feature integrations

๐Ÿ”ง Configuration

Environment Variables

Create a .env file with the following variables:

OPENROUTER_API_KEY=your_api_key_here
OPENROUTER_BASE_URL=https://openrouter.ai/api/v1

Configuration File

You can also create a nextjs-builder.config.json file for additional configuration:

{
  "llm": {
    "model": "anthropic/claude-3.5-sonnet-20240620",
    "temperature": 0.7,
    "max_tokens": 10000
  },
  "templates": {
    "default": "general"
  },
  "validation": {
    "run_eslint": true,
    "run_typescript_check": true
  }
}

๐Ÿ“ CLI Options

Option Description Default
description Description of the website to build (required)
--template Website template (general, blog, ecommerce, portfolio) "general"
--auth Include authentication false
--db Database integration (none, mongodb, postgres, supabase) "none"
--output Output directory for the generated website "./website"
--verbose Enable verbose logging false

๐Ÿงฉ Templates

General Website Template

A multi-purpose website suitable for businesses, organizations, or personal sites.

Key Features:

  • Home page with hero section
  • About page with team profiles
  • Services or features showcase
  • Contact form with validation
  • Responsive navigation and footer

Blog Template

A content-focused blog website optimized for readability and SEO.

Key Features:

  • Featured posts and categories
  • Blog listing with filtering
  • Individual post pages with author info
  • Category and tag archives
  • Search functionality

E-commerce Template

A complete online store with product showcase and checkout flow.

Key Features:

  • Product listings with filtering
  • Product detail pages with gallery
  • Shopping cart functionality
  • Checkout process
  • Order history

Portfolio Template

A showcase website for creative professionals and their work.

Key Features:

  • Work/project showcase
  • Project detail pages
  • About/bio section
  • Skills and experience presentation
  • Contact form

๐Ÿ”Œ Optional Features

Authentication

When enabled with --auth, the module will add:

  • User registration and login forms
  • Protected routes
  • User profile management
  • Session handling

Database Integration

Available options with --db:

  • mongodb: Sets up MongoDB connection with proper models
  • postgres: Integrates PostgreSQL with Prisma ORM
  • supabase: Connects to Supabase for database and auth

๐Ÿงช Testing

Run the test suite to validate the module:

# Run all tests
pytest

# Run specific test categories
pytest tests/unit/
pytest tests/integration/
pytest tests/e2e/

๐Ÿ“˜ Documentation

For more detailed documentation, see:

๐Ÿšง Development Status

This project is currently in alpha status. Core functionality is being finalized and the API may change.

Current Version: 0.1.0

  • โœ… Basic CLI interface
  • โœ… Next.js project creation
  • โœ… LangChain integration
  • โœ… Basic template system
  • โœ… Component generation
  • โœ… Page generation
  • ๐Ÿ”„ State management implementation
  • ๐Ÿ”„ Optional features

๐Ÿค Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines.

Development Setup

# Clone the repository
git clone https://github.com/nazareai/nextjs-builder.git
cd nextjs-builder

# Install dependencies
pip install -e ".[dev]"

# Set up pre-commit hooks
pre-commit install

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ‘ Acknowledgments

Top categories

Loading Svelte Themes