Skip to content

Latest commit

Β 

History

History
377 lines (296 loc) Β· 11.7 KB

File metadata and controls

377 lines (296 loc) Β· 11.7 KB

Deployment Architecture: GitHub Runners + Vercel

This document explains how the wedding website deployment uses GitHub-hosted runners (Ubuntu Linux VMs) to build and deploy the full-stack Next.js application to Vercel.

πŸ—οΈ Architecture Overview

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    GitHub Repository                         β”‚
β”‚  (Code, Workflows, Database Schema, Next.js App)            β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            β”‚
                            β”‚ Push to main / Manual trigger
                            ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚              GitHub Actions (CI/CD Pipeline)                 β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚    GitHub-Hosted Runner (Ubuntu Linux VM)           β”‚   β”‚
β”‚  β”‚                                                      β”‚   β”‚
β”‚  β”‚  1. Checkout code                                   β”‚   β”‚
β”‚  β”‚  2. Setup Node.js 20                                β”‚   β”‚
β”‚  β”‚  3. Install dependencies (npm ci)                   β”‚   β”‚
β”‚  β”‚  4. Generate Prisma client                          β”‚   β”‚
β”‚  β”‚  5. Run tests                                       β”‚   β”‚
β”‚  β”‚  6. Build Next.js app (Vercel CLI)                  β”‚   β”‚
β”‚  β”‚  7. Deploy to Vercel                                β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            β”‚
                            β”‚ Deploy artifacts
                            ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    Vercel Platform                           β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚              Production Environment                  β”‚   β”‚
β”‚  β”‚                                                      β”‚   β”‚
β”‚  β”‚  β€’ Next.js App Running                              β”‚   β”‚
β”‚  β”‚  β€’ SQLite Database (Serverless)                     β”‚   β”‚
β”‚  β”‚  β€’ API Routes (18 endpoints)                        β”‚   β”‚
β”‚  β”‚  β€’ NextAuth Authentication                          β”‚   β”‚
β”‚  β”‚  β€’ Email Service (Gmail SMTP)                       β”‚   β”‚
β”‚  β”‚  β€’ Image Storage (Cloudinary)                       β”‚   β”‚
β”‚  β”‚  β€’ Global CDN                                       β”‚   β”‚
β”‚  β”‚  β€’ Automatic SSL                                    β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            β”‚
                            β”‚ HTTPS
                            ↓
                     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                     β”‚   Users     β”‚
                     β”‚ (Browsers)  β”‚
                     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ”§ Component Breakdown

1. GitHub-Hosted Runners (Build Environment)

What it is:

  • Temporary Ubuntu Linux virtual machines
  • Provided free by GitHub
  • Runs during GitHub Actions workflows
  • Automatically provisioned and destroyed

What it does:

  • βœ… Checks out code from repository
  • βœ… Installs Node.js 20 and dependencies
  • βœ… Generates Prisma database client
  • βœ… Runs test suite
  • βœ… Builds Next.js application
  • βœ… Deploys to Vercel using Vercel CLI

Duration: 2-4 minutes per deployment

Cost: FREE (included with GitHub)

2. Vercel Platform (Hosting Environment)

What it is:

  • Serverless hosting platform optimized for Next.js
  • Global CDN (Content Delivery Network)
  • Automatic SSL certificates
  • Edge network for fast response times

What it runs:

  • βœ… Next.js application (all 34 routes)
  • βœ… API routes (18 endpoints for forms, auth, data)
  • βœ… SQLite database (serverless, persistent)
  • βœ… NextAuth authentication
  • βœ… Email notification service
  • βœ… Static assets and images

Duration: Continuous (24/7 uptime)

Cost: FREE tier (no credit card required)

3. Deployment Flow

Developer Action:
β”œβ”€ git push origin main
└─ or: Manual workflow trigger

GitHub Actions:
β”œβ”€ Workflow triggered (.github/workflows/deploy-vercel.yml)
β”œβ”€ Spin up Ubuntu runner
β”œβ”€ Install dependencies
β”œβ”€ Build application
β”œβ”€ Run tests (optional)
└─ Deploy to Vercel

Vercel:
β”œβ”€ Receive deployment
β”œβ”€ Activate new version
β”œβ”€ Update DNS
β”œβ”€ Site live with zero downtime
└─ Old version automatically cleaned up

Result:
└─ Live site at https://your-project.vercel.app

🎯 Why This Architecture?

GitHub Runners for Build

Advantages:

  • βœ… Free compute for building
  • βœ… Consistent Ubuntu environment
  • βœ… Integrated with GitHub repository
  • βœ… Automatic on every push
  • βœ… Can run tests before deploy
  • βœ… Build logs in GitHub Actions

Role:

  • CI/CD automation
  • Quality assurance (testing)
  • Build optimization
  • Deployment orchestration

Vercel for Hosting

Advantages:

  • βœ… Free tier (no credit card)
  • βœ… Native Next.js support
  • βœ… Serverless functions (API routes)
  • βœ… Global CDN (fast worldwide)
  • βœ… Automatic SSL certificates
  • βœ… Zero-downtime deployments
  • βœ… Environment variable management
  • βœ… Persistent database storage

Role:

  • Production hosting
  • Serving web traffic
  • Running server-side code
  • Database storage
  • Email sending

πŸ“Š What Runs Where

