System Overview
The production system is split across two platforms. Content lives in Drupal on sergeant.agency. The Quick Check engine, database, and internal tools run on Cloudflare Workers at the edge.
How Drupal and Cloudflare Connect
The Drupal landing page embeds the Quick Check form (HTML + JS). On submit, the browser makes a cross-origin fetch() to the CF Workers API. All processing happens on Cloudflare. Results are rendered client-side.
User-Facing Flow
What Lives Where
Drupal sergeant.agency
- Landing page content and layout
- Quick Check form HTML + JS (embedded)
- Blog articles (pillar content)
- Audit request form (or link to CF-hosted form)
- SEO, meta tags, multilingual (DE/FR/EN)
- Navigation, footer, brand integration
Cloudflare api subdomain
POST /api/checkQuick Check enginePOST /api/emailEmail capture + lead storagePOST /api/audit-requestAudit form submissions- D1 database (checks, leads, audit_requests)
- KV cache (rate limits, result cache 24h TTL)
- Cron trigger for score re-checks + email alerts
CORS Configuration
The CF Worker already includes Access-Control-Allow-Origin: * for all API routes. For production, restrict this to https://www.sergeant.agency and the admin domain.
Drupal Integration
The Quick Check needs to be embedded into a Drupal page. Two approaches:
What the Dev Team Needs to Build in Drupal
- A content type or page template for the AI Brand Visibility landing page
- A custom block or paragraph type for the Quick Check form
- JS asset that handles form submission, loading state, result rendering, email gate
- CSS for the Quick Check component (can be ported from the prototype)
- The API endpoint URL as a configurable setting (staging vs. production)
Admin Dashboard
Internal tool for managing leads and monitoring Quick Check usage. Runs as a separate CF Pages app with basic auth.
Views
Tech Stack
Static HTML + vanilla JS (same approach as the project dashboard). Reads from D1 via a secured API endpoint on the CF Worker. Protected with a simple token or Cloudflare Access.
Automated Email (Score Change Alerts)
Users who enter their email at the gate receive an automated re-check notification when their score changes.
How It Works
Implementation
- Cron Trigger: CF Worker with
[triggers] crons = ["0 8 * * *"](daily at 08:00 UTC) - Re-check logic: Query D1 for leads where
created_atis 7+ days ago andrecheck_sent = false - Score comparison: Run the same Quick Check API internally, compare with stored
result_json - Email delivery: Mailgun API. Simple transactional email: "Your score changed from X to Y"
- Rate limiting: Max 50 re-checks per cron run to stay within API budgets
Email Content
Open Decisions for Dev Team
- CF Workers (current): Edge-fast, proven, ~$0.03/check. D1 + KV included. No server management. Limitation: no native cron UI, no built-in auth.
- Next.js (Vercel or Metanet): Full framework, SSR, API routes, middleware. Better DX for complex features. More overhead for what is essentially an API + static page.
- Hono on CF Workers: Lightweight framework on the same CF infrastructure. Adds routing, middleware, auth patterns without leaving the edge. Good middle ground.
- FastAPI / Python (Metanet): If the team prefers Python. Better AI/ML library ecosystem. But adds server management and latency vs. edge.
ai-branding.sergeant.agency (can be kept for the dashboard/prototype).Migration Path: Prototype to Production
Phase 1: Drupal Landing Page
- Build landing page template in Drupal
- Port Quick Check form HTML + JS + CSS as custom block
- Point API calls to current CF endpoint
- Test cross-origin integration
- Restrict CORS to sergeant.agency
Phase 2: Admin Dashboard
- Build CF Pages app with basic auth (or CF Access)
- Read-only views for checks, leads, audit requests
- CSV export
- Status tracking for audit requests
Phase 3: Email Automation
- Configure Mailgun for transactional emails
- Build cron worker for 7-day re-checks
- Design email template (score changed / stable)
- Add
recheck_sentandrecheck_scorecolumns to D1 - Test with 5-10 internal leads before going live