Package Exports
- saas-factory
- saas-factory/src/cli.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (saas-factory) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
๐ญ SaaS Factory
๐ Bootstrap Your SaaS in Minutes, Not Months
The ultimate CLI tool for generating production-ready SaaS applications.
24 modules โข CRUD generator โข Full-stack templates โข Best practices built-in.
โจ What is SaaS Factory?
SaaS Factory is a powerful CLI that generates complete, production-ready SaaS applications with:
- ๐จ Next.js 14 frontend with App Router & Tailwind CSS
- โ๏ธ Node.js/Express or Python/FastAPI backend
- ๐ Authentication with JWT, OAuth, email verification
- ๐ณ Stripe payments, subscriptions, billing portal
- ๐ข Multi-tenancy with workspaces
- ๐ฅ Teams with invitations and roles
- ๐ก๏ธ RBAC permission system
- ๐ Dashboard UI components
- And 16 more modules!
๐ Quick Start
Create a New Project
npx saas-factory initFollow the interactive prompts to:
- Choose your frontend (Next.js or API-only)
- Choose your backend (Node.js, Python, or frontend-only)
- Select modules (auth, payments, teams, etc.)
- Name your project
Add Modules to Existing Project
# Interactive selection
npx saas-factory add
# Or add specific module
npx saas-factory add auth
npx saas-factory add payments
npx saas-factory add aiGenerate CRUD
# Generate complete CRUD for a resource
npx saas-factory generate crud product --fields "name:string,price:number,active:boolean"Check Project Health
npx saas-factory doctor๐ฆ Available Modules (24)
Core Modules
| Module | Description |
|---|---|
๐ auth |
Authentication with JWT, OAuth, email verification |
๐ณ payments |
Stripe subscriptions, checkout, billing portal |
๐ข workspaces |
Multi-tenant architecture |
๐ก๏ธ permissions |
Role-based access control (RBAC) |
๐ฅ teams |
Team management & invitations |
๐ ui |
Pre-built dashboard components |
Feature Modules
| Module | Description |
|---|---|
๐ง email |
Transactional emails (Resend/Postmark/SMTP) |
๐ notifications |
In-app + realtime (Pusher/Socket.io) |
๐ storage |
File uploads (S3/UploadThing) |
๐ฐ pricing |
Pricing page with Stripe |
๐ onboarding |
User onboarding wizard |
๐ analytics |
Google Analytics / PostHog |
๐ audit-log |
Audit logging for compliance |
๐ blog |
MDX-powered blog with RSS |
๐ i18n |
Internationalization |
Advanced Modules
| Module | Description |
|---|---|
๐ค ai |
AI chat (OpenAI/Anthropic/Google) |
๐ admin |
Admin dashboard panel |
๐ webhooks |
Webhook handling & verification |
โก jobs |
Background jobs (Inngest/BullMQ) |
๐ฉ feature-flags |
Feature flags & A/B testing |
๐ก๏ธ rate-limit |
API rate limiting |
๐ deploy |
Deployment configs (Vercel/Docker) |
๐งช testing |
Testing setup (Vitest/Playwright) |
๐ Step-by-Step Guide
Step 1: Create Your Project
npx saas-factory initYou'll be prompted to configure:
? ๐จ Choose your frontend framework: Next.js (React with App Router)
? โ๏ธ Choose your backend framework: Node.js (Express)
? ๐ฆ Select modules to include:
โ ๐ Authentication
โ ๐ณ Payments (Stripe)
โ ๐ข Workspaces
โฏ ๐ก๏ธ Permissions
โฏ ๐ฅ Teams
โ ๐ Dashboard UI
? ๐ Enter your project name: my-saas-app
? ๐ Initialize a Git repository? YesStep 2: Install Dependencies
cd my-saas-app
npm run install:allStep 3: Configure Environment
# Copy the example environment file
cp .env.example .env
# Edit .env with your actual values
nano .env # or use your preferred editorKey variables to configure:
# Database
DATABASE_URL=postgresql://user:pass@localhost:5432/mydb
# Auth
JWT_SECRET=your-super-secret-key-min-32-chars
# Stripe (if using payments)
STRIPE_SECRET_KEY=sk_test_...
STRIPE_WEBHOOK_SECRET=whsec_...Step 4: Set Up Database
# Generate Prisma client
cd backend
npx prisma generate
# Push schema to database
npx prisma db push
# (Optional) Seed initial data
npx prisma db seedStep 5: Start Development
# From project root
npm run devThis starts:
- Frontend: http://localhost:3000
- Backend: http://localhost:8000
Step 6: Build for Production
npm run build๐ ๏ธ CLI Commands
| Command | Description |
|---|---|
saas-factory init |
Create a new SaaS project |
saas-factory add [module] |
Add module to existing project |
saas-factory generate crud <name> |
Generate CRUD for a resource |
saas-factory doctor |
Check project health |
saas-factory list |
List all available modules |
Generate CRUD Examples
# Basic resource
saas-factory generate crud post --fields "title:string,content:text,published:boolean"
# E-commerce product
saas-factory generate crud product --fields "name:string,price:number,description:text,stock:number,active:boolean"
# Task/Todo
saas-factory generate crud task --fields "title:string,description:text,dueDate:date,completed:boolean,priority:string"This generates:
prisma/models/<name>.prisma- Database modelsrc/routes/<names>.js- API routes with validationapp/dashboard/<names>/page.tsx- List page with search & paginationapp/dashboard/<names>/[id]/page.tsx- Create/Edit form
๐ Project Structure
my-saas-app/
โโโ frontend/ # Next.js application
โ โโโ app/ # App Router pages
โ โ โโโ auth/ # Login, Register, etc.
โ โ โโโ dashboard/ # Protected dashboard
โ โ โโโ (marketing)/ # Public pages
โ โโโ components/ # React components
โ โโโ lib/ # Utilities
โ
โโโ backend/ # Express/FastAPI server
โ โโโ src/
โ โ โโโ routes/ # API endpoints
โ โ โโโ middleware/ # Auth, validation
โ โ โโโ utils/ # Helpers
โ โโโ prisma/ # Database schema
โ
โโโ shared/ # Shared modules
โ โโโ auth/ # Auth utilities
โ โโโ payments/ # Stripe helpers
โ โโโ ... # Other modules
โ
โโโ .env.example # Environment template
โโโ package.json # Root scripts
โโโ README.md # Project docsโ๏ธ Configuration
Environment Variables
Each module adds its required variables to .env.example. Here's a complete reference:
# ===================
# Core Configuration
# ===================
NODE_ENV=development
FRONTEND_URL=http://localhost:3000
BACKEND_URL=http://localhost:8000
# ===================
# Database
# ===================
DATABASE_URL=postgresql://user:password@localhost:5432/mydb
# ===================
# Authentication
# ===================
JWT_SECRET=your-super-secret-jwt-key-change-in-production
JWT_EXPIRES_IN=7d
REFRESH_TOKEN_EXPIRES_IN=30d
# Email Verification (optional)
EMAIL_VERIFICATION_REQUIRED=true
SMTP_HOST=smtp.example.com
SMTP_PORT=587
SMTP_USER=
SMTP_PASSWORD=
FROM_EMAIL=noreply@yourapp.com
# OAuth (optional)
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
GITHUB_CLIENT_ID=
GITHUB_CLIENT_SECRET=
# ===================
# Payments (Stripe)
# ===================
STRIPE_SECRET_KEY=sk_test_...
STRIPE_PUBLISHABLE_KEY=pk_test_...
STRIPE_WEBHOOK_SECRET=whsec_...
# ===================
# File Storage
# ===================
STORAGE_PROVIDER=s3
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_REGION=us-east-1
AWS_S3_BUCKET=your-bucket
# ===================
# AI (if using ai module)
# ===================
AI_PROVIDER=openai
OPENAI_API_KEY=sk-...
# ===================
# Analytics
# ===================
NEXT_PUBLIC_POSTHOG_KEY=phc_...๐ Deployment
Vercel (Recommended for Next.js)
# Install Vercel CLI
npm i -g vercel
# Deploy
vercel
# Production
vercel --prodDocker
# Build
docker-compose build
# Run
docker-compose up -dRailway
# Install Railway CLI
npm i -g @railway/cli
# Login & deploy
railway login
railway init
railway up๐งช Testing
If you added the testing module:
# Unit tests
npm run test
# E2E tests
npm run test:e2e
# With coverage
npm run test:coverage๐ Module Documentation
Each module includes a detailed README.md with:
- Required dependencies
- Environment variables
- Code examples
- API reference
- Integration guide
Access module docs at:
shared/<module-name>/README.md๐ค Contributing
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing) - Open a Pull Request
๐ License
MIT License - see LICENSE for details.
๐ Acknowledgments
Built with:
- Next.js - React Framework
- Express - Node.js Framework
- Prisma - Database ORM
- Tailwind CSS - CSS Framework
- Stripe - Payments
- Zod - Validation
Made with โค๏ธ by the SaaS Factory team