Spaces:
Sleeping
Download DEPLOYMENT.md from axeronis/microfunnel-api: direct link, hf CLI and curl.
- Browser
- Download file 5.2 kB
-
https://huggingface.co/spaces/axeronis/microfunnel-api/resolve/main/DEPLOYMENT.md
- Command line
-
hf download hf://spaces/axeronis/microfunnel-api/DEPLOYMENT.md
-
curl -L -o DEPLOYMENT.md https://huggingface.co/spaces/axeronis/microfunnel-api/resolve/main/DEPLOYMENT.md
π¦ PRODUCTION DEPLOYMENT GUIDE
π― Stack Overview
- Backend: Railway (Python/FastAPI)
- Frontend: Vercel (Next.js)
- Database: Supabase (PostgreSQL)
- Code: GitHub
π STEP 1: Push Code to GitHub
Create GitHub Repository:
# In your project root
git init
git add .
git commit -m "Initial commit - MicroFunnel AI Platform"
# Create repo on GitHub, then:
git remote add origin https://github.com/YOUR_USERNAME/microfunnel.git
git branch -M main
git push -u origin main
π STEP 2: Deploy Backend to Railway
2.1. Create Railway Project:
- Go to https://railway.app
- Sign up with GitHub
- Click New Project β Deploy from GitHub repo
- Select your
microfunnelrepository - Railway will auto-detect Python project
2.2. Configure Environment Variables:
Railway Dashboard β Your Project β Variables β Add these:
# Database (Supabase)
DATABASE_URL=postgresql://postgres.PROJECT_ID:PASSWORD@aws-0-eu-central-1.pooler.supabase.com:6543/postgres
# Supabase
SUPABASE_URL=https://kmdhrrkfzonbncxvjhjj.supabase.co
SUPABASE_KEY=<your-anon-key>
SUPABASE_SERVICE_KEY=<your-service-key>
# AI
GEMINI_API_KEY=<your-gemini-key>
# JWT Secret (generate new: openssl rand -hex 32)
SECRET_KEY=<generate-new-32-char-secret>
ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=43200
# Environment
ENVIRONMENT=production
DEBUG=false
# CORS (will update after Vercel deployment)
ALLOWED_ORIGINS=https://your-app.vercel.app
FRONTEND_URL=https://your-app.vercel.app
# Optional: Redis (Railway Add-on)
# REDIS_URL=<auto-provided-by-railway>
2.3. Get Railway Domain:
After deployment, Railway will provide a domain like:
https://microfunnel-production.up.railway.app
Save this URL! You'll need it for Vercel.
π STEP 3: Deploy Frontend to Vercel
3.1. Import Project:
- Go to https://vercel.com
- Sign up with GitHub
- Click Add New β Project
- Import your
microfunnelrepository - Vercel auto-detects Next.js
3.2. Configure Build Settings:
- Framework Preset: Next.js
- Root Directory:
frontend - Build Command:
npm run build - Output Directory:
.next
3.3. Add Environment Variables:
Vercel Dashboard β Settings β Environment Variables:
# Backend API (Railway domain from Step 2.3)
NEXT_PUBLIC_API_URL=https://microfunnel-production.up.railway.app
# Webhook URL (same as backend)
NEXT_PUBLIC_WEBHOOK_URL=https://microfunnel-production.up.railway.app
# Supabase
NEXT_PUBLIC_SUPABASE_URL=https://kmdhrrkfzonbncxvjhjj.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=<your-anon-key>
3.4. Deploy:
Click Deploy β Wait 2-3 minutes
Vercel will provide a domain like:
https://microfunnel.vercel.app
π STEP 4: Update CORS in Railway
Now that you have Vercel domain, update Railway:
Railway β Variables β Update:
ALLOWED_ORIGINS=https://microfunnel.vercel.app,https://www.microfunnel.vercel.app
FRONTEND_URL=https://microfunnel.vercel.app
Click Redeploy (Railway auto-redeploys on variable change)
π STEP 5: Run Database Migrations
Via Railway CLI:
# Install Railway CLI
npm install -g @railway/cli
# Login
railway login
# Link to your project
railway link
# Run migrations
railway run alembic upgrade head
Or manually via Supabase SQL Editor:
Run all migrations from backend/alembic/versions/*.py
π STEP 6: Test Deployment
Backend Health Check:
curl https://microfunnel-production.up.railway.app/health
Expected:
{
"status": "healthy",
"database": "connected",
"ai_engine": "ready"
}
Frontend:
Open: https://microfunnel.vercel.app
- Login should work
- Dashboard should load
- Chats should connect
Webhooks (WhatsApp/Instagram):
Webhook URLs will now use Railway domain:
https://microfunnel-production.up.railway.app/api/v1/webhook/meta/whatsapp/{tenant_id}
Update these in Meta Developers β Webhooks
π Continuous Deployment
Auto-deploy on Git Push:
# Make changes
git add .
git commit -m "Feature: Add X"
git push
# Railway auto-deploys backend
# Vercel auto-deploys frontend
π° Pricing Estimates
- Railway: $5-20/month (based on usage)
- Vercel: Free tier (Pro: $20/month)
- Supabase: Free tier (Pro: $25/month)
Total: ~$0-50/month depending on traffic
π Troubleshooting
Railway Build Fails:
- Check logs: Railway β Deployments β View Logs
- Common issue: Missing env vars
Vercel Build Fails:
- Check build logs in Vercel dashboard
- Common issue:
NEXT_PUBLIC_*vars not set
CORS Errors:
- Verify
ALLOWED_ORIGINSin Railway includes your Vercel domain - Check browser console for exact error
Database Connection Fails:
- Verify
DATABASE_URLin Railway - Check Supabase is not paused (free tier pauses after 7 days inactivity)
π You're Live!
Frontend: https://microfunnel.vercel.app Backend: https://microfunnel-production.up.railway.app Database: Supabase (always-on)
No more ngrok! Professional infrastructure! π¦