Launch
Refract
Visit
Example Image

Refract

Every SaaS pivots. Most codebases don't survive it.

Visit

Refract is a production-grade TypeScript SaaS boilerplate for teams that expect to pivot: pricing, plans, and integrations should be configuration—not a rewrite.

WHAT YOU GET

  • Billing — Stripe: dynamic plans/tiers, metered usage, proration, multi-currency, grace periods, checkout/upgrade/downgrade/cancel, billing controls, custom checkout UX. Idempotent webhooks and retries for production failure modes.
  • Auth & B2B — Multi-tenancy, scoped RBAC, password + OAuth, sessions, users, invites/revokes.
  • Infrastructure — Swap queue (SQS, BullMQ), mail (Brevo, SendGrid), cache, analytics adapters. Background jobs and email included.
  • Apps — GraphQL + codegen, Apollo server/client, React + MUI, TypeScript end-to-end.
  • Marketing + authenticated app in one monorepo.
  • Stack — PostgreSQL (Sequelize), Redis, Express, Apollo Server.
  • Observability — Structured logging, metrics (StatsD-oriented), analytics hooks.
  • Tests — 80%+ on billing and auth.
  • DX — Docker Compose, Makefile, CI (lint/build/test/codegen). Dev proxy: one origin for marketing, portal, API (OAuth/CORS like prod). Stripe CLI in Compose. Railway documented.
  • Docs & AI — In-repo onboarding and config. Cursor rules for consistent changes across backend, portal, tooling.
  • Principles — Composable core; vendor code behind swappable contracts so mail/queue/provider changes are adapter work.
  • Security — Validate at boundaries; ORM for DB; RBAC as product. Prefer bounded telemetry tags.

Who — Indie founders / small B2B teams; past-MVP teams; builders avoiding full rewrites when vendors change.

Why — Explicit boundaries + functional patterns. Full stack in Docker for repeatable onboarding.

Not a demo — Built for support load, billing edge cases, roles, integrations you have not chosen.

The pivot is a config change, not a rewrite.

Tech — React 19, Vite, MUI, Redux Toolkit, Apollo Client, React Router, RHF. Node, Express, Apollo Server, Sequelize, Postgres, Redis, Passport/JWT. Stripe; SQS/BullMQ; Brevo/SendGrid.

Example Image
Example Image
Example Image
Example Image
Example Image

Features

Business & Revenue Infrastructure

  • B2B-First Multi-Tenancy: Hardened organizations, granular roles, and secure invites. Skip the auth-design phase and move straight to your domain logic.
  • Production-Grade Billing: Battle-tested Stripe flows including self-serve upgrades, downgrades, and complex proration—not just "happy path" demos.
  • Consumption-Ready Pricing: A hybrid revenue engine that supports flat subscriptions, metered usage, and tiered plans out of the box.
  • Multi-Brand via Config: Deploy unique products or client brands from a single monorepo using specialized adapters and config-driven architecture.

Engineering & Delivery Speed

  • Unified Type-Safe Monorepo: One source of truth for your Admin UI, API, and Marketing site, powered by Shared Types and automated codegen.
  • Pivot-Proof Boundaries: Swap infrastructure—from mail providers to queue systems—via clean boundaries, avoiding the "full rewrite" trap when requirements change.
  • The "Agency" Superpower: A reusable foundational layer designed for studios to ship high-quality, customized client platforms in record time.
  • Symmetric AI Legibility: A directory structure and cursorrules optimized for AI agents, ensuring your LLM partner actually understands your intent.

Ops & Reliability

  • Reliable Revenue Hooks: Idempotent webhook handling and built-in retries to ensure your billing state never drifts from reality.
  • Local-to-Prod Parity: Docker-first development with a single-origin setup, ensuring OAuth and CORS work the same on your machine as they do in the cloud.
  • Zero-Friction Deployment: One-click paths to production via Railway with fully documented environment and service orchestration.

Use Cases

🚀 The High-Stakes B2B Startup

The Problem: You need to ship an MVP that looks like an Enterprise product (Orgs, Roles, Permissions) but your pricing model is still an experiment.

The Refract Edge: Launch with a robust B2B foundation on day one. If you decide to pivot from a $50/mo subscription to a usage-based credit model or a $2,000 one-off license, you swap a configuration adapter rather than rewriting your core billing logic.

🛠️ The "Modern" Agency & Studio

The Problem: Delivering high-quality custom SaaS for clients is slow because you’re constantly re-wiring Auth, Stripe, and Webhooks for every new project.

The Refract Edge: Use Refract as your "Gold Image." Its modular boundaries allow you to swap mail providers (Postmark vs. Resend) or databases per client while keeping a consistent, type-safe codebase that your team actually understands.

🤖 The AI-Native Product

The Problem: You’re building a wrapper or an agent-led tool where the code needs to be extremely organized so that AI coding assistants (like Cursor) don't hallucinate or break the logic.

The Refract Edge: Symmetric Legibility. Our "Direct-Map" directory structure provides a clear mental model for both humans and LLMs. The strict functional core ensures that AI-generated refactors stay within their lanes and don't leak into your infrastructure.

📈 The Hybrid Commerce Platform

The Problem: You want to sell a "Pro" subscription but also offer one-off "Power Packs," digital downloads, or top-up credits.

The Refract Edge: Refract handles the complexity of hybrid revenue. It’s a complete commerce engine that manages recurring MRR and one-time transactional sales within the same unified organizational context.

Comments

custom-img
Software engineer from big-tech in Calif...

I built Refract because I was tired of fighting codebases everywhere. It’s a foundation designed for the long game—explicit boundaries, pivot-proof billing, and zero infrastructure lock-in. Enjoy!

Social Links
custom-img
Software engineer from big-tec...
Makers
custom-img
Software engineer from big-tec...

Comments

custom-img
Software engineer from big-tech in Calif...

I built Refract because I was tired of fighting codebases everywhere. It’s a foundation designed for the long game—explicit boundaries, pivot-proof billing, and zero infrastructure lock-in. Enjoy!