https://github.com/nbschultz97/polygen-ai
AI-powered 3D modeling assistant. Generate, edit, and export 3D models using natural language.
https://github.com/nbschultz97/polygen-ai
3d-modeling ai openscad react saas typescript
Last synced: 23 days ago
JSON representation
AI-powered 3D modeling assistant. Generate, edit, and export 3D models using natural language.
- Host: GitHub
- URL: https://github.com/nbschultz97/polygen-ai
- Owner: nbschultz97
- License: mit
- Created: 2026-01-24T21:29:31.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2026-03-22T22:35:07.000Z (4 months ago)
- Last Synced: 2026-03-23T16:27:26.649Z (4 months ago)
- Topics: 3d-modeling, ai, openscad, react, saas, typescript
- Language: TypeScript
- Homepage: https://polygen-ai.vercel.app
- Size: 13.8 MB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
- Security: SECURITY.md
- Roadmap: ROADMAP.md
Awesome Lists containing this project
README
# PolyGen AI
**v3.9.1** | [Changelog](CHANGELOG.md) | [Roadmap](ROADMAP.md) | [Deployment Guide](DEPLOYMENT.md)
A text-to-3D model generator powered by a multi-agent AI pipeline. Converts natural language descriptions into printable OpenSCAD code using Google Gemini (Planner) and Anthropic Claude (Coder).
**Now available as a SaaS** with user authentication, subscription tiers, and usage tracking.
## Live Demo
π Live at [polygen.ceradonsystems.com](https://polygen.ceradonsystems.com/) β try 2 free generations without signing up!
## Quick Start (Local Dev)
```bash
# 1. Clone and install
git clone https://github.com/nbschultz97/polygen-ai.git
cd polygen-ai && pnpm install
# 2. Configure API keys (minimum: Gemini + Anthropic)
cp .env.example .env.local
# Edit .env.local β set GEMINI_API_KEY and ANTHROPIC_API_KEY
# 3. Start dev server
pnpm dev
# 4. Open http://localhost:5173 β use "Try Demo" for anonymous mode
# (Supabase/Stripe are optional β auth features gracefully degrade)
```
> **No API keys?** The app loads but generation requires at least Gemini + Anthropic keys. See `.env.example` for details.
## Features
### Core 3D Generation
- **Natural Language Input** - Describe what you want to create in plain English
- **Image-to-3D** - Upload a photo and recreate it as a printable model
- **STL Remix** - Upload an existing STL and generate parametric modifications around it
- **OpenSCAD Code Generation** - Outputs parametric, printable-ready pure OpenSCAD code
- **Preview/Render Split** - Fast preview for iteration, full Manifold render for verified export
- **In-App 3D Preview** - View your model in the browser with Three.js
- **Visual Critic** - Auto-triggers AI vision analysis on renders to catch structural issues
- **Parametric GST Templates** - Pre-built tactical templates for complex assemblies (Picatinny, MOLLE)
- **STL Export** - Download STL files after verified render
### v2.2 Reliable Code Generation
- **Closed-Loop Validation** - 3-attempt retry system with escalating guidance
- **Error Categorization** - Parses errors into 7 categories with suggested fixes
- **Pitfall Database** - 12 common OpenSCAD mistakes with bad/good examples
- **Auto-Preprocessing** - Injects epsilon and $fn if missing
- **Manifold Checking** - Detects open edges and non-manifold geometry
- **Teaching Mode** - Educational comments explain OpenSCAD concepts
### Multi-Agent Pipeline (v2.0+)
- **Planner Agent (Gemini 3 Pro)** - Generates Geometric Structure Tree (GST) from natural language
- **Coder Agent (Claude Sonnet)** - Converts GST to pure OpenSCAD code
- **Browser Validation** - WASM-based OpenSCAD compilation (fully serverless)
- **Smart Quick Fixes** - Context-aware refinement suggestions based on GST component types
- **Symbolic Correction** - Edit requests preserve component relationships
### SaaS Platform (v3.0+)
- **User Authentication** - Email/password and Google OAuth via Supabase
- **Subscription Tiers** - Free, Pro ($19/mo), Enterprise ($99/mo)
- **Usage Tracking** - Generation limits enforced per tier
- **Stripe Payments** - Secure checkout and subscription management
- **Analytics Dashboard** - Track your usage, manage subscription
- **Referral System** - Earn bonus generations by referring friends
### UX
- **Design Templates** - 9 quick-start templates for common objects
- **Clarification Questions** - AI asks follow-up questions with clickable suggested answers
- **User Preferences** - Save your printer settings, tolerances, and material preferences
- **Onboarding Tour** - Guided introduction for new users
- **Export Options** - Copy code, download `.scad` files, or open directly in OpenSCAD
## Pricing
| Plan | Price | Generations | Features |
| -------------- | --------- | ----------- | ------------------------------------------------------- |
| **Free** | $0 | 5/month | Basic templates, OpenSCAD export |
| **Pro** | $19/month | 100/month | All templates, STL export, 3D preview, priority support |
| **Enterprise** | $99/month | Unlimited | + API access, team features |
## Architecture
```
User Prompt β [Planner/Gemini] β GST JSON β [Coder/Claude] β OpenSCAD β [Validator/WASM] β 3D Model
β β
Clarification Retry with errors
Questions (max 3 attempts)
```
**Geometric Structure Tree (GST)**: An intermediate JSON representation that captures the semantic structure of the model (components, parameters, anchors, boolean operations) before code generation.
## Run Locally
**Prerequisites:** Node.js 20+
1. Clone the repository:
```bash
git clone https://github.com/nbschultz97/polygen-ai.git
cd polygen-ai
```
2. Install dependencies:
```bash
npm install
```
3. Copy the environment template:
```bash
cp .env.example .env.local
```
4. Fill in your API keys in `.env.local`:
```bash
# AI APIs (Required)
GEMINI_API_KEY=your_gemini_key
ANTHROPIC_API_KEY=your_claude_key
USE_MULTI_AGENT=true
# Supabase (Required for auth)
VITE_SUPABASE_URL=https://your-project.supabase.co
VITE_SUPABASE_ANON_KEY=your_anon_key
# Stripe (Required for payments)
STRIPE_SECRET_KEY=sk_live_xxx
VITE_STRIPE_PRO_MONTHLY_PRICE_ID=price_xxx
```
5. Run the app:
```bash
npm run dev
```
6. Open http://localhost:5173 in your browser
## Deployment
See [DEPLOYMENT.md](DEPLOYMENT.md) for complete deployment instructions including:
- Supabase setup and database schema
- Stripe configuration and webhook setup
- Vercel deployment with environment variables
- Custom domain configuration
## Configuration
### AI Configuration
| Variable | Default | Description |
| ------------------- | ---------------------- | ---------------------------------------- |
| `GEMINI_API_KEY` | (required) | Google AI API key for Planner agent |
| `GEMINI_MODEL` | `gemini-3-pro-preview` | Gemini model variant |
| `THINKING_LEVEL` | `high` | Reasoning depth: `low`, `medium`, `high` |
| `ANTHROPIC_API_KEY` | (optional) | Claude API key for Coder agent |
| `USE_MULTI_AGENT` | `false` | Enable PlannerβCoderβValidator pipeline |
### SaaS Configuration
| Variable | Description |
| --------------------------- | --------------------------------------- |
| `VITE_SUPABASE_URL` | Supabase project URL |
| `VITE_SUPABASE_ANON_KEY` | Supabase anonymous key |
| `SUPABASE_SERVICE_ROLE_KEY` | Supabase service role key (server-side) |
| `STRIPE_SECRET_KEY` | Stripe secret key |
| `STRIPE_WEBHOOK_SECRET` | Stripe webhook signing secret |
| `VITE_STRIPE_*_PRICE_ID` | Stripe price IDs for each plan |
| `VITE_GA_MEASUREMENT_ID` | Google Analytics 4 ID (optional) |
## Tech Stack
- **Frontend**: React 19 + TypeScript + Vite 7 + Tailwind CSS
- **3D Rendering**: Three.js + OpenSCAD WASM
- **AI**: Google Gemini API (Planner) + Anthropic Claude API (Coder)
- **Auth**: Supabase Auth with Google OAuth
- **Payments**: Stripe Subscriptions
- **Hosting**: Vercel (recommended)
- **Analytics**: Google Analytics 4
## Project Structure
```
polygen-ai/
βββ components/ # React components
β βββ AuthContext.tsx # Authentication state
β βββ LandingPage.tsx # Marketing homepage
β βββ MainApp.tsx # Authenticated app wrapper
β βββ PricingPage.tsx # Subscription plans
β βββ ...
βββ services/ # Business logic
β βββ authService.ts # Supabase auth
β βββ stripeService.ts # Stripe integration
β βββ geminiService.ts # Gemini API
β βββ coderService.ts # Claude API
β βββ errorCategorizer.ts # Error analysis
β βββ ...
βββ api/ # Vercel Edge Functions
β βββ stripe/ # Payment endpoints
βββ supabase/ # Database schemas
βββ marketing/ # Launch materials
βββ seo/ # SEO assets
βββ public/ # Static files
```
## Contributing
See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
## License
MIT
---
Built by [Noah Schultz](https://github.com/nbschultz97) | Powered by Gemini + Claude