Documentation

Documentation

Learn how to use Nudgd to generate your SaaS boilerplate in minutes.

What is Nudgd?

Nudgd is a powerful SaaS boilerplate generator that creates production-ready full-stack applications in minutes.

Instead of starting from scratch, you configure your project requirements (database, authentication, payments, etc.) and Nudgd generates a complete backend and frontend with all best practices baked in.

What you get:

  • ✓ Fully functional Express backend with TypeScript
  • ✓ Next.js 14 frontend with modern UI components
  • ✓ Database setup (PostgreSQL or MongoDB)
  • ✓ JWT authentication with bcrypt password hashing
  • ✓ Docker setup for local development
  • ✓ Environment configuration
  • ✓ Production-ready security best practices

Installation

Nudgd runs as a generator service - just visit the generator:

https://nudgdapp.com

The generator runs on the backend and creates projects instantly.

Creating Your First Project

  1. Fill out the form with your project details:
    • Project name (e.g., "my-saas")
    • Description
    • Select features (database, auth, payments, etc.)
  2. Choose your database: PostgreSQL or MongoDB
  3. Select optional features: Stripe, Resend email, OpenAI integration, AWS S3 storage, etc.
  4. Click "Generate Project" and wait for the magic ✨
  5. Download the ZIP file with your complete project

Frontend Bundle

Nudgd always generates a production-ready frontend—no toggle needed.

  • Next.js 14 (App Router) with Tailwind UI components
  • Signup, signin, and protected dashboard shell wired to your chosen auth
  • Marketing landing page and docs page to explain your product
  • API hooks and layouts aligned to the backend/services you select

Authentication

Nudgd includes JWT-based authentication out of the box:

Features:

  • ✓ Secure password hashing with bcrypt
  • ✓ JWT tokens for stateless authentication
  • ✓ Role-based access control (RBAC)
  • ✓ Rate limiting on auth endpoints
  • ✓ Input validation
  • ✓ Automatic password exclusion from responses

POST /api/auth/register

POST /api/auth/login

Database Options

PostgreSQL

Recommended for most applications. Relational database with Prisma ORM.

  • Advanced querying with Prisma
  • Type-safe database access
  • Built-in migrations
  • Perfect for complex schemas

MongoDB

Choose for flexible schemas and document-based data.

  • Document-based NoSQL database
  • Schema flexibility
  • Great for rapid prototyping
  • Mongoose ODM integration

Payment Integration

Easily add payment processing to your SaaS:

Stripe

Complete payment solution with subscriptions, one-time payments, and invoicing.

Lemon Squeezy

Creator-friendly payment platform with built-in compliance.

Email Services

Send transactional emails with integrated services:

Resend

Modern email service for developers. Send emails from Next.js.

SMTP

Generic SMTP configuration for any email provider.

AI Integration

Add AI capabilities with pre-configured integrations:

OpenAI

GPT-4, ChatGPT, and embeddings for intelligent features.

Anthropic

Claude AI models for advanced AI capabilities.

File Storage

Handle file uploads with built-in storage options:

Local Storage

Store files on your server. Good for development and small deployments.

AWS S3

Scalable cloud storage for production. Includes CDN integration.

Project Structure

Your generated project includes both backend and frontend:

my-saas/
├── server/
│   ├── src/
│   │   ├── index.ts          # Entry point
│   │   ├── app.ts            # Express app setup
│   │   ├── db.ts             # Database connection
│   │   ├── authController.ts # Auth logic
│   │   ├── middleware/       # Custom middleware
│   │   └── routes/           # API routes
│   ├── prisma/
│   │   └── schema.prisma     # Database schema
│   └── package.json
│
├── web/
│   ├── src/
│   │   ├── app/              # Next.js pages
│   │   ├── components/       # React components
│   │   ├── context/          # Auth context
│   │   └── hooks/            # Custom hooks
│   ├── package.json
│   └── next.config.js
│
├── docker-compose.yml        # Local database setup
└── SETUP.md                  # Setup instructions

