Deployment Guide
Deploy Societee to Cloudflare: 3 Workers (backend + auth + frontend). Account: 5bec9c1969d08a2f18cf2235edfd41de (Roori - Personal). Auth: rohitmore3192@gmail.com.
Target Deployment
societee.pages.dev → Frontend (Cloudflare Pages)
societee.workers.dev → Backend API (Cloudflare Workers)
auth.societee.workers.dev → OpenAuth Server (Cloudflare Workers)
kb-societee.pages.dev → Knowledge Base (Cloudflare Pages)
Cloudflare Resources Needed
| Resource | CLI Command | Binding |
| D1 Database | wrangler d1 create societee-db | DB |
| D1 Database | wrangler d1 create societee-auth-db | AUTH_DB |
| KV Namespace | wrangler kv namespace create KV_CACHE | KV_CACHE |
| KV Namespace | wrangler kv namespace create AUTH_STORAGE | AUTH_STORAGE |
| R2 Bucket | wrangler r2 bucket create societee-vault | R2_VAULT |
| Vectorize Index | wrangler vectorize create societee-rag-index | VECTOR_INDEX |
Deployment Steps
Step 1: Create Resources
wrangler d1 create societee-db
# → Copy database_id → Update wrangler.toml
wrangler d1 create societee-auth-db
# → Copy database_id → Update auth/wrangler.json
wrangler kv namespace create KV_CACHE
# → Copy id → Update wrangler.toml
wrangler kv namespace create AUTH_STORAGE
# → Copy id → Update auth/wrangler.json
wrangler r2 bucket create societee-vault
wrangler vectorize create societee-rag-index
Step 2: Update Configs
# wrangler.toml — replace placeholder IDs
[vars]
DATABASE_ID = "<real-d1-id>"
KV_ID = "<real-kv-id>"
R2_BUCKET = "societee-vault"
VECTOR_INDEX = "societee-rag-index"
# auth/wrangler.json — same pattern
Step 3: Run Migrations
# Backend schema
wrangler d1 execute societee-db --remote --file=./db/schema.sql
# Backend seed data
wrangler d1 execute societee-db --remote --file=./db/seed.sql
# Auth schema
wrangler d1 migrations apply societee-auth-db --remote
Step 4: Set Secrets
# Backend secrets
wrangler secret put JWT_SECRET
wrangler secret put ENCRYPTION_MASTER_KEY
# Generate secure values:
openssl rand -hex 32 # for both
Step 5: Deploy
# Deploy backend
wrangler deploy
# Deploy auth server
cd auth && wrangler deploy
# Deploy frontend
cd frontend && npm run build && wrangler pages deploy dist --project-name=societee
# Deploy knowledge base
wrangler pages deploy kb --project-name=kb-societee
Step 6: Configure CORS
# Backend: allow frontend origin
Access-Control-Allow-Origin: https://societee.pages.dev
Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS
Access-Control-Allow-Headers: Content-Type, Authorization, X-Tenant-ID
# Auth: allow frontend origin
Access-Control-Allow-Origin: https://societee.pages.dev
Step 7: Post-Deploy Verification
# 1. Test auth server
curl https://auth.societee.workers.dev/health
# 2. Test backend health
curl https://societee.workers.dev/v1/health
# 3. Test frontend
open https://societee.pages.dev
# 4. Login test
curl -X POST https://societee.workers.dev/v1/auth/login \
-H "Content-Type: application/json" \
-d '{"email":"rohit@societee.com","password":"Admin@123"}'
# 5. Monitor logs
wrangler tail
Local Development
# Backend (port 8787)
cd societee
wrangler dev
# Frontend (port 8888, proxies /v1 → localhost:8787)
cd frontend
npm run dev
# Auth server (port 8789)
cd auth
wrangler dev
Test Credentials
| User | Email | Password | Role |
| Admin | rohit@societee.com | Admin@123 | SUPER_ADMIN / SOCIETY_ADMIN |
| Priya (Secretary) | priya@example.com | Admin@123 | SECRETARY |
| Rahul (Treasurer) | rahul@example.com | Admin@123 | TREASURER |
Cost at Scale
| Resource | Free Tier Limit | Cost (Paid Plan) |
| Workers | 100K req/day | $5/mo per 10M requests |
| D1 | 10GB storage, 5M rows read/day | $0.75/mo per GB stored |
| KV | 100K reads/day | $0.50/mo per million reads |
| R2 | 10GB storage | $0.015/mo per GB stored |
| Workers AI | Limited daily inferences | $0.011 per 1K tokens |
| Vectorize | 5M dimensions stored | $0.01/million dimensions |
| Pages | 500 builds/month | Free for most use |
Total infrastructure: ~₹5,200/month for up to 1,000 societies. 93% gross margin on infra alone.