Deployment Steps

Step-by-step deployment instructions for production

Backend Docs API - Deployment Steps

Follow these exact steps to deploy to production.

Prerequisites Checklist

Before starting:

Part 1: Deploy Backend API to Railway

Step 1: Create Railway Project (5 minutes)

  1. Open https://railway.app/dashboard
  2. Click "New Project"
  3. Click "Empty Project"
  4. Name it: "backend-docs-api"
  5. Click the project to open it

Step 2: Generate Project Token (2 minutes)

  1. In Railway project, click "Settings"
  2. Scroll to "Tokens"
  3. Click "Create Token"
  4. Name it: "backend-docs-api-deploy"
  5. Copy the token

Step 3: Update .env.local (1 minute)

Add these lines to .env.local:

# Railway Docs API
RAILWAY_DOCS_TOKEN=<paste-token-here>
RAILWAY_PROJECTID_DOCS=<copy-from-railway-url>

To get project ID:

Step 4: Configure Railway Environment (5 minutes)

In Railway dashboard:

  1. Click "Variables" tab
  2. Add these variables (click "+ New Variable" for each):
NODE_ENV=production
JWT_SECRET=<copy from .env.local - MUST match backend-api>
SYSTEM_TOKEN=<copy from .env.local>
MONGODB_CONNECTION_STRING_TEST_MODULES=<copy from .env.local>
ALLOWED_ORIGINS=https://gograb.space,http://localhost:5010
  1. Click "Deploy" (or wait for auto-deploy)

Step 5: Deploy to Railway (3-5 minutes)

Run the deployment script:

cd /Users/fguijarro/developer/repos/editor
./deployment/deploy-docs-api.sh

Expected output:

๐Ÿ“š Backend Docs API Railway Deployment
โณ Deploying backend-docs-api...
โœ… Backend Docs API Deployment Triggered!

Step 6: Wait for Build (2-3 minutes)

  1. Go to Railway dashboard
  2. Click "Deployments" tab
  3. Watch build progress
  4. Wait for "Success" status

Step 7: Get Railway URL (1 minute)

  1. In Railway dashboard, click "Settings"
  2. Scroll to "Networking"
  3. Click "Generate Domain"
  4. Copy the URL (e.g., backend-docs-api-production.up.railway.app)

Step 8: Test Deployment (1 minute)

# Replace with your Railway URL
curl https://backend-docs-api-production.up.railway.app/docs-api/health

Expected response:

{
  "status": "ok",
  "timestamp": "2025-12-21T...",
  "service": "backend-docs-api",
  "database": "docs-database"
}

โœ… Backend API Deployed Successfully!


Part 2: Initial Data Sync

Step 9: Configure Sync Environment (1 minute)

# Set production API URL (use your Railway URL)
export DOCS_API_URL=https://backend-docs-api-production.up.railway.app/docs-api
export SYSTEM_TOKEN=<copy-from-env-local>

Step 10: Run Bulk Sync (10-15 minutes)

yarn docs:sync

Expected output:

โ˜๏ธ  Starting bulk sync to cloud...
๐Ÿ“ Docs path: /Users/.../editor/docs
๐ŸŒ API URL: https://backend-docs-api-production.up.railway.app/docs-api

๐Ÿ” Scanning documentation files...
๐Ÿ“Š Found 450 markdown files

๐Ÿ“ค Uploading batch 1/9 (50 files)...
โœ… Batch 1 uploaded: 50 created, 0 updated
...

โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
โ•‘     โ˜๏ธ  Bulk Sync Complete           โ•‘
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

โœ… Uploaded: 450 files
โŒ Failed:   0 files
โฑ๏ธ  Duration: 12.5s

Step 11: Verify Data in MongoDB (2 minutes)

  1. Go to MongoDB Atlas dashboard
  2. Click "Browse Collections"
  3. Select docs-database
  4. Verify collections:
    • doc-files - Should have ~450 documents
    • doc-projects - Should have project configs
    • page-views - Empty initially
    • search-events - Empty initially

โœ… Data Synced Successfully!


Part 3: Deploy Frontend

Step 12: Update Production Environment (1 minute)

Edit apps/docs-angular/src/environments/environment.prod.ts:

export const environment = {
  production: true,
  docsApiUrl: 'https://backend-docs-api-production.up.railway.app/docs-api',
  wsUrl: 'wss://backend-docs-api-production.up.railway.app',
  enableCloudSync: true,
  enableAnalytics: true,
};

