Repository navigation
Monetization + go-to-market: tiers/Stripe, SSRF guard, landing, funnel analytics, activation, waitlist - #3
Merged
Conversation
…ng page MicroSaaS monetization layer on top of the existing quota/budget machinery. Core invariant: billing NEVER constrains self-hosters — with no STRIPE_SECRET_KEY every user is on the "unlimited" tier and all checks are no-ops (the entire pre-existing suite passes unchanged). With Stripe configured, no-subscription = Free tier. - services/billing.py: tier table in code (Free 5 analyses/2 docs/fast model; Pro $12 50/30/detailed; Power $24 200/unlimited/API), env-overridable via TIER_LIMITS_JSON over a rolling TIER_WINDOW_DAYS window. get_tier reads the subscriptions row (mirrored from Stripe). check_and_record_analysis gates count + tier LLM budget then meters one usage_events row (metering is best-effort/fail-open; the check is fail-closed). check_artifact_quota counts existing application_artifacts. clamp_model downgrades detailed->fast for Free. Stripe (optional [billing] extra, lazy import): Checkout session, customer portal, signature-verified webhook mirroring (checkout.completed / subscription.updated / deleted) into subscriptions. - db: subscriptions + usage_events tables (migration 9e4b7d21c803, up/down/up verified); billing.* audit kinds. - Enforcement wiring: analysis_runner.check_user_quota (all entry points), tailoring.generate_* (artifact quota), api/auth.require_user (API = Power feature, 402), api/routes.post_analyze (clamp + 402 on tier limit). - api/billing.py: POST /v1/billing/webhook (unauthenticated, signature- verified, 503 when unconfigured) + GET /v1/billing/plan. - app.py: "Plan & usage" sidebar panel (usage meters, upgrade -> Checkout, manage -> customer portal), tier errors caught in analyze + artifact flows, model clamping with a friendly notice. - landing/: self-contained static landing page (verdict-demo hero, no- fabrication guarantee, pricing mirroring the tier table) + deploy README. - CI: subscriptions/usage_events in the Postgres table assertion. CLAUDE.md documents the billing invariant. uv.lock: + stripe. - tests: 26 new (tier resolution incl. disabled=unlimited, TIER_LIMITS_JSON merge, analysis/artifact/budget quotas, clamp, webhook lifecycle, checkout, API 402 gate, webhook 503/400, tailoring integration). Full suite green (673), ruff/mypy (80 files)/bandit clean. https://claude.ai/code/session_01Vpu7T5ezA2RAJhfpPxBzQd
…docs; legal templates Hardening (implemented): - utils/security.check_url_allowed: SSRF policy for user-supplied URLs — http/https only; IP-literal or DNS-resolved private/loopback/link-local/ reserved targets rejected (cloud metadata, localhost services, RFC-1918). Unresolvable hostnames pass (the fetch fails identically; the attack needs resolution to a private IP). SSRF_ALLOW_PRIVATE_URLS=1 opt-out for self-hosted/dev. Wired into the two user-controlled sinks: url_ingest.fetch_job_posting and webhooks.register_webhook. 10 new tests. DNS-rebinding/redirect residuals documented as planned work. Launch collateral (docs): - docs/STRIPE_SETUP.md: account registration + KYC (sole proprietor, SSN/EIN), dashboard config (products/prices, webhook events, customer portal), a 12-step test-mode dry run, go-live checklist, and the Merchant-of-Record decision (Stripe vs Lemon Squeezy/Paddle) with a revisit-at-MRR rule. - docs/HARDENING.md: threat-model inventory for the hosted multi-tenant deployment (prompt injection, SSRF, uploads, rendered output, tenant data/process isolation, abuse/cost) with shipped/partial/planned status and a priority order for launch. - docs/GTM.md: positioning, zero-CAC channel plan, product-analytics design on existing tables (usage_events/subscriptions/llm_usage) + funnel targets with a 60-day decision gate, and a <=$40/mo single-box validation architecture mapped to existing repo pieces. - landing/terms.html + landing/privacy.html: ToS + privacy-policy templates (marked for legal review; match the app's real data practices — export/ delete, encrypted TOTP, no model training on user content). Full suite green (683), ruff/mypy/bandit clean. https://claude.ai/code/session_01Vpu7T5ezA2RAJhfpPxBzQd
… deploy topology The minimum to put it in front of real users and measure demand — then stop building and go sell. Funnel analytics (decide with data, no third-party tool): - services/funnel.compute_funnel: cross-user operator metrics from existing tables — signups, activation (signup->first analysis), the aha metric (>=3 analyses in a user's first week), engagement, free->paid, est MRR + COGS. - worker/funnel_report.py: cron-friendly CLI (--days/--json). Read-only. Activation / time-to-first-verdict: - app.py: anonymous "See a sample verdict" preview on the auth screen (zero cost, no LLM call) so visitors grasp the value before signing up; and a first-run "Try a sample posting" one-click for new users (no saved apps yet) that pre-fills a realistic posting so the first verdict is seconds, not a blank textarea. Waitlist (capture leads not ready to sign up): - WaitlistEntry model + migration b2f7c9d04a16; services/waitlist (validate, normalise, rate-limit, dedupe-as-noop); public POST /waitlist (CORS scoped to LANDING_ORIGIN); email-capture form wired into landing/index.html. Deploy topology (cheapest path to live): - deploy/Caddyfile.fullstack: one box, landing at / + Streamlit at /app + API at /api, auto-TLS; deploy/README "Single-box validation deploy" + "Funnel report" sections. CI: waitlist_entries in the Postgres table assertion. CLAUDE.md + .env.example updated. uv.lock unchanged (no new deps). 14 new tests. Full suite green (697), ruff/mypy(84 files)/bandit clean. https://claude.ai/code/session_01Vpu7T5ezA2RAJhfpPxBzQd
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #2. Turns the production-ready app into a sellable, launch-ready microSaaS, then adds the minimum to validate demand: billing/tiers + Stripe, an SSRF guard, the landing page + launch docs, and the founder validation unblockers (funnel analytics, activation/empty-state, waitlist, one-box deploy topology).
4 commits · suite green (697 tests, 7 live-e2e skipped) · ruff + mypy + bandit clean.
Billing & tiers (
feat(billing))Core invariant: billing never constrains self-hosters — no
STRIPE_SECRET_KEY⇒ everyone isunlimitedand all checks are no-ops. With Stripe, no-subscription = Free tier.Tier table in code (Free 5/2/fast · Pro $12 50/30/detailed · Power $24 200/∞/API),
TIER_LIMITS_JSON-overridable. Enforcement rides the existing quota machinery (check_user_quotagates count + tier budget then meters ausage_eventsrow; artifact quota intailoring; API = Power feature, 402;clamp_modelfor Free). Stripe (optional[billing]extra, lazy): Checkout, customer portal, signature-verified webhook →subscriptionstable. UI "Plan & usage" panel. Migration9e4b7d21c803. 26 tests.SSRF guard
utils/security.check_url_allowed: user-supplied URLs (posting ingestion, webhook endpoints) reject private/loopback/link-local/metadata targets at both server-side sinks.SSRF_ALLOW_PRIVATE_URLS=1opt-out. 10 tests; residuals indocs/HARDENING.md.Validation unblockers (
feat(validation))The minimum to put it in front of users and measure:
services/funnel.compute_funnel+worker/funnel_report.py(cron CLI): activation, the aha metric (≥3 analyses in a user's first week), free→paid, est MRR + COGS — all from existing tables, no third-party tool.WaitlistEntry+ publicPOST /waitlist(CORS-scoped, rate-limited, dedupe-as-noop) + email form on the landing page. Migrationb2f7c9d04a16.deploy/Caddyfile.fullstack(one box: landing/+ app/app+ API/api, auto-TLS) + a "Single-box validation deploy" guide.Launch collateral
landing/static site (+ Terms/Privacy templates);docs/STRIPE_SETUP.md(KYC, 12-step test-mode dry run, MoR alternatives);docs/HARDENING.md(threat model + priority order);docs/GTM.md(channels, funnel targets + 60-day gate, ≤$40/mo architecture).Migrations
9e4b7d21c803(billing) +b2f7c9d04a16(waitlist) — CI runsup → down → upon Postgres; schema-drift guard asserts models match.Test plan
python -m unittest discover -s tests→ 697 pass (7 live-e2e skipped)ruff check ./mypy/bandit -r . -ll→ cleanhttps://claude.ai/code/session_01Vpu7T5ezA2RAJhfpPxBzQd