Your First Project
Let's build a complete SaaS application from scratch.
What We're Building
A SaaS starter with:
- User authentication
- Admin dashboard
- Subscription management (Stripe)
- Email notifications
- PostgreSQL database
Step 1: Create the Project
npx autodeploybase init my-saas \
--framework next \
--archetype saas \
--database postgresql
You'll see output like:
Creating project: my-saas
Framework: Next.js 14
Archetype: SaaS
Database: PostgreSQL
✓ Created project structure
✓ Generated Next.js app
✓ Added authentication plugin
✓ Added admin dashboard plugin
✓ Generated Prisma schema
✓ Created environment template
Project created successfully!
Next steps:
cd my-saas
cp .env.example .env
npm install
npx prisma migrate dev
npm run dev
Step 2: Explore the Structure
my-saas/
├── prisma/
│ └── schema.prisma # Database schema
├── src/
│ ├── app/
│ │ ├── api/ # API routes
│ │ │ ├── auth/ # Auth endpoints
│ │ │ └── admin/ # Admin endpoints
│ │ ├── (auth)/ # Auth pages
│ │ │ ├── login/
│ │ │ └── register/
│ │ ├── admin/ # Admin pages
│ │ └── dashboard/ # User dashboard
│ ├── components/
│ │ ├── admin/ # Admin components
│ │ └── ui/ # UI components
│ └── lib/
│ ├── auth.ts # Auth utilities
│ └── db.ts # Database client
├── .env.example # Environment template
├── autodeploy.config.json # Project configuration
└── package.json
Step 3: Configure Environment
cp .env.example .env
Edit .env:
.env
# Database
DATABASE_URL="postgresql://postgres:password@localhost:5432/my_saas"
# Authentication
JWT_SECRET="your-super-secret-key-at-least-32-characters"
JWT_EXPIRY="7d"
# App
NEXT_PUBLIC_APP_URL="http://localhost:3000"
Step 4: Set Up Database
Start PostgreSQL (if using Docker):
docker run -d \
--name my-saas-db \
-e POSTGRES_PASSWORD=password \
-e POSTGRES_DB=my_saas \
-p 5432:5432 \
postgres:16
Run migrations:
npm install
npx prisma generate
npx prisma migrate dev --name init
Step 5: Start Development
npm run dev
Step 6: Add Stripe Payments
npx autodeploybase add payments-stripe
Configure Stripe:
.env
STRIPE_SECRET_KEY=sk_test_...
STRIPE_PUBLISHABLE_KEY=pk_test_...
STRIPE_WEBHOOK_SECRET=whsec_...
Step 7: Add Email
npx autodeploybase add email
Configure email provider:
.env
EMAIL_PROVIDER=resend
RESEND_API_KEY=re_...
EMAIL_FROM="noreply@myapp.com"
Step 8: Regenerate
After adding plugins, regenerate:
npx autodeploybase generate
Step 9: Test Everything
# Run tests
npm run test
# Type check
npm run typecheck
# Lint
npm run lint
Step 10: Deploy
Vercel (Recommended)
npm i -g vercel
vercel
Set environment variables in Vercel dashboard.
Docker
# Build
docker build -t my-saas .
# Run
docker run -p 3000:3000 \
-e DATABASE_URL="..." \
-e JWT_SECRET="..." \
my-saas
Your Configuration File
autodeploy.config.json
{
"$schema": "https://autodeploybase.dev/schema.json",
"name": "my-saas",
"version": "1.0.0",
"framework": "next",
"database": "postgresql",
"plugins": {
"auth-jwt": {
"enabled": true,
"settings": {
"tokenExpiry": "7d"
}
},
"admin-dashboard": {
"enabled": true
},
"payments-stripe": {
"enabled": true,
"settings": {
"currency": "usd"
}
},
"email": {
"enabled": true,
"settings": {
"provider": "resend"
}
}
}
}
What's Next?
Customize
Modify components and add your business logic.
Add Plugins
Explore available plugins to add features.
Build Plugins
Create custom plugins for your needs.