This guide will help you deploy the complete Leadership Suite with all functionality enabled using Cloudflare.
The Leadership Suite uses a modern Cloudflare-native architecture:
npm install -g wranglerwrangler login# Create the database
wrangler d1 create leadership-legacy-db
# Note the database ID from the output and update wrangler.toml
# Run the initial schema
wrangler d1 execute leadership-legacy-db --file=./schema/schema.sql
# Run suite schema
wrangler d1 execute leadership-legacy-db --file=./migrations/0002_create_suite_schema.sql
# Insert demo user and sample data
wrangler d1 execute leadership-legacy-db --file=./migrations/0003_insert_demo_user.sql
# Create R2 bucket for file storage
wrangler r2 bucket create leadership-legacy-assets
# Enable public access (optional, for serving uploaded files)
# Configure this in the Cloudflare dashboard under R2
Replace placeholders in wrangler.toml:
database_id: Your D1 database IDaccount_id: Your Cloudflare account IDcp .env.local .env.local.example
# Edit .env.local with your values
For AI assistant with Anthropic (optional, uses Cloudflare AI by default):
wrangler secret put ANTHROPIC_API_KEY
# Enter your Anthropic API key when prompted
For email functionality with Resend (optional):
wrangler secret put RESEND_API_KEY
# Enter your Resend API key when prompted
# Deploy the API worker
wrangler deploy
# Note the worker URL from the output (e.g., leadership-legacy.YOUR_SUBDOMAIN.workers.dev)
Update wrangler-pages.toml with your Worker URL:
[env.production.vars]
WORKER_URL = "https://leadership-legacy.YOUR_SUBDOMAIN.workers.dev"
# Install dependencies
npm install
# Build the Next.js static site
npm run build
# Deploy to Cloudflare Pages
npx wrangler pages deploy out --project-name=leadership-legacy
# Or use the Cloudflare dashboard to connect your Git repository
In the Cloudflare dashboard:
NEXT_PUBLIC_API_URL: Your worker URL (or leave empty to use relative /api)NEXT_PUBLIC_R2_PUBLIC_BASE: Your R2 public URL (if using public bucket)npm run buildout/leadership-legacy.pages.dev)/suite to access the suite dashboard# Terminal 1: Start the Worker
wrangler dev
# This starts the API at http://localhost:8787
# Terminal 2: Start Next.js
npm run dev
# This starts the frontend at http://localhost:3000
The Next.js app will proxy /api/* requests to the Worker automatically in development.
_routes.json is in the public folderwrangler d1 execute leadership-legacy-db --file=./migrations/0002_create_suite_schema.sqlwrangler.toml and codewrangler r2 bucket listwrangler.toml@cf/meta/llama-3.1-8b-instructwrangler tailThis architecture provides:
For issues or questions:
Congratulations! Your Leadership Suite is now fully functional and deployed on Cloudflare’s edge network.