saas-factory
v2.0.1
Published
CLI tool to instantly bootstrap full-featured SaaS applications with customizable modules
Downloads
586
Maintainers
Readme
🏭 SaaS Factory
✨ 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=
[email protected]
# 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
