Student starter code (30% baseline)
index.html- Main HTML pagescript.js- JavaScript logicstyles.css- Styling and layoutpackage.json- Dependenciessetup.sh- Setup scriptREADME.md- Instructions (below)๐ก Download the ZIP, extract it, and follow the instructions below to get started!
Welcome to your final activity! Learn how to deploy your Quest Tracker app to production using modern hosting platforms (Netlify and Railway).
By completing this activity, you will:
IMPORTANT: This template includes WORKING deployment configurations! You can review them immediately:
npm install
npm start
frontend/netlify.toml (Netlify config)backend/railway.toml (Railway config)scripts/ folder (automated deployment)65% of the configuration is implemented for you:
๐ก Pro Tip: This activity includes 5 advanced TODO markers embedded in the deployment scripts. Look for detailed comments marked with
TODO 1throughTODO 5in:
backend/.env.example(Environment Configuration - Easy)scripts/deploy-backend.js(Build Process - Medium)scripts/deploy-frontend.js(Deployment Script - Medium)scripts/health-check.js(Error Monitoring - Hard)- See TODO 5 below for CI/CD Pipeline instructions
Create accounts on hosting platforms and connect your GitHub repository.
Platforms Required:
Success Criteria:
Set up production environment variables for both frontend and backend.
Frontend Variables to Configure:
REACT_APP_API_URL=https://your-api.railway.app
REACT_APP_API_KEY=your-production-api-key
REACT_APP_ENVIRONMENT=production
Backend Variables to Configure:
NODE_ENV=production
DATABASE_URL=postgresql://user:pass@host:port/db
JWT_SECRET=your-jwt-secret
Success Criteria:
Deploy your Quest Tracker API to Railway using the provided configuration.
Steps:
backendSuccess Criteria:
/healthDeploy your Quest Tracker frontend to Netlify using the provided configuration.
Steps:
frontend, command: npm run build)Success Criteria:
Implement automated health checks and monitoring for your deployed application.
Requirements:
Success Criteria:
The frontend/netlify.toml file configures your frontend deployment:
[build]
publish = "dist" # Output directory after build
command = "npm run build" # Build command
[[redirects]]
from = "/api/*" # Proxy API requests
to = "https://your-api.railway.app/api/:splat"
status = 200
[[redirects]]
from = "/*" # SPA routing support
to = "/index.html"
status = 200
Key Features:
The backend/railway.toml file configures your backend deployment:
[build]
builder = "NIXPACKS" # Auto-detect Node.js
buildCommand = "npm install --production"
[deploy]
startCommand = "npm start" # Command to run server
healthcheckPath = "/health" # Health check endpoint
[env]
NODE_ENV = "production" # Production mode
PORT = "$PORT" # Railway assigns port
Key Features:
Environment variables keep sensitive data (API keys, database credentials) out of your code. They allow different configurations for development and production.
.env.example)# API Configuration
REACT_APP_API_URL=https://your-api.railway.app
REACT_APP_API_KEY=your-production-api-key
REACT_APP_ENVIRONMENT=production
How to Set in Netlify:
.env.example)# Server Configuration
NODE_ENV=production
PORT=3000
# Database (Railway provides automatically)
DATABASE_URL=postgresql://user:pass@host:port/db
# Security (generate with: node -e "console.log(require('crypto').randomBytes(32).toString('hex'))")
JWT_SECRET=your-secure-random-secret
API_RATE_LIMIT=1000
How to Set in Railway:
# View deployment guide
npm start
# Run health checks
npm run health-check
# Deploy frontend (requires Netlify CLI)
npm run deploy:frontend
# Deploy backend (requires Railway CLI)
npm run deploy:backend
# Install Netlify CLI
npm install -g netlify-cli
netlify login
# Install Railway CLI
npm install -g @railway/cli
railway login
Run the provided health check script to validate your deployment:
npm run health-check
The script checks:
/health)Test these critical features after deployment:
# Test API response time
curl -w "Time: %{time_total}s\n" https://your-api.railway.app/health
# Test frontend load time (use browser DevTools)
# Network tab โ Reload page โ Check "Load" time (should be < 3s)
Issue: API calls fail with CORS errors
Solution: Check Netlify redirects in netlify.toml point to correct Railway URL
Issue: Environment variables not loading Solution: Verify variables are set in platform dashboard and redeploy
Issue: Backend health check fails
Solution: Verify /health endpoint exists and Railway service is running
Issue: Build fails on Netlify
Solution: Check build logs for errors, verify npm run build works locally
Ready to level up your deployment skills? Try these bonus features:
OBJECTIVE: Create a complete CI/CD pipeline with automated testing and deployment
WHAT TO DO:
SUCCESS CRITERIA: โ GitHub Actions workflow file is created and committed โ Pipeline runs tests before deploying (fail fast on test errors) โ Manual approval is required before production deployment โ Health checks run automatically after deployment โ Pipeline fails and rolls back if health checks fail โ Deployment status is posted to Slack/Discord (bonus)
LEARNING GOALS:
DEPLOYMENT STAGES:
EXAMPLE WORKFLOW STRUCTURE:
# .github/workflows/deploy.yml
name: Deploy Quest Tracker
on:
push:
branches: [ main ]
workflow_dispatch: # Manual trigger
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Install and Test Backend
run: |
cd backend
npm ci
npm test
- name: Install and Test Frontend
run: |
cd frontend
npm ci
npm test
deploy-staging:
needs: test
runs-on: ubuntu-latest
environment: staging
steps:
- uses: actions/checkout@v3
- name: Deploy to Staging
run: |
npm run deploy:backend
npm run deploy:frontend
- name: Run Health Checks
run: npm run health-check
deploy-production:
needs: deploy-staging
runs-on: ubuntu-latest
environment: production # This adds manual approval gate
steps:
- uses: actions/checkout@v3
- name: Deploy to Production
run: |
npm run deploy:backend
npm run deploy:frontend
- name: Run Production Health Checks
run: npm run health-check
HINT: Use GitHub Environments (Settings -> Environments) to add protection rules HINT: Add RAILWAY_TOKEN and NETLIFY_AUTH_TOKEN to GitHub Secrets HINT: Use actions/checkout@v3, actions/setup-node@v3 for setup HINT: Test the workflow locally with act (
nektos/actYour deployment is complete when:
Once you complete this project, you'll have:
This is a major milestone! Your Quest Tracker app is now live on the internet for the world to use. You've learned the complete journey from development to production deployment!
Need Help?
npm start before deployingHappy deploying! ๐