Skip to main content

Deployment Guide

We use a hybrid deployment strategy involving Cloudflare Pages (Frontend), Cloudflare Workers (API Gateway), Supabase Edge Functions (Backend Logic), and Self-Hosted Docker (Workers).

0. Machine Setup

To set up a new machine for deployment or development, run:

cp .env.example .env
# Edit .env with your secrets
make setup

This will satisfy all dependencies and generate necessary configuration files (like apps/api/.dev.vars) automatically.

1. Workflows

WorkflowTriggerDescription
Unified CI/CDPush to sandbox, mainAutomatically deploys changed components (web, api, supabase, workers).
Unified CI/CDManual DispatchAllows selective deployment of any component (e.g., "Deploy API" = true).
Deploy DocumentationPush to docs-public/** or docs-private/**Deploys public and private docs to Cloudflare Pages.

Note on Infrastructure: Infrastructure provisioning (Terraform) is now part of the Unified Workflow but is Manual Only for safety. Select Provision Infra when dispatching the workflow.

Automated Deployments:

  • Web: Triggers on changes to apps/web/** or packages/**
  • API: Triggers on changes to apps/api/** or packages/**
  • Supabase: Triggers on changes to services/supabase/**
  • Workers: Triggers on changes to services/fetcher/** or services/scheduler/**

2. Sandbox Environment

  • Branch: sandbox
  • Frontend URL: https://faiht-frontend.adeel-zain-work.workers.dev
  • API URL: https://api.faiht-frontend.adeel-zain-work.workers.dev
  • Database: Connects to the Sandbox Supabase Project.

How to Deploy: Simply push code to the sandbox branch.

git checkout sandbox
git merge main
git push origin sandbox

3. Production Environment

  • Branch: main
  • Frontend URL: https://www.freeaihashtags.com
  • API URL: https://api.freeaihashtags.com
  • Database: Connects to the Production Supabase Project.

How to Deploy: Push or merge Pull Request into main.

4. Secrets Management

We use GitHub Secrets for CI/CD. For bulk management or local reference, secrets are tracked in:

  • .github.production.secrets: Production environment secrets (gitignored).
  • .github.sandbox.secrets: Sandbox environment secrets (gitignored).
  • .github.secrets.example: Template for secrets file.

5. Manual Deployment (Fallback)

If CI fails, you can deploy manually using the CLI tools.

Web

cd apps/web
pnpm build
npx wrangler pages deploy out --project-name=faiht-frontend --branch=main

API Gateway

cd apps/api
npx wrangler deploy --env production

Supabase Functions

Deploy all functions:

cd services/supabase
npx supabase functions deploy --project-ref <PROJECT_ID>

Core Functions

  • paddle-webhook: Handles all Paddle payment/subscription events.
  • manage-subscription: Consolidated logic for user-initiated cancellations and reactivations.
  • api-keys: Manages public API key lifecycle.
  • api-v1-*: Business logic for various API endpoints.