Skip to main content

Deployment Overview

TalentG uses Vercel for frontend deployment and Supabase for backend services, with automated CI/CD pipelines for seamless deployments.

Deployment Architecture

Vercel Configuration

Project Setup

  1. Connect Repository:
    • Go to vercel.com
    • Import GitHub repository
    • Configure build settings
  2. Build Configuration:
    {
      "buildCommand": "pnpm iso:build",
      "outputDirectory": ".next",
      "installCommand": "pnpm install",
      "framework": "nextjs"
    }
    
  3. Environment Variables:
    • Add production environment variables
    • Configure staging environment
    • Set up preview deployments

Deployment Settings

// vercel.json
{
  "builds": [
    {
      "src": "package.json",
      "use": "@vercel/next"
    }
  ],
  "routes": [
    {
      "src": "/api/(.*)",
      "dest": "/api/$1"
    }
  ],
  "functions": {
    "app/api/**/*.ts": {
      "maxDuration": 30
    }
  }
}

Branch Strategy

Main Branch (Production)

  • Trigger: Push to main branch
  • Environment: Production
  • URL: https://talentg.vercel.app
  • Database: Production Supabase
  • Features: All production features enabled

Staging Branch

  • Trigger: Push to staging branch
  • Environment: Staging
  • URL: https://talentg-staging.vercel.app
  • Database: Staging Supabase
  • Features: Pre-production testing

Feature Branches

  • Trigger: Pull request creation
  • Environment: Preview
  • URL: https://talentg-git-feature-branch.vercel.app
  • Database: Development Supabase
  • Features: Feature-specific testing

CI/CD Pipeline

GitHub Actions Workflow

# .github/workflows/deploy.yml
name: Deploy to Vercel

on:
  push:
    branches: [main, staging]
  pull_request:
    branches: [main]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with:
          node-version: '18'
          cache: 'pnpm'
      
      - name: Install dependencies
        run: pnpm install
      
      - name: Run tests
        run: pnpm test
      
      - name: Run type check
        run: pnpm type-check
      
      - name: Run linting
        run: pnpm lint

  deploy:
    needs: test
    runs-on: ubuntu-latest
    if: github.ref == 'refs/heads/main'
    steps:
      - uses: actions/checkout@v3
      - name: Deploy to Vercel
        uses: amondnet/vercel-action@v20
        with:
          vercel-token: ${{ secrets.VERCEL_TOKEN }}
          vercel-org-id: ${{ secrets.ORG_ID }}
          vercel-project-id: ${{ secrets.PROJECT_ID }}
          vercel-args: '--prod'

Build Process

  1. Dependency Installation:
    pnpm install --frozen-lockfile
    
  2. Type Checking:
    pnpm type-check
    
  3. Linting:
    pnpm lint
    
  4. Testing:
    pnpm test
    
  5. Build:
    pnpm iso:build
    

Database Migrations

Migration Strategy

# Create migration
supabase migration new add_new_feature

# Apply to staging
supabase db push --project-ref staging-project-ref

# Apply to production
supabase db push --project-ref production-project-ref

Migration Rollback

# Rollback last migration
supabase migration repair --status reverted

# Rollback specific migration
supabase db reset --project-ref project-ref

Environment Management

Production Environment

# Environment variables
NEXT_PUBLIC_SUPABASE_URL=https://your-project.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=your-anon-key
SUPABASE_SERVICE_ROLE_KEY=your-service-role-key
NEXT_PUBLIC_APP_URL=https://talentg.vercel.app
NODE_ENV=production

Staging Environment

# Environment variables
NEXT_PUBLIC_SUPABASE_URL=https://staging-project.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=staging-anon-key
SUPABASE_SERVICE_ROLE_KEY=staging-service-role-key
NEXT_PUBLIC_APP_URL=https://talentg-staging.vercel.app
NODE_ENV=staging

Deployment Process

Pre-deployment Checklist

  • All tests passing
  • Type checking successful
  • Linting clean
  • Database migrations ready
  • Environment variables configured
  • Feature flags set correctly

Deployment Steps

  1. Code Review:
    • Pull request review
    • Code quality checks
    • Security review
  2. Testing:
    • Automated test suite
    • Integration tests
    • Performance tests
  3. Deployment:
    • Vercel deployment
    • Database migration
    • Health checks
  4. Post-deployment:
    • Smoke tests
    • Monitoring alerts
    • User notification

Monitoring & Alerts

Health Checks

// app/api/health/route.ts
export async function GET() {
  try {
    // Check database connection
    const { data } = await supabase.from('profiles').select('count').limit(1)
    
    // Check external services
    const services = await Promise.allSettled([
      checkSupabaseHealth(),
      checkEmailServiceHealth(),
      checkStorageHealth()
    ])
    
    const healthy = services.every(service => 
      service.status === 'fulfilled'
    )
    
    return Response.json({
      status: healthy ? 'healthy' : 'unhealthy',
      timestamp: new Date().toISOString(),
      services: services.map(s => ({
        name: s.status === 'fulfilled' ? s.value.name : 'unknown',
        status: s.status === 'fulfilled' ? 'up' : 'down'
      }))
    })
  } catch (error) {
    return Response.json(
      { status: 'unhealthy', error: error.message },
      { status: 500 }
    )
  }
}

Performance Monitoring

// lib/analytics.ts
export const trackDeployment = (version: string) => {
  if (typeof window !== 'undefined' && window.gtag) {
    window.gtag('event', 'deployment', {
      version,
      timestamp: new Date().toISOString()
    })
  }
}

Rollback Strategy

Automatic Rollback

  • Vercel automatically rolls back on build failure
  • Health check failures trigger rollback
  • Error rate thresholds trigger rollback

Manual Rollback

# Rollback to previous deployment
vercel rollback [deployment-url]

# Rollback database
supabase db reset --project-ref project-ref

Rollback Checklist

  • Identify rollback reason
  • Notify team
  • Execute rollback
  • Verify system health
  • Document incident
  • Plan fix deployment

Security Considerations

Secrets Management

  • Environment variables in Vercel dashboard
  • Supabase secrets in project settings
  • GitHub secrets for CI/CD
  • Regular secret rotation

Access Control

  • Vercel team permissions
  • Supabase project access
  • GitHub repository permissions
  • Deployment approval process

Security Scanning

# Security scanning in CI
- name: Run security audit
  run: pnpm audit --audit-level moderate

- name: Run Snyk security scan
  uses: snyk/actions/node@master
  with:
    args: --severity-threshold=high

Troubleshooting

Common Issues

  1. Build Failures:
    • Check build logs in Vercel dashboard
    • Verify environment variables
    • Check dependency versions
  2. Database Issues:
    • Verify migration status
    • Check RLS policies
    • Validate connection strings
  3. Performance Issues:
    • Check bundle size
    • Analyze Core Web Vitals
    • Review database queries

Debug Commands

# Check deployment status
vercel ls

# View deployment logs
vercel logs [deployment-url]

# Check database status
supabase status

# Test API endpoints
curl https://talentg.vercel.app/api/health