operations

Quick Deployment Setup Guide

This guide will help you set up deployments for HiveJournal to Vercel (frontend) and Railway (backend).

Prerequisites

  • GitHub repository connected
  • Vercel account (sign up at https://vercel.com)
  • Railway account (sign up at https://railway.app)
  • Supabase project created
  • Stripe account (for payments)
  • Resend account (for emails)

This is the easiest approach - connect your GitHub repo directly in Vercel and Railway dashboards.

Frontend - Vercel Setup

  1. Connect Repository

    • Go to Vercel Dashboard
    • Click "Add New Project"
    • Import your GitHub repository: jurowski/hivejournal-2026
    • Select the repository and click "Import"
  2. Configure Project Settings

    • Framework Preset: Next.js (auto-detected)
    • Root Directory: apps/frontend
    • Build Command: npm run build (auto-detected)
    • Output Directory: .next (auto-detected)
    • Install Command: npm install (auto-detected)
  3. Add Environment Variables Go to Project Settings > Environment Variables and add:

    NEXT_PUBLIC_SUPABASE_URL=your_supabase_project_url
    NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key
    NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=your_stripe_publishable_key
    NEXT_PUBLIC_API_URL=https://your-backend.railway.app
    
  4. Deploy

    • Click "Deploy"
    • Vercel will automatically deploy on every push to main branch

Backend - Railway Setup

  1. Connect Repository

    • Go to Railway Dashboard
    • Click "New Project"
    • Select "Deploy from GitHub repo"
    • Choose your repository: jurowski/hivejournal-2026
  2. Configure Service

    • Railway will auto-detect the backend
    • If not, click "New Service" > "GitHub Repo" > Select your repo
    • Set the Root Directory to apps/backend in service settings
    • Railway will use the railway.json configuration automatically
  3. Add Environment Variables Go to Service Settings > Variables and add:

    PORT=3001
    NODE_ENV=production
    SUPABASE_URL=your_supabase_project_url
    SUPABASE_SERVICE_ROLE_KEY=your_supabase_service_role_key
    STRIPE_SECRET_KEY=your_stripe_secret_key
    STRIPE_WEBHOOK_SECRET=your_stripe_webhook_secret
    RESEND_API_KEY=your_resend_api_key
    RESEND_FROM_EMAIL=noreply@hivejournal.com
    ALLOWED_ORIGINS=https://your-frontend.vercel.app,https://hivejournal.com
    JWT_SECRET=your_secure_random_string
    
  4. Get Backend URL

    • After deployment, go to Settings > Networking
    • Railway will generate a domain like your-backend.railway.app
    • Copy this URL and update:
      • Frontend's NEXT_PUBLIC_API_URL in Vercel
      • ALLOWED_ORIGINS in Railway to include your frontend URL
  5. Deploy

    • Railway will automatically deploy on every push to main branch
    • To trigger a manual redeploy, see RAILWAY_REDEPLOY.md

Option 2: GitHub Actions Deployment

If you prefer to use GitHub Actions for deployment, you'll need to set up additional secrets.

Required GitHub Secrets

Go to your repository Settings > Secrets and variables > Actions, and add:

For Vercel:

  • VERCEL_TOKEN - Get from Vercel Account Settings > Tokens
  • VERCEL_ORG_ID - Get from Vercel project settings
  • VERCEL_PROJECT_ID - Get from Vercel project settings

For Railway:

  • RAILWAY_TOKEN - Get by running railway login and railway link locally, then check .railway/token
  • RAILWAY_SERVICE_ID - Get from Railway service settings

For Build:

  • NEXT_PUBLIC_SUPABASE_URL
  • NEXT_PUBLIC_SUPABASE_ANON_KEY
  • NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY
  • NEXT_PUBLIC_API_URL

Getting Vercel IDs

  1. Install Vercel CLI: npm i -g vercel
  2. Run vercel link in the apps/frontend directory
  3. Check .vercel/project.json for orgId and projectId

Getting Railway Token and Service ID

  1. Install Railway CLI: npm i -g @railway/cli
  2. Run railway login
  3. Run railway link in the apps/backend directory
  4. Get token from ~/.railway/token or Railway dashboard
  5. Get service ID from Railway service settings URL or dashboard

Post-Deployment Steps

1. Update Environment Variables

After both are deployed:

  1. Get Backend URL from Railway

    • Copy the Railway-generated domain
  2. Update Frontend Environment Variables in Vercel

    • Update NEXT_PUBLIC_API_URL to your Railway backend URL
  3. Update Backend Environment Variables in Railway

    • Update ALLOWED_ORIGINS to include your Vercel frontend URL

2. Configure Webhooks

Stripe Webhook:

  • URL: https://your-backend.railway.app/api/payment/webhook
  • Events: checkout.session.completed, customer.subscription.updated, customer.subscription.deleted

Resend Webhook (if needed):

  • URL: https://your-backend.railway.app/api/email/webhook
  • Event: email.received

3. Test Deployment

  1. Visit your Vercel frontend URL
  2. Test sign up/sign in
  3. Test API health endpoint: https://your-backend.railway.app/health
  4. Test a full user flow

Troubleshooting

Frontend Issues

  • Check Vercel build logs in the dashboard
  • Verify all NEXT_PUBLIC_* environment variables are set
  • Check that NEXT_PUBLIC_API_URL points to your Railway backend

Backend Issues

  • Check Railway logs in the dashboard
  • Verify all environment variables are set
  • Check CORS configuration - ensure ALLOWED_ORIGINS includes your frontend URL
  • Test health endpoint: curl https://your-backend.railway.app/health

Common Issues

CORS Errors:

  • Make sure ALLOWED_ORIGINS in Railway includes your Vercel frontend URL
  • Format: https://your-app.vercel.app,https://hivejournal.com (comma-separated, no spaces)

Build Failures:

  • Check Node.js version matches (should be 18+)
  • Verify all dependencies are in package.json
  • Check build logs for specific errors

Environment Variable Issues:

  • Remember: NEXT_PUBLIC_* variables are exposed to the browser
  • Never put secrets in NEXT_PUBLIC_* variables
  • Redeploy after adding new environment variables

Next Steps

  • Set up custom domains (see DEPLOYMENT.md)
  • Configure monitoring and alerts
  • Set up database backups in Supabase
  • Configure email domain in Resend
DEPLOYMENT SETUP — Docs | HiveJournal