The Social Power Haus
A multi-tenant AI SaaS for coaches — the architecture, AI systems and engineering practice behind 67 AI-backed endpoints.
The Social Power Haus is a paid membership platform for coaches and experts, built around an AI content studio. Members pay for a tier and gain access to creation tools, courses, a community and live coaching. Underneath the product surface sits a multi-tenant system of more than 40 feature areas, three entitlement tiers and a single shared database — powered by 50 tables, 212 migrations, 222 API routes and 67 AI-backed endpoints.
What makes the platform interesting is not the feature count. It is that every AI feature is grounded in the member’s own context, constrained to machine-parseable output, and metered so the whole thing stays fast and cheap. At its peak it served 40+ paying members and 13k+ visitors, generated 30+ content pieces a day, returned AI responses in 1–3 seconds, and ran for under $100 a month in model spend.
What it is
Every member builds a Brand DNA profile: their offer, positioning, ideal client, market research, content buckets and brand voice. That profile is the retrieval layer the rest of the platform reads from, and it is why the AI output sounds like the member rather than a generic chatbot. The member-facing product, the admin tooling and the background jobs all reuse the same context.
From client conversation to shipped feature
Features moved through a deliberate three-stage loop rather than straight to code:
- Client specification. Discovery and scoping discussions, a written spec agreed with the client, and ambiguity resolved before a single line of code was written.
- Story, epic, sprint. Work broken into epics and stories, acceptance criteria defined up front, then prioritised and planned into sprints.
- Per-feature operation. The plan is written first, tests are written alongside the code, and the result is verified with agents before a human review.
Plan-driven and test-driven, with agent verification: every feature starts from a written plan and acceptance tests, is implemented with AI agents, then checked against that plan before it goes to review.
The stack
App framework
Next.js 16 App Router with React 19 server components in strict TypeScript, styled with Tailwind CSS 4, and TanStack Query handling client-side caching and mutations. Server-first and typed end to end.
Data layer
Supabase Postgres is the single source of truth, with Auth, Storage and Realtime attached. Row-Level Security on every table enforces per-user isolation at the database, and @supabase/ssr manages cookie sessions server-side.
AI layer
One provider, three models: Sonnet 4.6 for quality generation, Haiku 4.5 for high-volume background work, and Opus 4.6 reserved for the hardest tasks. Every response is constrained by a JSON schema.
Payments and entitlements
Stripe handles checkout, the customer portal and subscription webhooks, while Kajabi purchase webhooks auto-provision members. Credits are modelled as an auditable ledger, and pricing comes from a single source of truth.
Platform and infrastructure
Vercel hosts the app and runs scheduled cron jobs, Resend sends transactional email, a Docker-backed Supabase stack gives local production parity, and Serwist makes the app installable as a PWA.
Tooling
Git feature branches and PR review, ESLint for static analysis, Node’s built-in test runner for contract tests, and pnpm / uv for reproducible dependency management.
AI coding tools
Cursor and VS Code for day-to-day coding, v0 and Lovable for rapid UI iteration, and Claude Code / opencode for agentic, plan-driven implementation — guided by repo conventions in AGENTS.md and gated by review. AI is leverage here, not autopilot.
Architecture: a hard trust boundary around AI
The system is server-first, and no AI keys or privileged logic ever reach the client. Every model call runs through an authenticated route handler.
Browser (React 19) → Next.js (RSC + route handlers) → Supabase (Postgres + RLS) → Claude API (server-only key)
Stripe and Kajabi events arrive as signed webhooks, and background work runs on protected Vercel cron jobs rather than being publicly callable.
The core AI pattern: ground it, constrain it, meter it
The same shape repeats across all 67 AI endpoints:
- Ground — retrieve the member’s raw Brand DNA and inject it into the prompt.
- Constrain — a JSON schema forces machine-parseable output instead of prose.
- Meter — credits are deducted and tokens, cache use, latency and cost are logged per call.
// route handler — same shape everywhere
export async function POST(req: NextRequest) {
const { user, profile } = await requireAuthWithChallenge();
// 1 — retrieve member context
const ctx = formatBrandDNAContextForPrompt(
generateBrandDNAContext(brandDna)
);
// 2 — schema-constrained Claude call
const res = await anthropic.messages.create({
model: 'claude-sonnet-4-6',
system: SYSTEM_PROMPT,
messages: [{ role: 'user', content: ctx + task }],
output_config: jsonSchemaOutputFormat(schema),
});
// 3 — observe + meter
logger.log(res);
await deductCreditOrFail(user.id, profile.tier);
}
The AI systems
Brand DNA — the context layer
A six-step onboarding flow — Signature Offer, Positioning, Ideal Client, Market Research, Content Buckets, Brand Voice — where Claude generates structured JSON per step and every response is validated against a Zod schema. Raw fields, including verbatim client quotes, reframes and objections, are fed to prompts rather than lossy summaries. Summaries are pre-generated in the background by a Haiku cron so the other features stay fast. Brand DNA is referenced in around 95 places: it is the retrieval layer the platform reads from. Built on claude-sonnet-4-6 and claude-haiku-4-5 across 13 routes.

