Welcome to FlareStack! Follow this guide to get your IP reputation and automated blocking system running locally and in production.
Before running locally or deploying to production, you must initialize the repository.
# Step 1: Initialize the project (Run this FIRST)
pnpm run setup
# ------------- TROUBLESHOOTING ------------- #
# If your local environment breaks or you need to start over:
# pnpm run nukeRunning pnpm run setup creates an apps/dashboard/.dev.vars file for you with random secrets.
Wait! Before you continue:
- Open
apps/dashboard/.dev.vars. - (Optional) Paste your
RESEND_API_KEYto enable email verification. - If left blank, accounts will auto-activate (useful for quick local testing).
After completing the initial setup, you can boot the local environment to test features safely.
💡 Tip: Make sure you've filled in your
apps/dashboard/.dev.varsif you want to test email! (See Section 1).
# Start all development servers
pnpm dev# 1. Install dependencies
pnpm install
# 2. Setup Local Database
pnpm --filter @flarestack/db generate
npx wrangler d1 migrations apply flarestack-db --local --config apps/dashboard/wrangler.jsonc --persist-to .wrangler/state
# 3. Environment Variables (Local Secrets)
cat <<EOF > apps/dashboard/.dev.vars
BETTER_AUTH_BASE_URL="http://localhost:5173"
BETTER_AUTH_SECRET="$(openssl rand -base64 32)"
# Optional: fill in to enable email verification via Resend (https://resend.com).
# Leave blank → accounts auto-activate (no email needed).
RESEND_API_KEY=""
# Optional: custom from address (must be from a Resend-verified domain).
# Leave blank to use Resend's test sender (onboarding@resend.dev)
RESEND_FROM=""
EOF
# 4. Start Development Server
pnpm dev- Open
http://localhost:5173/authto Sign Up for your local user. - Email verification is optional locally. Fill
RESEND_API_KEYto enable it — otherwise accounts activate instantly. - Connect a Cloudflare account and add your zones.
- Test the Worker: While
pnpm devis running, press 't' in the terminal to force a cron event, or visithttp://localhost:8787/__scheduled.
⚠️ Local cron does not tick automatically. Unlike production (where Cloudflare fires the cron every minute on its own), the local Miniflare runtime does not run the scheduler clock — it just sits idle. You must manually trigger each cron execution using 't' or the/__scheduledURL.
Launch your system to the Cloudflare edge.
⚠️ IMPORTANT: You must have runpnpm run setuplocally at least once before deploying, as this installs dependencies and generates the database client.
- Copy the template:
cp apps/dashboard/.prod.vars.example apps/dashboard/.prod.vars - Open
apps/dashboard/.prod.varsand fill in your values.
💡 Tip (The Chicken & Egg Problem): If you don't know your production URL yet, leave
BETTER_AUTH_BASE_URLas the default. Run the deployment (Step 2) once. The command will print your Pages URL at the end. Copy that URL back into.prod.varsand run the deploy again to sync it!
Once your variables are set, run:
pnpm run deploy# 1. Infrastructure Creation
npx wrangler login
npx wrangler d1 create flarestack-db
# 2. Configuration (Manual Link)
# Copy the database_id from step 1 into:
# - apps/dashboard/wrangler.jsonc
# - apps/worker/wrangler.jsonc
# 3. Deploy
npx wrangler d1 migrations apply flarestack-db --remote --config apps/dashboard/wrangler.jsonc
pnpm --filter @flarestack/worker deploy
pnpm --filter @flarestack/dashboard deploy
# 4. Production Environment Variables
# Copy the template and fill in your values:
cp apps/dashboard/.prod.vars.example apps/dashboard/.prod.vars
# Then edit apps/dashboard/.prod.vars with your real values.
# `pnpm run deploy` will read from this file and push to Cloudflare automatically.- Visit your Pages URL (provided at the end of the deployment script).
- Sign up and configure your production organization and zones.
- Your worker will now run automatically on Cloudflare every minute!
Run these commands whenever you modify packages/db/src/schema/.
# Generate new SQL migration files
pnpm --filter @flarestack/db generate
# Apply to Local DB
npx wrangler d1 migrations apply flarestack-db --local --config apps/dashboard/wrangler.jsonc --persist-to .wrangler/state
# Apply to Production DB
npx wrangler d1 migrations apply flarestack-db --remote --config apps/dashboard/wrangler.jsonc