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
| Workflow | Trigger | Description |
|---|---|---|
Unified CI/CD | Push to sandbox, main | Automatically deploys changed components (web, api, supabase, workers). |
Unified CI/CD | Manual Dispatch | Allows selective deployment of any component (e.g., "Deploy API" = true). |
Deploy Documentation | Push 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/**orpackages/** - API: Triggers on changes to
apps/api/**orpackages/** - Supabase: Triggers on changes to
services/supabase/** - Workers: Triggers on changes to
services/fetcher/**orservices/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.