APP

Documentation

Developer Guide

Deployment Configuration

AutoTechJobs is deployed on Cloudflare Pages, leveraging Cloudflare's global edge network for optimal performance and reliability. This document outlines the deployment configuration and infrastructure setup.

Cloudflare Pages Configuration

The application is configured in wrangler.toml:

# wrangler.toml
name = "autotechjobs"
compatibility_date = "2025-01-09"
pages_build_output_dir = "./build/client"

[placement]
mode = "smart"

[[kv_namespaces]]
binding = "KV"
id = "27646024ef8843a3a80e65c844ca8e27"

[[d1_databases]]
binding = "DB"
database_name = "autotechjobs_preview"
database_id = "f87561e1-64d7-4651-bc6c-9eb363bb1581"

Environment Variables

The application requires several environment variables to be configured in the Cloudflare Pages dashboard:

VariableDescriptionRequired
SESSION_SECRETSecret key used for session encryptionYes
RESEND_API_KEYAPI key for Resend email serviceYes
GEOCODING_API_KEYAPI key for geocoding serviceYes
CLOUDFLARE_ANALYTICS_TOKENToken for Cloudflare AnalyticsNo
STRIPE_SECRET_KEYSecret key for Stripe payment processingYes (for premium features)
STRIPE_WEBHOOK_SECRETSecret for Stripe webhook verificationYes (for premium features)

Build and Deployment Process

The application is built and deployed automatically when changes are pushed to the main branch:

  1. Code is pushed to the GitHub repository
  2. GitHub Actions runs tests and linting checks
  3. If tests pass, Cloudflare Pages builds the application
  4. The build output is deployed to Cloudflare's edge network
  5. Database migrations are applied if needed

The build configuration in the Cloudflare Pages dashboard:

Build commandnpm run build
Build output directorybuild/client
Root directory/
Node.js version18.x

Cloudflare Infrastructure

Cloudflare Pages

  • Hosts the Remix application
  • Provides global CDN distribution
  • Automatic deployments from Git
  • Preview deployments for pull requests

Cloudflare D1

  • SQLite-compatible database
  • Distributed at the edge
  • Automatic replication
  • Schema migrations via wrangler

Cloudflare KV

  • Used for session storage
  • Caching frequently accessed data
  • Global key-value store

Cloudflare Workers

  • Background processing
  • Email delivery service
  • Scheduled tasks

Database Migrations

Database migrations are managed using Wrangler CLI:

# Create a new D1 database
npx wrangler d1 create autotechjobs

# Apply migrations from schema.sql
npx wrangler d1 execute autotechjobs --file=./db/schema.sql

# Run SQL commands directly
npx wrangler d1 execute autotechjobs --command="SELECT * FROM users LIMIT 10"

Deployment Environments

AutoTechJobs maintains three distinct deployment environments to ensure smooth development and testing:

Production Environment

  • Branch: main
  • URL: autotechjobs.pages.dev
  • Purpose: Live application with production data
  • Access: Public
  • Database: autotechjobs_prod
  • Features: Full feature set

Preview Environment

  • Branch: develop
  • URL: preview.autotechjobs.pages.dev
  • Purpose: Pre-production testing
  • Access: Team members only
  • Database: autotechjobs_preview
  • Features: All features enabled

Feature Testing Environment

  • Branch: Feature branches
  • URL: [branch-name].autotechjobs.pages.dev
  • Purpose: Isolated feature testing
  • Access: Feature team only
  • Database: autotechjobs_feature_[branch]
  • Features: Feature-specific

Environment Configuration

Environment Variables

  • NODE_ENV - Environment identifier
  • ENVIRONMENT - Environment name
  • DB_NAME - Database name
  • BASE_URL - Base URL for API calls

Deployment Process

  • Push to main → Production deployment
  • Push to develop → Preview deployment
  • Push to feature branch → Feature environment deployment
  • Automatic database migrations

Environment-Specific Features

Production

  • Full feature set
  • Production database
  • Rate limiting enabled
  • Performance monitoring

Preview/Feature

  • Feature flags
  • Test data isolation
  • Development tools
  • Debug logging

For more information about deployment best practices, see theDevelopmentdocumentation.