7.7 KiB
🚀 ALwrity Deployment Guide
Vercel Deployment Strategy
Since Vercel is optimized for frontend applications, we'll deploy the frontend on Vercel and the backend on a separate platform.
Architecture Overview
Frontend (Vercel) ←→ Backend (Railway/Render) ←→ Database (SQLite/PostgreSQL)
🎯 Step-by-Step Deployment
Part 1: Deploy Backend (Railway - Recommended)
Option A: Railway (Recommended)
-
Install Railway CLI:
npm install -g @railway/cli -
Login to Railway:
railway login -
Initialize Project:
cd backend railway init -
Add Environment Variables:
railway variables set GEMINI_API_KEY=your_gemini_key railway variables set OPENAI_API_KEY=your_openai_key railway variables set ANTHROPIC_API_KEY=your_anthropic_key railway variables set MISTRAL_API_KEY=your_mistral_key railway variables set TAVILY_API_KEY=your_tavily_key railway variables set EXA_API_KEY=your_exa_key railway variables set SERPER_API_KEY=your_serper_key railway variables set CLERK_SECRET_KEY=your_clerk_secret railway variables set GSC_REDIRECT_URI=https://your-frontend.vercel.app/gsc/callback railway variables set WORDPRESS_REDIRECT_URI=https://your-frontend.vercel.app/wp/callback railway variables set WIX_REDIRECT_URI=https://your-frontend.vercel.app/wix/callback -
Deploy:
railway up -
Get Backend URL:
railway domainCopy the URL (e.g.,
https://your-app.railway.app)
Option B: Render
- Go to render.com and connect your GitHub
- Create a new "Web Service"
- Select your repository
- Configure:
- Build Command:
pip install -r requirements.txt - Start Command:
python start_alwrity_backend.py - Environment: Python 3
- Build Command:
- Add all environment variables in the dashboard
- Deploy and get your backend URL
Part 2: Deploy Frontend (Vercel)
1. Prepare Frontend for Production
Create a .env.production file in the frontend directory:
REACT_APP_API_URL=https://your-backend-url.railway.app
REACT_APP_ENVIRONMENT=production
2. Deploy to Vercel
-
Connect to Vercel:
- Go to vercel.com
- Click "New Project"
- Import your GitHub repository
-
Configure Project:
- Framework Preset: Create React App
- Root Directory:
frontend - Build Command:
npm run build - Output Directory:
build
-
Add Environment Variables:
REACT_APP_API_URL = https://your-backend-url.railway.app REACT_APP_ENVIRONMENT = production -
Deploy:
- Click "Deploy"
- Wait for deployment to complete
- Get your frontend URL (e.g.,
https://your-app.vercel.app)
3. Update Backend URLs
After getting your frontend URL, update the backend environment variables:
# Update redirect URIs with your actual Vercel URL
railway variables set GSC_REDIRECT_URI=https://your-app.vercel.app/gsc/callback
railway variables set WORDPRESS_REDIRECT_URI=https://your-app.vercel.app/wp/callback
railway variables set WIX_REDIRECT_URI=https://your-app.vercel.app/wix/callback
🔧 Alternative: Full-Stack on Vercel (Advanced)
If you want to deploy everything on Vercel, you can use Vercel's serverless functions:
1. Create API Routes
Create api/ directory in your project root:
api/
├── auth/
│ └── [...auth].ts
├── content/
│ └── generate.ts
└── seo/
└── analyze.ts
2. Convert FastAPI to Vercel Functions
This requires significant refactoring of your backend code to work with Vercel's serverless functions.
3. Deploy as Monorepo
# Install Vercel CLI
npm i -g vercel
# Deploy
vercel --prod
🛠️ Environment Variables Checklist
Backend Environment Variables:
# AI API Keys
GEMINI_API_KEY=your_gemini_key
OPENAI_API_KEY=your_openai_key
ANTHROPIC_API_KEY=your_anthropic_key
MISTRAL_API_KEY=your_mistral_key
# Research APIs
TAVILY_API_KEY=your_tavily_key
EXA_API_KEY=your_exa_key
SERPER_API_KEY=your_serper_key
# Authentication
CLERK_SECRET_KEY=your_clerk_secret
# OAuth Redirects (update with your Vercel URL)
GSC_REDIRECT_URI=https://your-app.vercel.app/gsc/callback
WORDPRESS_REDIRECT_URI=https://your-app.vercel.app/wp/callback
WIX_REDIRECT_URI=https://your-app.vercel.app/wix/callback
Frontend Environment Variables:
REACT_APP_API_URL=https://your-backend-url.railway.app
REACT_APP_ENVIRONMENT=production
🚀 Post-Deployment Steps
1. Test Your Deployment
- Visit your Vercel URL
- Complete the onboarding process
- Test content generation
- Verify OAuth integrations
2. Configure Custom Domain (Optional)
- In Vercel dashboard, go to your project
- Click "Domains"
- Add your custom domain
- Update redirect URIs with custom domain
3. Monitor Performance
- Check Vercel analytics
- Monitor Railway/Render logs
- Set up error tracking (Sentry, etc.)
🔍 Troubleshooting
Common Issues:
-
CORS Errors:
- Add your Vercel domain to backend CORS settings
- Update
allowed_originsin FastAPI CORS middleware
-
Environment Variables:
- Ensure all variables are set in both platforms
- Check variable names match exactly
-
OAuth Redirects:
- Update all redirect URIs with production URLs
- Test OAuth flows end-to-end
-
Database Issues:
- Consider upgrading to PostgreSQL for production
- Set up database backups
Performance Optimization:
-
Frontend:
- Enable Vercel's edge caching
- Optimize bundle size
- Use CDN for static assets
-
Backend:
- Implement connection pooling
- Add caching layers
- Monitor memory usage
📊 Monitoring & Maintenance
Health Checks:
- Frontend:
https://your-app.vercel.app/health - Backend:
https://your-backend.railway.app/health
Logs:
- Vercel: Built-in function logs
- Railway:
railway logs - Render: Dashboard logs section
Scaling:
- Vercel: Automatic scaling
- Railway: Manual scaling in dashboard
- Render: Auto-scaling available
🎯 Recommended Architecture
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Frontend │ │ Backend │ │ Database │
│ (Vercel) │◄──►│ (Railway) │◄──►│ (PostgreSQL) │
│ │ │ │ │ │
│ • React App │ │ • FastAPI │ │ • User Data │
│ • Static Files │ │ • AI Services │ │ • Content │
│ • CDN Cached │ │ • OAuth APIs │ │ • Analytics │
└─────────────────┘ └─────────────────┘ └─────────────────┘
This setup provides:
- ✅ Fast frontend delivery via Vercel's global CDN
- ✅ Scalable backend with Railway's infrastructure
- ✅ Reliable database with PostgreSQL
- ✅ Easy maintenance with separate concerns
- ✅ Cost-effective scaling based on usage
🚀 Next Steps
- Deploy backend to Railway/Render
- Deploy frontend to Vercel
- Configure environment variables
- Test all integrations
- Set up monitoring
- Configure custom domain (optional)
Your ALwrity platform will be live and accessible worldwide! 🌍