Skip to main content

Cloudflare Deployment

Fataplus is deployed entirely on Cloudflare infrastructure, utilizing Pages for the frontend, Workers for the backend API, and D1 for database storage.

Prerequisites

Before deploying, ensure you have:
  • Node.js 18.0.0 or higher
  • A Cloudflare account
  • Wrangler CLI (Cloudflare’s deployment tool)
  • Access to the fata.plus domain on Cloudflare

Wrangler Setup

1

Install Wrangler globally

npm install -g wrangler
2

Authenticate with Cloudflare

wrangler auth login
This will open a browser window for authentication.
3

Verify authentication

wrangler whoami
You should see your Cloudflare account details.

D1 Database Setup

Fataplus uses Cloudflare D1 (SQLite at the edge) for data storage.
1

Create D1 database

For the frontend/website:
wrangler d1 create fataplus-website-db
The output will include a database_id. Copy this for your wrangler configuration.
2

Update wrangler.toml with database ID

Add the database binding to your wrangler.toml:
[[d1_databases]]
binding = "DB"
database_name = "fataplus-website-db"
database_id = "your-database-id-here"
3

Run migrations locally

# For SonicJS-based frontend
npm run db:migrate:local
4

Run migrations in production

npm run db:migrate
The current production database ID is 20b1fb8c-3e08-4e91-9083-53558750107d

R2 Storage Setup (Optional)

For media storage, Fataplus uses Cloudflare R2:
# Create R2 bucket for media
wrangler r2 bucket create fataplus-website-media
Add to your wrangler.toml:
[[r2_buckets]]
binding = "BUCKET"
bucket_name = "fataplus-website-media"

Frontend Deployment (Cloudflare Pages)

The frontend applications are deployed using Cloudflare Pages.
1

Navigate to frontend directory

cd frontend/fataplus-website
2

Install dependencies

npm install
3

Build the application

npm run build
4

Deploy to Cloudflare Pages

npm run deploy
Or use Wrangler directly:
wrangler pages deploy
Ensure all environment variables are set before deploying. See the Environment Configuration page.

Backend Deployment (Cloudflare Workers)

The backend API runs on Cloudflare Workers at bknd.fata.plus.
1

Navigate to backend directory

cd backend-integration/fataplus-bknd-backend
2

Install dependencies

npm install
3

Generate types

npm run typegen
4

Deploy to Cloudflare Workers

npm run deploy
Or use Wrangler directly:
wrangler deploy

Backend Configuration

The backend uses wrangler.json for configuration:
{
  "$schema": "node_modules/wrangler/config-schema.json",
  "name": "fataplus-bknd-backend",
  "main": "src/index.ts",
  "compatibility_date": "2025-08-03",
  "account_id": "your-account-id",
  "routes": [
    {"pattern": "bknd.fata.plus/*", "zone_name": "fata.plus"}
  ],
  "compatibility_flags": [
    "nodejs_compat"
  ],
  "workers_dev": true,
  "minify": true,
  "observability": {
    "enabled": true
  },
  "d1_databases": [
    {
      "binding": "DB",
      "database_name": "fataplus-website-db",
      "database_id": "20b1fb8c-3e08-4e91-9083-53558750107d"
    }
  ]
}

Development Workflow

1

Local development

# Frontend
cd frontend/fataplus-website
npm run dev

# Backend
cd backend-integration/fataplus-bknd-backend
npm run dev
2

Access local services

  • Frontend: http://localhost:8787
  • Backend Admin: http://localhost:8787/admin
3

Type checking

npm run type-check

Deployment URLs

After successful deployment:
  • Production Worker: https://fataplus-bknd-backend.fenohery.workers.dev
  • Admin Interface: https://fataplus-bknd-backend.fenohery.workers.dev/admin
  • Custom Domain (when configured): https://bknd.fata.plus

Verifying Deployment

1

Check Worker status

curl -I https://fataplus-bknd-backend.fenohery.workers.dev
2

Test admin interface

curl -I https://fataplus-bknd-backend.fenohery.workers.dev/admin
3

View logs

wrangler tail
Cloudflare Workers typically deploy globally within 30 seconds. D1 database changes may take a few minutes to propagate.

Troubleshooting

Worker not accessible

  1. Verify your account ID in wrangler.json matches your Cloudflare account
  2. Check that routes are correctly configured
  3. Ensure the domain is managed by Cloudflare

Database connection errors

  1. Verify the database ID is correct in your wrangler configuration
  2. Run migrations: npm run db:migrate
  3. Check D1 database exists: wrangler d1 list

Build failures

  1. Clear node_modules and reinstall: rm -rf node_modules && npm install
  2. Update Wrangler: npm install -g wrangler@latest
  3. Check TypeScript types: npm run typegen

Next Steps