An intelligent web application that generates code and file structures through AI prompts, featuring live preview, user authentication, and payment processing.
- π€ AI Code Generation - Generate complete code structures from natural language prompts
- π File Structure Creation - Automatically create organized project directories
- π Live Preview - Real-time code preview with syntax highlighting
- π Google Authentication - Secure OAuth 2.0 login system
- π³ PayPal Integration - Subscription and payment processing
- π Real-time Database - Convex database for instant data synchronization
- π¨ Modern UI - Responsive design with Tailwind CSS
- β‘ Fast Performance - Built on Next.js 15 with Turbopack
- Next.js 15 - React framework with App Router
- React 19 - Latest React features and Server Components
- TypeScript - Type-safe development
- Tailwind CSS - Utility-first styling
- Shadcn/ui - Modern component library
- Convex - Real-time database and backend functions
- NextAuth.js - Authentication framework
- Server Actions - Form handling and data mutations
- Google OAuth 2.0 - User authentication
- PayPal SDK - Payment processing
- Google APIs - Additional Google services
- OpenAI API - AI code generation (optional)
- Node.js 18+
- npm or yarn or pnpm
- Git
git clone https://github.com/yourusername/ai-website-builder.git cd ai-website-builder
text
npm install
or yarn install
or pnpm install
text
Create .env.local file:
App Configuration NEXTAUTH_URL=http://localhost:3000 NEXTAUTH_SECRET=your-super-secret-key-here
Google Authentication GOOGLE_CLIENT_ID=your-google-client-id GOOGLE_CLIENT_SECRET=your-google-client-secret
PayPal Configuration NEXT_PUBLIC_PAYPAL_CLIENT_ID=your-paypal-client-id PAYPAL_CLIENT_SECRET=your-paypal-client-secret PAYPAL_ENVIRONMENT=sandbox # or production
Convex Database NEXT_PUBLIC_CONVEX_URL=your-convex-url CONVEX_DEPLOY_KEY=your-convex-deploy-key
Google APIs GOOGLE_API_KEY=your-google-api-key
AI Services (Optional) OPENAI_API_KEY=your-openai-key
text
Initialize Convex:
npx convex dev
text
npm run dev
text
Open http://localhost:3000 in your browser.
ai-website-builder/ βββ app/ # Next.js App Router β βββ (auth)/ # Authentication routes β βββ (dashboard)/ # Protected dashboard β βββ api/ # API routes β βββ components/ # React components β β βββ ui/ # Shadcn/ui components β β βββ auth/ # Auth components β β βββ code-editor/ # Code editor components β β βββ payment/ # Payment components β βββ lib/ # Utility functions β βββ globals.css # Global styles β βββ layout.tsx # Root layout β βββ page.tsx # Home page βββ convex/ # Convex backend β βββ _generated/ # Auto-generated files β βββ schema.ts # Database schema β βββ users.ts # User functions β βββ projects.ts # Project functions β βββ payments.ts # Payment functions βββ public/ # Static assets βββ components.json # Shadcn/ui config βββ next.config.js # Next.js config βββ tailwind.config.js # Tailwind config βββ package.json
text
- Visit Google Cloud Console
- Create a new project or select existing
- Enable Google+ API
- Create OAuth 2.0 credentials
- Add authorized redirect URIs:
http://localhost:3000/api/auth/callback/googlehttps://yourdomain.com/api/auth/callback/google
- Create PayPal Developer account
- Create a REST API application
- Copy Client ID and Secret
- Configure webhook endpoints for payment notifications
// convex/schema.ts import { defineSchema, defineTable } from "convex/server"; import { v } from "convex/values";
export default defineSchema({ users: defineTable({ email: v.string(), name: v.string(), image: v.optional(v.string()), googleId: v.string(), subscription: v.optional(v.string()), createdAt: v.number(), }).index("by_email", ["email"]).index("by_googleId", ["googleId"]),
projects: defineTable({ userId: v.id("users"), name: v.string(), description: v.optional(v.string()), code: v.string(), fileStructure: v.object({ files: v.array(v.object({ name: v.string(), content: v.string(), type: v.string(), })), }), isPublic: v.boolean(), createdAt: v.number(), updatedAt: v.number(), }).index("by_user", ["userId"]),
payments: defineTable({ userId: v.id("users"), paypalOrderId: v.string(), amount: v.number(), currency: v.string(), status: v.string(), createdAt: v.number(), }).index("by_user", ["userId"]), });
text
// Example usage const generateProject = async (prompt: string) => { const response = await fetch('/api/generate', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ prompt }) });
return await response.json(); };
text
// convex/projects.ts import { mutation, query } from "./_generated/server"; import { v } from "convex/values";
export const createProject = mutation({ args: { name: v.string(), code: v.string(), description: v.optional(v.string()), }, handler: async (ctx, args) => { const identity = await ctx.auth.getUserIdentity(); if (!identity) throw new Error("Not authenticated");
text const user = await ctx.db .query("users") .filter((q) => q.eq(q.field("email"), identity.email)) .first();
if (!user) throw new Error("User not found");
return await ctx.db.insert("projects", { userId: user._id, name: args.name, code: args.code, description: args.description, fileStructure: { files: [] }, isPublic: false, createdAt: Date.now(), updatedAt: Date.now(), }); }, });
text
// components/PayPalButton.tsx import { PayPalButtons, usePayPalScriptReducer } from "@paypal/react-paypal-js";
export function PayPalCheckout({ amount }: { amount: number }) { const [{ options, isPending }] = usePayPalScriptReducer();
return ( <PayPalButtons style={{ layout: "vertical" }} createOrder={async (data, actions) => { const orderId = await fetch("/api/paypal/create-order", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ amount }), }).then((res) => res.json());
text return orderId; }} onApprove={async (data, actions) => { const response = await fetch("/api/paypal/capture-order", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ orderID: data.orderID }), });
return response.json();
}} /> ); }
text
- Connect Repository npx vercel --prod
text
- Environment Variables
- Add all environment variables in Vercel dashboard
- Ensure production URLs are used
- Custom Domain
- Configure custom domain in Vercel
- Update OAuth redirect URLs
- Railway:
railway deploy - Netlify: Configure build settings
- DigitalOcean: Use App Platform
GET /api/auth/session- Get current sessionPOST /api/auth/signin- Sign in userPOST /api/auth/signout- Sign out user
GET /api/projects- List user projectsPOST /api/projects- Create new projectPUT /api/projects/[id]- Update projectDELETE /api/projects/[id]- Delete project
POST /api/generate- Generate code from promptPOST /api/generate/structure- Generate file structure
POST /api/paypal/create-order- Create PayPal orderPOST /api/paypal/capture-order- Capture paymentGET /api/payments- Get payment history
Run tests npm run test
Run tests in watch mode npm run test:watch
Run E2E tests npm run test:e2e
text
Authentication Problems
- Verify Google OAuth credentials
- Check redirect URLs match exactly
- Ensure NEXTAUTH_SECRET is set
Database Connection
- Run
npx convex devto start local development - Check Convex deployment status
- Verify environment variables
Payment Issues
- Confirm PayPal sandbox/production settings
- Check webhook configurations
- Verify client ID matches environment
Build Errors
- Update to Node.js 18+
- Clear npm cache:
npm cache clean --force - Delete
node_modulesand reinstall
- Fork the repository
- Create feature branch:
git checkout -b feature/amazing-feature - Commit changes:
git commit -m 'Add amazing feature' - Push to branch:
git push origin feature/amazing-feature - Open Pull Request
- Follow TypeScript best practices
- Use ESLint and Prettier for code formatting
- Write meaningful commit messages
- Add tests for new features
- Update documentation
This project is licensed under the MIT License - see the LICENSE file for details.
- Next.js Team for the amazing framework
- Convex for the real-time database
- Vercel for hosting and deployment
- Shadcn/ui for beautiful components
- π§ Email: sa9451736205@gmail.com
- π Issues: GitHub Issues
Made with β€οΈ by Your Name
β Star this repository if you found it helpful!