Module System
SaaSFoundryAI's module system lets you add features to projects during or after creation.
Overview
Modules are optional features that can be added:
- 📧 Email - MailerSend integration for transactional emails
- 📦 Storage - S3-compatible storage for file uploads
- 📊 Analytics - Umami analytics for user tracking
Adding Modules
During Project Creation
bash
sf new
# Interactive prompts include module selection
? Email service: MailerSend
? S3 storage: Docker (local development)
? Analytics: Yes, include UmamiAfter Project Creation
bash
cd my-project
sf update
# Select modules to add
? Which modules to add:
❯ ◯ Email (MailerSend)
◯ Storage (S3)
◯ Analytics (Umami)Available Modules
Email Module
Provider: MailerSend Affects: API only
Features:
- ✅ Transactional emails (welcome, password reset, invites)
- ✅ Template support
- ✅ Multi-sender configuration
- ✅ Test mode for development
Setup:
bash
sf update
# Select "Email (MailerSend)"
# Configure API key and sender emailSee: Email Module Guide
Storage Module
Provider: S3-compatible (AWS S3, MinIO, etc.) Affects: API + Web
Features:
- ✅ File uploads (images, documents)
- ✅ Presigned URLs for secure access
- ✅ Organization-scoped buckets
- ✅ Local Docker setup for development
Setup:
bash
sf update
# Select "Storage (S3)"
# Choose: Manual, Docker, or CredentialsAnalytics Module
Provider: Umami Affects: Web only
Features:
- ✅ Privacy-focused analytics
- ✅ No cookies required
- ✅ Privacy-minded collection that supports a GDPR-respectful configuration
- ✅ Self-hostable
Setup:
bash
sf update
# Select "Analytics (Umami)"
# Configure website ID and URLHow Modules Work
Blueprint + Overlay Pattern
SaaSFoundryAI uses a two-layer approach:
- Blueprints - Base project templates with TODO markers
- Overlays - Module source code that activates markers
Example:
Blueprint (before module):
typescript
// TODO mailer-service-active: import { EmailService } from './email.service'
export class AuthService {
// TODO mailer-service-active: constructor(private emailService: EmailService) {}
}After installing Email module:
typescript
import { EmailService } from './email.service'
export class AuthService {
constructor(private emailService: EmailService) {}
}Installer Process
When you add a module, the installer:
- Copies overlay files - Module source code
- Uncomments TODO markers - Activates module code
- Updates dependencies - Adds npm packages
- Configures environment - Updates
.envfiles - Updates manifest - Records module in
.saasfoundry.json
Manifest Tracking
Installed modules are tracked in .saasfoundry.json:
json
{
"modules": {
"email": { "provider": "mailersend", "version": 1 },
"s3Setup": "docker",
"includeAnalytics": true
}
}Module Updates
SaaSFoundryAI can update module code when the CLI is upgraded:
bash
sf update
# Detects version mismatch
# Offers to update module code
? Update Email module to latest version? YesThe update system uses three-way merge:
- Base - Original generated code (from manifest hash)
- Current - Your modified code
- Target - New template code
Merge strategies:
- ✅ Auto-update - File untouched, template changed
- ⚠️ Conflict - Both modified, saved as
.saasfoundry.new - ⏭️ Skip - File modified, template unchanged
Adding Custom Modules
You can create custom modules by:
- Creating overlay files in
scaffolds/overlays/modules/ - Creating installer in
src/installers/ - Adding TODO markers in blueprints
- Updating types and prompts
See: Development — adding a module or a skill
Best Practices
- Add modules early - Easier to integrate before writing code
- Use Docker for development - Storage and database
- Test in production mode - Some modules behave differently
- Keep .env in sync - Manual configuration may drift
Next Steps
- Email Module - Detailed email setup
- Run
sf updateto add more modules to your project - Check
src/installers/to see how modules are installed