Self-Hosting Deployment
This guide is the operational companion to the architecture page. Use it when you want to run the full Quantago stack yourself on Cloudflare Workers and Pages, backed by PostgreSQL and ClickHouse.
Before You Deploy
You need:
- a Cloudflare account with Workers and Pages enabled
- a PostgreSQL database
- a ClickHouse database
- a GitHub repository if you want CI/CD
- a domain if you want production hostnames instead of provider defaults
Services You Will Deploy
- backend API Worker
- frontend app on Pages
- optional admin app on Pages
- docs site on Pages
- optional landing Worker
Required Runtime Configuration
Backend secrets
DATABASE_URLBETTER_AUTH_SECRETINGESTION_ADMIN_SECRETCLICKHOUSE_URLCLICKHOUSE_USERNAMECLICKHOUSE_PASSWORD
Generate the secret values with:
openssl rand -base64 32
Backend non-secret vars
BETTER_AUTH_URLFRONTEND_ORIGINADMIN_ORIGIN
Frontend and admin build vars
VITE_API_URL
Database Setup
PostgreSQL migrations
export DATABASE_URL="your-production-database-url"
cd services/backend
psql "$DATABASE_URL" -f src/db/migrations/0001_init.sql
psql "$DATABASE_URL" -f src/db/migrations/0002_better_auth.sql
psql "$DATABASE_URL" -f src/db/migrations/0003_backtest_workflows.sql
psql "$DATABASE_URL" -f src/db/migrations/0004_ingestion_metadata.sql
psql "$DATABASE_URL" -f src/db/migrations/0005_add_user_roles.sql
psql "$DATABASE_URL" -f src/db/migrations/0006_strategy_registry.sql
ClickHouse bootstrap
Create the market data database if needed:
CREATE DATABASE IF NOT EXISTS market_data;
The schema is created by the backend on first ingestion.
Cloudflare Pages Projects
Create Pages projects before the first deploy:
cd services/frontend
pnpm build
npx wrangler pages project create ${FRONTEND_PAGES_PROJECT:-quantago-app}
cd ../admin
pnpm build
npx wrangler pages project create ${ADMIN_PAGES_PROJECT:-quantago-admin}
cd ../docs
pnpm build
npx wrangler pages project create ${DOCS_PAGES_PROJECT:-quantago-docs}
The deploy scripts default to quantago-app, quantago-admin, and quantago-docs, but those names can be overridden with environment variables.
Deploy Order
- Provision databases.
- Run PostgreSQL migrations.
- Configure backend secrets and trusted origins.
- Create Pages projects.
- Deploy the backend.
- Deploy frontend, admin, docs, and landing.
Deploy Commands
From the repository root:
pnpm deploy:backend
pnpm deploy:frontend
pnpm deploy:admin
pnpm deploy:docs
pnpm deploy:landing
Or deploy everything together:
pnpm run deploy:all
Custom Domains
Recommended production hostnames:
api.quantago.cofor the APIapp.quantago.cofor the frontendadmin.quantago.cofor the admin appdocs.quantago.cofor the docs sitequantago.cofor the landing site
Verification Checklist
curl https://api.your-domain.com/api/healthreturns{ "ok": true }- the frontend can authenticate against the backend without CORS or cookie issues
/api/sessionreturns a user for authenticated requests- market data queries return ticks
- backtests can be queued and advance beyond the initial
pendingstate - admin-only routes reject non-admin users
Common Failure Modes
- wrong
BETTER_AUTH_URL,FRONTEND_ORIGIN, orADMIN_ORIGIN - missing Pages projects
- missing ClickHouse credentials
- missing workflow binding or database migrations
Pair this guide with Self-Hosting Architecture.