Complete step-by-step guide to set up all required external services for your Cloudflare deployment.
Estimated Time: 15-20 minutes Cost: All services have generous free tiers
You need to set up 4 external services:
- ✅ Neon PostgreSQL - Database (5 min)
- ✅ Upstash Redis - Caching & Sessions (5 min)
- ✅ Stripe - Payment Processing (5 min)
- ✅ Resend - Email Delivery (5 min)
- Go to https://neon.tech
- Click Sign Up or Get Started
- Sign up with GitHub (recommended) or email
- Verify your email if needed
-
Click "New Project" or "Create a project"
-
Fill in details:
Project Name: mystic-ecom-production Database Name: main PostgreSQL Version: 16 (latest) Region: Choose closest to your usersRegion Recommendations:
- US users:
US East (Ohio)orUS West (Oregon) - EU users:
Europe (Frankfurt)orEurope (London) - Asia users:
Asia Pacific (Singapore)
- US users:
-
Click "Create Project"
-
After project creation, you'll see the dashboard
-
Click on "Connection Details" or look for the connection string
-
You'll see something like:
postgresql://username:password@ep-cool-name-12345678.us-east-2.aws.neon.tech/main?sslmode=require -
IMPORTANT: Copy the ENTIRE connection string including
?sslmode=require -
Save it securely - you'll need this for Cloudflare environment variables
Create a temporary file to store your credentials:
# Create a secure credentials file (DO NOT COMMIT THIS) cat > ~/deployment-credentials.txt << 'EOF' # DEPLOYMENT CREDENTIALS - DELETE AFTER DEPLOYMENT # Generated: $(date) # Neon PostgreSQL DATABASE_URL=PASTE_YOUR_CONNECTION_STRING_HERE # Upstash Redis (fill in later) REDIS_URL= # Stripe (fill in later) STRIPE_SECRET_KEY= STRIPE_PUBLISHABLE_KEY= STRIPE_WEBHOOK_SECRET= # Resend (fill in later) RESEND_API_KEY= EOF
- In Neon dashboard, go to Settings
- Enable Auto-suspend to save costs (database pauses when inactive)
- Set Auto-suspend delay: 5 minutes (default)
- Enable Autoscaling for better performance
You'll need these later:
- ✅ Connection string (DATABASE_URL)
- ✅ Database name:
main - ✅ PostgreSQL version: 16
✅ Neon Setup Complete! We'll import the schema later.
- Go to https://upstash.com
- Click Sign Up or Get Started for Free
- Sign up with GitHub (recommended) or email
-
Click "Create Database"
-
Fill in details:
Name: mystic-ecom-production Type: Regional (faster, recommended) Region: Same as your Neon database TLS: Enabled (REQUIRED - should be enabled by default) Eviction: No eviction (recommended for session storage) -
Click "Create"
-
After creation, click on your database
-
Scroll down to "REST API" or "Connection Details"
-
Look for "Redis Connection URL"
-
Copy the connection string that starts with
rediss://rediss://default:AbCdEf123456...@us1-example-12345.upstash.io:6379 -
IMPORTANT: Make sure it starts with
rediss://(double 's' for SSL) -
Save it to your credentials file:
# Edit your credentials file nano ~/deployment-credentials.txt # Add your Redis URL
- In Upstash dashboard, click on your database
- Go to Settings
- Verify:
- ✅ TLS is enabled
- ✅ Region is correct
- ✅ Eviction policy:
noeviction(for sessions)
If you have redis-cli installed:
redis-cli -u "YOUR_REDIS_URL" ping
# Should return: PONG✅ Upstash Redis Setup Complete!
- Go to https://stripe.com
- Click "Start now" or "Sign up"
- Fill in your business details
- Verify your email
- Complete the onboarding questionnaire
- Provide business information
- Set up bank account for payouts (can do later)
-
In Stripe Dashboard, click "Developers" in top right
-
Click "API keys" in left sidebar
-
You'll see two environments:
- Test mode (for development)
- Live mode (for production)
-
Toggle to "Live mode" using the switch in sidebar
-
Copy your keys:
Publishable key: pk_live_xxxxxxxxxxxxx Secret key: sk_live_xxxxxxxxxxxxx (click "Reveal" to see) -
Save them to your credentials file:
nano ~/deployment-credentials.txt # Add: # STRIPE_SECRET_KEY=sk_live_xxxxxxxxxxxxx # STRIPE_PUBLISHABLE_KEY=pk_live_xxxxxxxxxxxxx
For now, just note that you'll need to:
- Create webhook endpoint at:
https://your-site.pages.dev/api/webhooks/stripe - Subscribe to payment events
- Copy the webhook secret
Temporary placeholder for now:
# Add to credentials file
STRIPE_WEBHOOK_SECRET=whsec_SETUP_AFTER_DEPLOYMENTWhile you're here, also copy your Test mode keys for local development:
# Switch to "Test mode"
# Copy keys to .env.local for local testing✅ Stripe Setup Complete! (Webhook will be configured after deployment)
- Go to https://resend.com
- Click "Start Building" or "Sign Up"
- Sign up with email
- Verify your email address
-
After login, go to "API Keys" in left sidebar
-
Click "Create API Key"
-
Fill in details:
Name: mystic-ecom-production Permission: Full Access (or Sending access) -
Click "Create"
-
Copy the API key immediately - it won't be shown again!
re_xxxxxxxxxxxxxxxxxxxxxxxxxxxxx -
Save it to your credentials file:
nano ~/deployment-credentials.txt # Add: # RESEND_API_KEY=re_xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
For testing, you can use Resend's default domain (onboarding.resend.dev)
For production, add your own domain:
- Go to "Domains" in left sidebar
- Click "Add Domain"
- Enter your domain (e.g.,
mystic-ecom.com) - Click "Add"
- Add DNS records shown by Resend to your domain's DNS settings
- Wait for verification (usually 5-30 minutes)
For now, use the default:
# Add to credentials file
EMAIL_FROM=onboarding@resend.dev
EMAIL_FROM_NAME=Mystic EcomYou can send a test email from Resend dashboard:
- Go to "Emails" → "Send Test Email"
- Enter your email
- Send to verify it's working
✅ Resend Setup Complete!
Generate random secrets for your application:
# Generate 4 secrets (run this command 4 times)
node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"Run the command 4 times and save each output:
# Add to credentials file
SESSION_SECRET=FIRST_GENERATED_SECRET
JWT_SECRET=SECOND_GENERATED_SECRET
CSRF_SECRET=THIRD_GENERATED_SECRET
DOWNLOAD_TOKEN_SECRET=FOURTH_GENERATED_SECRETYour ~/deployment-credentials.txt should now look like this:
# DEPLOYMENT CREDENTIALS - DELETE AFTER DEPLOYMENT
# Generated: 2025-11-07
# Neon PostgreSQL
DATABASE_URL=postgresql://user:pass@ep-xxx.neon.tech/main?sslmode=require
# Upstash Redis
REDIS_URL=rediss://default:pass@xxx.upstash.io:6379
# Security Secrets
SESSION_SECRET=abc123...
JWT_SECRET=def456...
CSRF_SECRET=ghi789...
DOWNLOAD_TOKEN_SECRET=jkl012...
# Stripe
STRIPE_SECRET_KEY=sk_live_xxxxxxxxxxxxx
STRIPE_PUBLISHABLE_KEY=pk_live_xxxxxxxxxxxxx
STRIPE_WEBHOOK_SECRET=whsec_SETUP_AFTER_DEPLOYMENT
# Resend
RESEND_API_KEY=re_xxxxxxxxxxxxx
EMAIL_FROM=onboarding@resend.dev
EMAIL_FROM_NAME=Mystic Ecom
# Admin
ADMIN_EMAIL=your-email@example.com
# Site Config
PUBLIC_SITE_URL=https://your-project.pages.dev
NODE_ENV=productionNow that Neon is set up, let's import your database schema.
# Check for schema files
ls -la database/# Set your Neon connection string
export DATABASE_URL="your-neon-connection-string"
# Import schema
psql "$DATABASE_URL" < database/schema.sql
# Or if you have migrations
npm run db:migrate # if this script existsYou'll need to create your database tables. Check if there are SQL files in your project:
# Search for SQL files
find . -name "*.sql" -type fLet me check your project structure - I'll help you find and import the schema in the next step.
Mark off as you complete each service:
-
Neon PostgreSQL
- Account created
- Project created
- Connection string saved
- Schema imported (we'll do this next)
-
Upstash Redis
- Account created
- Database created (with TLS enabled)
- Connection URL saved (starts with
rediss://)
-
Stripe
- Account created and activated
- Live mode API keys obtained
- Keys saved securely
- Webhook endpoint noted (configure after deployment)
-
Resend
- Account created
- API key generated and saved
- Email sender configured
-
Security Secrets
- 4 random secrets generated
- All secrets saved to credentials file
IMPORTANT:
- Never commit
~/deployment-credentials.txtto git - Delete this file after deployment is complete
- Store credentials in a password manager for safekeeping
- Use environment variables in Cloudflare, not hardcoded values
- Rotate secrets periodically for security
All services offer generous free tiers:
Neon PostgreSQL (Free):
- 10 projects
- 3 GB storage per project
- 1 concurrent connection
- Unlimited compute hours
Upstash Redis (Free):
- 10,000 commands/day
- 256 MB storage
- TLS included
Stripe (Free):
- No monthly fees
- Pay only per transaction (2.9% + $0.30)
- Unlimited API calls
Resend (Free):
- 3,000 emails/month
- 100 emails/day
- 1 domain
# Test connection
psql "$DATABASE_URL" -c "SELECT version();"
# If fails, check:
# 1. Connection string has ?sslmode=require
# 2. Database is not suspended (wake it in dashboard)
# 3. No firewall blocking port 5432# Test connection
redis-cli -u "$REDIS_URL" ping
# If fails, check:
# 1. URL starts with rediss:// (double 's')
# 2. Correct password
# 3. TLS is enabled in Upstash- Webhooks are configured AFTER deployment
- You need your live Cloudflare URL first
- Test with Stripe CLI locally before production
- Verify email address in Resend
- Check API key is correct
- Monitor sending limits
- Add custom domain for better deliverability
Once all services are set up:
- ✅ You have all credentials saved
- ✅ Import database schema (next step)
- ✅ Test connections
- ✅ Proceed to Cloudflare Pages deployment
- ✅ Add environment variables in Cloudflare dashboard
Continue to: Cloudflare Pages deployment (Step 2 in CLOUDFLARE_QUICKSTART.md)
Need Help?
- Neon Docs: https://neon.tech/docs
- Upstash Docs: https://docs.upstash.com
- Stripe Docs: https://stripe.com/docs
- Resend Docs: https://resend.com/docs