# Kingdom Wife Blueprint — Automation Plan

> What runs without Sandi · what stays manual · what’s deferred. The principle: Sandi keeps the voice work; everything mechanical is automated.

## Automation map

    flowchart LR
        A[New Tier 2/3 purchase] -->|Stripe webhook| B(IONOS PHP handler)
        B --> C[(MySQL: kwb_purchases)]
        C --> D[Trigger Day 0 email]
        C --> E[Schedule Day 3,7,14,30 in queue]
        D --> F[Cron: every 6h email-sender.php]
        E --> F
        F --> G[Send via PHP mailer or ConvertKit]
        G --> H[(MySQL: kwb_email_log)]

        I[New cohort signup Tier 3] --> J[Calendly RSVP auto-link]
        J --> K[Cohort #N membership row]
        K --> L[Accountability partner pairing]

        M[Receipt drop in 2026_Receipts/] --> N(receipt-watcher-agent)
        N --> O{Auto-classify?}
        O -->|High confidence| P[Append journal row]
        O -->|Ambiguous| Q[Prompt Sandi]

        style A fill:#1F4D4A,stroke:#163A38,color:#fff
        style D fill:#B8893A,stroke:#8B5E3C,color:#fff
        style F fill:#6B7F6B,stroke:#3D7A4E,color:#fff

## What runs WITHOUT Sandi (full automation)

Trigger | What happens | Tech
--- | --- | ---
Stripe webhook (Tier 2 / Tier 3 purchase) | User row updated · purchase logged · Day 0 email queued | PHP webhook handler in `includes/stripe-webhook.php`
Daily cron @ 6am | Email queue check; sends due Day 3/7/14/30 emails | `cron-email.php` via IONOS cron
Hourly cron | Bounced-email cleanup · failed-payment retry | `cron-cleanup.php`
Weekly cron @ Sunday 8pm | Cohort attendance digest emailed to Sandi · accountability-pair non-engagement flags | `cron-cohort-digest.php`
Monthly cron @ 1st of month 1am | Receipt-watcher sweep · receipt journal stub generated for the new month | `cron-monthly.php`
Quarterly cron @ Q1/Q2/Q3/Q4 first Monday | KPI snapshot generated · emailed to Sandi for review | `cron-quarterly.php`
Per-content-completion | `kwb_content_progress` row inserted · downstream unlock check | inline in lesson-N.php

## What stays MANUAL (Sandi keeps the voice)

Task | Why manual | Cadence
--- | --- | ---
Cohort call (90 min monthly) | Live presence is the product | Monthly
Personal check-ins to disengaged members | Trust-keeping work; can’t be templated | As needed
Approving newly-drafted course content | Voice gate + theological accuracy | Per content batch
Quarterly business review | Strategic decisions live in her head | Quarterly
Beta-feedback consensus calls | Editorial judgment | Per book launch
Sabbath calls (calls she takes outside structured cohort) | Pastoral relationship | As needed
Anything that goes out under her name | Voice ownership | Always

## What’s DEFERRED (don’t build until Phase 4)

Feature | Defer until | Why
--- | --- | ---
Mobile app (native) | After Y1 revenue ≥ $50K | Web-responsive is sufficient initially
Advanced analytics dashboard | After 100 paid members | KPI snapshot email is enough
AI-driven content recommendations | After course content complete | Premature personalization
Affiliate program | After Y1 testimonials proven | Need ambassadors first, not affiliates
Multi-language | After English audience saturates | Y3+
Public REST API | Never (without specific reason) | Out of scope

## Email automation sequence (the core flow)

    sequenceDiagram
        participant U as User
        participant S as Stripe
        participant P as PHP webhook
        participant DB as MySQL
        participant Q as Email queue
        participant M as Mailer (cron)

        U->>S: Pays $197 (Tier 2)
        S->>P: webhook payment_intent.succeeded
        P->>DB: INSERT kwb_purchases (succeeded)
        P->>DB: UPDATE kwb_users SET current_tier=2
        P->>Q: INSERT email_queue (day-0-welcome, NOW)
        P->>Q: INSERT email_queue (day-3-introduction, NOW+3d)
        P->>Q: INSERT email_queue (day-7-reflection, NOW+7d)
        P->>Q: INSERT email_queue (day-14-deeper, NOW+14d)
        P->>Q: INSERT email_queue (day-30-celebrate, NOW+30d)

        Note over M: cron every 6h
        M->>Q: SELECT pending WHERE scheduled_for <= NOW
        M->>M: Render template + send
        M->>DB: INSERT email_log (sent)

## Manual-override controls

Every automation has a manual-override toggle in `/admin/`: - Pause email queue for specific user (e.g., she emails back asking to slow down) - Manually advance a user to next tier (refund · gift · beta access) - Suspend cohort attendance counter (member on medical leave) - Re-send last email (user reports they didn’t receive) - Trigger out-of-cycle email (announcement · quarterly newsletter)

These overrides write to an audit log table for traceability.

## Failure modes & alerts

Failure | Detection | Alert
--- | --- | ---
Stripe webhook signature mismatch | webhook handler returns 401, logs to `kwb_webhook_errors` | Email to valuetovictory@gmail.com immediately
Email send rate > 100/hr (suggests stuck queue) | cron checks queue depth | Email + dashboard banner
Failed payment 3x in 24h | webhook handler counter | Email + admin dashboard flag
MySQL connection refused | bootstrap.php health check | Email + 500 page with status
Disk usage > 80% on IONOS | weekly cron `df -h` check | Email

## Cross-references

- [[04_system_architecture]] — schema + folder structure that this automation depends on
- [[03_sop_library]] — manual SOPs that complement these automations
- [[06_gap_analysis]] — what’s not yet automated and why
- [[../../../../sandi-system-engine/_skills/email-sequence-builder/SKILL.md|email-sequence-builder skill]]
- [[../../../../sandi-system-engine/_agents/receipt-watcher-agent/AGENT.md|receipt-watcher-agent]]