Running Locally

  1. Extract the ZIP file to your desired location
  2. Install dependencies:
    cd server && npm install
    cd ../web && npm install
  3. Start Docker for the database:
    cd server && docker compose up -d
  4. Run database migrations (PostgreSQL):
    npm run prisma:migrate
  5. Start the backend and frontend:
    # Terminal 1 - Backend
    cd server && npm run dev
    
    # Terminal 2 - Frontend
    cd web && npm run dev

• Backend: http://localhost:5000
• Frontend: http://localhost:3000

Database Setup

With Docker (Recommended)

docker compose up -d

Your database runs in a container with persistent data.

Without Docker

Update your connection string in .env:

# PostgreSQL local
DATABASE_URL=postgresql://user:password@localhost:5432/dbname

# MongoDB local
MONGO_URI=mongodb://localhost:27017/dbname

Environment Variables

Create .env files in both server/ and web/ directories.

Backend (.env)

PORT=5000
NODE_ENV=development
CORS_ORIGIN=http://localhost:3000

# Database
DATABASE_URL=postgresql://admin:password123@localhost:5432/my-saas
# or
MONGO_URI=mongodb://admin:password123@localhost:27017/my-saas?authSource=admin

# Authentication
JWT_SECRET=your-super-secret-key-min-32-chars
BCRYPT_ROUNDS=12

# Optional - Payment
STRIPE_SECRET_KEY=sk_test_...

# Optional - Email
RESEND_API_KEY=re_...

# Optional - AI
OPENAI_API_KEY=sk-...

# Optional - Storage
AWS_ACCESS_KEY_ID=...
AWS_SECRET_ACCESS_KEY=...
AWS_S3_BUCKET=...

Frontend (.env.local)

NEXT_PUBLIC_API_URL=http://localhost:5000
NEXT_PUBLIC_APP_URL=http://localhost:3000

Building for Production

Backend

npm run build
NODE_ENV=production npm start

Frontend

npm run build
npm start

Security Checklist

  • Set strong JWT_SECRET
  • Use environment variables for all secrets
  • Enable HTTPS only
  • Set NODE_ENV=production
  • Use managed database services
  • Setup monitoring and logging
  • Enable rate limiting
  • Regular security updates

Docker Deployment

Deploy your application using Docker:

# Build backend image
cd server
docker build -t my-saas-backend .

# Build frontend image
cd ../web
docker build -t my-saas-frontend .

# Run with docker-compose for production
docker-compose -f docker-compose.prod.yml up

Production Environment Configuration

Update these values when deploying to production:

# Backend
NODE_ENV=production
PORT=8080
CORS_ORIGIN=https://yourdomain.com

# Use strong secrets - Generate with: node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
JWT_SECRET=<very-long-random-string>
BCRYPT_ROUNDS=12

# Use managed database service
DATABASE_URL=postgresql://user:pass@production-db.example.com/dbname
# or
MONGO_URI=mongodb+srv://user:pass@cluster.mongodb.net/dbname

# Frontend
NEXT_PUBLIC_API_URL=https://api.yourdomain.com
NEXT_PUBLIC_APP_URL=https://yourdomain.com

Modifying Generated Code

The generated code is yours to customize. Feel free to modify, extend, and improve it for your use case.

Tips for customization:

  • ✓ Add your business logic to controllers
  • ✓ Extend the database schema with new models
  • ✓ Create new API routes as needed
  • ✓ Design custom UI components
  • ✓ Integrate third-party services
  • ✓ Add tests for critical paths

Best Practices

Development

  • Use TypeScript for type safety
  • Write unit and integration tests
  • Follow the existing code structure
  • Use meaningful variable and function names
  • Add comments for complex logic

Security

  • Never commit secrets to version control
  • Use environment variables for all secrets
  • Validate all user input
  • Use parameterized queries
  • Implement rate limiting
  • Keep dependencies updated

Database

  • Run migrations before deployment
  • Backup your database regularly
  • Use transactions for critical operations
  • Index frequently queried columns
  • Monitor query performance

Deployment

  • Test in staging before production
  • Use CI/CD for automated deployments
  • Monitor application health
  • Setup error tracking and logging
  • Plan for scaling from the start

Need help? Join our community or check the latest documentation.