Content Lab — the generation engine
The generation engine, covering roughly 50 routes. A hook engine spans three intent families — trust, growth and sell — across 18 named techniques. Three content formats are generated end to end: talking-head script, carousel and b-roll. There are CTA examples by sales intensity and a “One Thing Framework” of proven templates. Rewrite endpoints iterate on saved content using structured user feedback, and every generation is queued against the member’s credit balance before it runs.

Content Critic — the scoring engine
Content Critic scores submitted content out of 40 across four fixed categories worth 10 points each: Specificity, Belief Shift, Pattern Match and CTA Strategy. Verdict thresholds turn the score into an action — POST / FIX / REWRITE / SCRAP — and the feedback is tied to the member’s specific ICA, offer and positioning rather than generic advice. A rewrite endpoint then fixes the exact sections that were flagged.

Profile Analyser — scrape → review
Profile Analyser scrapes a member’s Instagram profile and normalises posts through defensive coercion helpers, then Claude returns a structured review: scores with explanations, a rewritten bio and priorities. It also generates a three-day action checklist graded HIGH / MEDIUM / LOW priority. The same engine is reused across member-facing and admin-facing flows.
Admin AI Assistant — the chatbot
A streaming chat used by the coach, scoped to one selected member at a time. The system prompt is assembled at request time from live member data — a retrieval pattern over structured records — including Brand DNA, the member’s strategy pack and their content-planner activity. Sessions and messages are persisted, and input is Zod-validated with UUID checks and admin gating.

AI Automations — the background layer
Background work runs on Vercel Cron behind secret-header auth (CRON_SECRET), never publicly callable. An hourly Brand DNA summary job uses a dirty-flag queue, five users per run and a bounded runtime. Monthly credit resets and tier top-ups are scheduled in UTC with documented London equivalents. A daily clinic lifecycle opens and blocks slots, generates session summaries and cleans up recordings. Haiku 4.5 absorbs the high-volume summarisation.
The shared discipline behind every AI feature
- Shared client. One Anthropic singleton with a 120s timeout and two automatic retries, so behaviour is consistent across all routes.
- Cost observability. Token and cache accounting with a per-model pricing table logs estimated cost, latency and tools per call.
- Model routing. Sonnet 4.6 for quality generation, Haiku 4.5 for high-volume summaries, and Opus 4.6 only where it earns its cost.
- Trust and metering. Zod-validated requests, typed responses, and credit metering plus tier gating wrapped around every endpoint.
Billing treated as trust-critical engineering
Stripe checkout and the customer portal handle the money, and redirect targets are allow-listed to prevent open redirects. Kajabi purchase webhooks land in a durable queue with retry-on-failure and auto-provisioning. Credits are an auditable ledger, pricing comes from a single source of truth, and Row-Level Security ships with all four policies per table — no silent write failures and no cross-tenant reads.
How it gets shipped safely
- Git: feature branch → PR → merge, with 133 merged PRs using conventional commits and review.
- Docker: the full Supabase Postgres / Auth / Storage / Realtime stack runs locally for production parity.
- Gates:
pnpm lint && pnpm typecheckon every change, plus contract tests for session lifecycles. - AI workflow: v0 (621 commits), Cursor, and Claude Code / opencode guided by a repo
AGENTS.md.
Why this project matters
The Social Power Haus is the clearest example of how I build AI products: grounding, structured output and cost control designed in from the start rather than bolted on. It ships fast with AI, but keeps review gates that hold quality high. It treats billing and entitlements as trust-critical engineering. And it was built with the client as a partner — specs, trade-offs and honest status throughout. The takeaway is that I build AI systems, not prompts.