Deployment Guide
Complete guide to deploying your Flowfull backend to production.
Overview
Flowfull can be deployed to any platform that supports Node.js/Bun applications. This guide covers the most popular platforms.
Prerequisites
Before deploying:
- ✅ Database configured and migrated
- ✅ Environment variables documented
- ✅ Redis instance (for caching)
- ✅ Flowless instance on Pubflow
- ✅ Tests passing
Platform Guides
Railway
Best for: Quick deployments, PostgreSQL/Redis included
- Install Railway CLI:
bash
npm install -g @railway/cli- Login:
bash
railway login- Initialize project:
bash
railway init- Add PostgreSQL:
bash
railway add postgresql- Add Redis:
bash
railway add redis- Set environment variables:
bash
railway variables set FLOWLESS_URL=https://your-instance.pubflow.com
railway variables set BRIDGE_SECRET=your-secret
railway variables set VALIDATION_MODE=STANDARD- Deploy:
bash
railway upFly.io
Best for: Global edge deployment, low latency
- Install Fly CLI:
bash
curl -L https://fly.io/install.sh | sh- Login:
bash
fly auth login- Create app:
bash
fly launch- Create Dockerfile:
dockerfile
FROM oven/bun:1 as base
WORKDIR /app
# Install dependencies
COPY package.json bun.lockb ./
RUN bun install --frozen-lockfile
# Copy source
COPY . .
# Build (if needed)
RUN bun run build
# Expose port
EXPOSE 3000
# Start
CMD ["bun", "run", "start"]- Set secrets:
bash
fly secrets set FLOWLESS_URL=https://your-instance.pubflow.com
fly secrets set BRIDGE_SECRET=your-secret
fly secrets set DATABASE_URL=your-database-url- Deploy:
bash
fly deployVercel
Best for: Serverless deployment, Next.js integration
- Install Vercel CLI:
bash
npm install -g vercel- Create
vercel.json:
json
{
"version": 2,
"builds": [
{
"src": "src/index.ts",
"use": "@vercel/node"
}
],
"routes": [
{
"src": "/(.*)",
"dest": "src/index.ts"
}
]
}- Deploy:
bash
vercel- Set environment variables in Vercel dashboard
AWS (EC2)
Best for: Full control, enterprise deployments
Launch EC2 instance (Ubuntu 22.04)
SSH into instance:
bash
ssh -i your-key.pem ubuntu@your-instance-ip- Install Bun:
bash
curl -fsSL https://bun.sh/install | bash- Clone repository:
bash
git clone https://github.com/your-org/your-flowfull.git
cd your-flowfull- Install dependencies:
bash
bun install- Create
.env:
bash
nano .env
# Add your environment variables- Run migrations:
bash
bun run migrate- Install PM2:
bash
npm install -g pm2- Start with PM2:
bash
pm2 start bun --name flowfull -- run start
pm2 save
pm2 startupGoogle Cloud Run
Best for: Serverless containers, auto-scaling
Install gcloud CLI
Create
Dockerfile(same as Fly.io)Build and push:
bash
gcloud builds submit --tag gcr.io/PROJECT_ID/flowfull- Deploy:
bash
gcloud run deploy flowfull \
--image gcr.io/PROJECT_ID/flowfull \
--platform managed \
--region us-central1 \
--allow-unauthenticated \
--set-env-vars FLOWLESS_URL=https://your-instance.pubflow.comEnvironment Variables
Required Variables
env
# Server
PORT=3000
NODE_ENV=production
# Database
DATABASE_TYPE=postgresql
DATABASE_URL=postgresql://user:password@host:5432/db
# Flowless Integration
FLOWLESS_URL=https://your-instance.pubflow.com
BRIDGE_SECRET=your-bridge-secret-here
# Security
VALIDATION_MODE=STANDARDOptional Variables
env
# Cache
CACHE_ENABLED=true
REDIS_URL=redis://host:6379
# PASETO
PASETO_SECRET_KEY=your-paseto-secret
# Logging
LOG_MODE=productionDatabase Migration
Run migrations before deploying:
bash
# Local
bun run migrate
# Railway
railway run bun run migrate
# Fly.io
fly ssh console -C "bun run migrate"
# Vercel (use Vercel CLI)
vercel env pull .env.production
bun run migrateHealth Checks
Add health check endpoint:
typescript
app.get('/health', async (c) => {
try {
// Check database
await db.selectFrom('users').select('id').limit(1).execute();
// Check Redis (if enabled)
if (process.env.CACHE_ENABLED === 'true') {
await redis.ping();
}
return c.json({
status: 'healthy',
timestamp: new Date().toISOString()
});
} catch (error) {
return c.json({
status: 'unhealthy',
error: error.message
}, 503);
}
});Monitoring
Logging
typescript
import { logger } from './lib/logger';
app.use('*', async (c, next) => {
const start = Date.now();
await next();
const ms = Date.now() - start;
logger.info({
method: c.req.method,
path: c.req.path,
status: c.res.status,
duration: ms
});
});Error Tracking
Use Sentry for error tracking:
bash
bun add @sentry/nodetypescript
import * as Sentry from '@sentry/node';
Sentry.init({
dsn: process.env.SENTRY_DSN,
environment: process.env.NODE_ENV,
});
app.onError((err, c) => {
Sentry.captureException(err);
return c.json({ error: 'Internal server error' }, 500);
});Scaling
Horizontal Scaling
Flowfull is designed to scale horizontally:
- Stateless design - No local state
- Redis cache - Shared across instances
- Database pooling - Efficient connections
- Load balancer - Distribute traffic
Auto-Scaling
Configure auto-scaling based on:
- CPU usage (> 70%)
- Memory usage (> 80%)
- Request rate (> 1000 req/s)
Security
Production Checklist
- ✅ Use HTTPS only
- ✅ Set
NODE_ENV=production - ✅ Use strong
BRIDGE_SECRET - ✅ Enable
VALIDATION_MODE=STANDARDor higher - ✅ Use environment variables for secrets
- ✅ Enable rate limiting
- ✅ Set up CORS properly
- ✅ Use security headers
Security Headers
typescript
import { secureHeaders } from 'hono/secure-headers';
app.use('*', secureHeaders());Rate Limiting
typescript
import { rateLimiter } from 'hono-rate-limiter';
app.use('*', rateLimiter({
windowMs: 15 * 60 * 1000, // 15 minutes
max: 100, // Max 100 requests per window
}));Best Practices
✅ Do
- Use environment variables for configuration
- Run migrations before deployment
- Set up health checks
- Enable monitoring and logging
- Use HTTPS in production
- Set up auto-scaling
- Backup database regularly
❌ Don't
- Hardcode secrets
- Skip migrations
- Deploy without testing
- Use development mode in production
- Ignore error logs
- Skip health checks
Troubleshooting
Deployment Fails
Check:
- Build logs for errors
- Environment variables are set
- Database is accessible
- Dependencies are installed
App Crashes
Check:
- Error logs
- Database connection
- Redis connection (if enabled)
- Memory limits
Slow Performance
Check:
- Database indexes
- Cache hit rate
- Connection pool size
- Instance resources
Next Steps
- Database Setup - Configure production database
- HybridCache - Optimize with caching
- Environment Config - Manage configuration
Need Help?
- 🌐 Notside.com - Professional deployment services
- 📧 Email: contact@notside.com
- 💼 Services: DevOps, infrastructure, scaling