Component GitHub Runner Vercel
Build Process βœ… Yes ❌ No
Testing βœ… Yes ❌ No
Live Website ❌ No βœ… Yes
API Routes ❌ No βœ… Yes
Database ❌ No βœ… Yes
Authentication ❌ No βœ… Yes
Email Sending ❌ No βœ… Yes
Static Assets ❌ No βœ… Yes
Duration 2-4 minutes 24/7
Cost Free Free

πŸ”„ Continuous Deployment

Automatic (Recommended)

# 1. Make changes to code
git add .
git commit -m "Update feature"
git push origin main

# 2. GitHub Actions automatically:
#    - Builds on Ubuntu runner
#    - Runs tests
#    - Deploys to Vercel
#    - Site updated in 3 minutes

Manual

# Go to GitHub Actions tab
# Select: "Deploy Full-Stack App to Vercel"
# Click: "Run workflow"
# Select: branch (main)
# Click: "Run workflow"

πŸ” Environment Variables

Stored in Vercel

Production secrets stored securely in Vercel:

  • DATABASE_URL - SQLite database path
  • NEXTAUTH_SECRET - Authentication secret
  • NEXTAUTH_URL - Production URL
  • ADMIN_EMAIL - Admin login email
  • ADMIN_PASSWORD - Admin login password
  • GMAIL_USER - Email service username
  • GMAIL_APP_PASSWORD - Email service password
  • CLOUDINARY_* - Image upload credentials

Stored in GitHub

Deployment credentials stored in GitHub Secrets:

  • VERCEL_TOKEN - Vercel CLI authentication
  • VERCEL_ORG_ID - Vercel organization ID
  • VERCEL_PROJECT_ID - Vercel project ID

πŸ“ˆ Scalability

Traffic Handling

  • Low Traffic (< 100 visits/day): βœ… Free tier sufficient
  • Medium Traffic (100-10,000 visits/day): βœ… Free tier works
  • High Traffic (> 10,000 visits/day): May need Vercel Pro ($20/mo)

Database

  • SQLite (Current):

    • βœ… Good for < 1000 concurrent users
    • βœ… Simple and fast
    • βœ… No extra configuration
  • Upgrade Path (if needed):

    • PostgreSQL (Vercel Postgres)
    • MySQL (PlanetScale)
    • MongoDB (MongoDB Atlas)

πŸ› οΈ Maintenance

Updates

# Code updates: Just push to GitHub
git push origin main
# Automatic rebuild and deploy

# Dependency updates:
npm update
git push origin main
# Automatic rebuild and deploy

# Database schema changes:
npx prisma migrate dev
git push origin main
# Automatic rebuild and deploy

Monitoring

  • Vercel Dashboard: https://vercel.com/dashboard

    • View deployment logs
    • Monitor performance
    • Check error rates
    • Analyze traffic
  • GitHub Actions: Actions tab in repository

    • Build status
    • Test results
    • Deployment history

πŸ’° Cost Breakdown

GitHub (Free)

  • βœ… GitHub Actions: 2,000 minutes/month free
  • βœ… Each deployment: ~3 minutes
  • βœ… Capacity: ~650 deployments/month

Vercel (Free Tier)

  • βœ… Bandwidth: 100 GB/month
  • βœ… Serverless execution: 100 GB-hours
  • βœ… Deployments: Unlimited
  • βœ… Team members: 1
  • βœ… Custom domains: βœ…
  • βœ… SSL: βœ… (automatic)

Total Monthly Cost

$0.00 (Everything free)

🎯 Advantages Over Alternatives

vs GitHub Pages (Static Only)

Feature GitHub Pages This Solution
Database ❌ βœ… SQLite
API Routes ❌ βœ… 18 routes
Authentication ❌ βœ… NextAuth
Admin Panel ❌ βœ… Full dashboard
Forms Limited βœ… Full featured
Build GitHub Actions GitHub Actions
Cost Free Free

vs VPS (Self-Hosted)

Feature VPS This Solution
Setup Time Hours 12 minutes
Maintenance Manual Automatic
SSL Manual Automatic
CDN Extra cost Included
Scaling Manual Automatic
Cost $5-50/month Free
Build Self-managed GitHub Actions

πŸ”’ Security

GitHub Runners

  • βœ… Isolated VM per workflow
  • βœ… Clean environment every time
  • βœ… No persistent data
  • βœ… Secrets encrypted

Vercel

  • βœ… Automatic SSL/TLS
  • βœ… DDoS protection
  • βœ… Environment variables encrypted
  • βœ… Secure database storage
  • βœ… Regular security updates

πŸ“ž Support

For Build Issues (GitHub Actions)

  • Check workflow logs in Actions tab
  • Review error messages
  • Verify GitHub Secrets are set

For Runtime Issues (Vercel)

  • Check Vercel dashboard logs
  • Review function logs
  • Verify environment variables
  • Check database connections

πŸŽ‰ Summary

This architecture provides:

βœ… Free Hosting - No costs for typical wedding website βœ… Full-Stack - Database, API routes, authentication βœ… Automatic Deployment - Push code, site updates βœ… GitHub Runners - Ubuntu Linux VMs for building βœ… Production Ready - SSL, CDN, global performance βœ… Simple Maintenance - No server management βœ… Scalable - Handles traffic spikes automatically

Result: Professional wedding website with all features working, deployed in 12 minutes, maintained via Git.


Build Platform: GitHub Actions (Ubuntu runners) Hosting Platform: Vercel (Serverless) Database: SQLite (Serverless) Cost: $0/month Setup Time: 12 minutes Status: βœ… Production Ready