Replace backend-docs-api-production.up.railway.app with your actual Railway URL.

Step 13: Build Frontend (2-3 minutes)

nx build docs-angular --configuration=production

Expected output:

โœ” Browser application bundle generation complete.
โœ” Copying assets complete.
โœ” Index html generation complete.

Output location: dist/apps/docs-angular/browser

Step 14: Test Build Locally (2 minutes)

nx serve-static docs-angular

Navigate to http://localhost:5010 and verify:

Step 15: Deploy Frontend (5-10 minutes)

Option A: Copy to gograb.space/docs

If you have server access:

scp -r dist/apps/docs-angular/browser/* [email protected]:/var/www/gograb.space/docs/

Option B: Deploy to Railway Static

  1. Create new Railway service: "docs-angular-static"
  2. Connect to GitHub repo
  3. Build command: nx build docs-angular --configuration=production
  4. Start command: npx serve dist/apps/docs-angular/browser -p $PORT
  5. Generate domain

Option C: Deploy to Vercel

cd dist/apps/docs-angular/browser
vercel --prod

Step 16: Verify Production Frontend (2 minutes)

Navigate to: https://gograb.space/docs (or your deployment URL)

Test:

โœ… Frontend Deployed Successfully!


Part 4: Post-Deployment Verification

Step 17: End-to-End Test (5 minutes)

  1. Test Public Access:

    • Navigate to https://gograb.space/docs
    • Browse documentation
    • Perform searches
    • Check different projects
  2. Test Admin Access:

    • Go to https://gograb.space/docs/admin
    • Login with admin password
    • Check analytics dashboard
    • Verify cloud file manager
  3. Test Real-Time Sync (if applicable):

    • Edit a file locally
    • Run yarn docs:watch (with production URL)
    • Verify change appears online

Step 18: Monitor for 24 Hours

  1. Railway Dashboard:

    • Monitor resource usage
    • Check for errors in logs
    • Verify health checks passing
  2. MongoDB Atlas:

    • Monitor connection count
    • Check query performance
    • Verify storage usage
  3. Frontend:

    • Check for JavaScript errors
    • Monitor page load times
    • Verify analytics tracking

Troubleshooting

API Deployment Failed

Check:

  1. Railway build logs for errors
  2. Environment variables are all set
  3. MongoDB connection string is correct
  4. Dockerfile syntax is valid

Fix:

# Redeploy
./deployment/deploy-docs-api.sh

Initial Sync Failed

Check:

  1. DOCS_API_URL is correct
  2. SYSTEM_TOKEN matches Railway
  3. API is responding to health checks
  4. MongoDB is accessible

Fix:

# Verify API
curl https://your-api.railway.app/docs-api/health

# Retry sync
yarn docs:sync

Frontend Build Failed

Check:

  1. TypeScript errors: nx lint docs-angular
  2. Environment file is correct
  3. All imports are valid
  4. Bundle size within limits

Fix:

# Clear cache and rebuild
nx reset
nx build docs-angular --configuration=production

Frontend Can't Connect to API

Check:

  1. environment.prod.ts has correct Railway URL
  2. CORS is configured in Railway environment
  3. API is deployed and healthy
  4. Browser console for CORS errors

Fix:

  1. Update ALLOWED_ORIGINS in Railway
  2. Redeploy API
  3. Rebuild frontend

Success Criteria

Deployment is complete when:

Timeline Summary

Step Time Status
Create Railway project 5 min โณ User action
Configure environment 5 min โณ User action
Deploy API 3-5 min โณ User action
Initial sync 10-15 min โณ User action
Build frontend 2-3 min โณ User action
Deploy frontend 5-10 min โณ User action
Total 30-45 min Ready

Quick Command Reference

# Deploy API
./deployment/deploy-docs-api.sh

# Sync data
export DOCS_API_URL=https://your-api.railway.app/docs-api
yarn docs:sync

# Build frontend
nx build docs-angular --configuration=production

# Test locally
yarn serve:backend-docs
yarn docs:sync
yarn serve:docs

Support

Congratulations! ๐ŸŽ‰

You're ready to deploy! Follow these steps and your documentation will be live at gograb.space/docs.

Implementation Status: โœ… Complete
Deployment Status: โณ Awaiting user action
Documentation Status: โœ… Complete