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

Refract is a production-ready TypeScript architecture for SaaS products that expect to change. Billing, RBAC, multi-tenancy, and background jobs already isolated into clear ownership boundaries — so the fifth pricing change is as easy as the first.

Adaptive billing engine Launch subscriptions, usage billing, and pricing tiers without custom infrastructure. Change pricing models without touching your product logic.
Change-safe architecture Functional core, 80%+ test coverage, explicit module boundaries. New features don't force you to untangle old decisions.
Cursor-native. Agent-ready. Clear module boundaries make AI coding tools safer and more effective. Your agents navigate structure instead of hallucinating it.

TypeScript monorepo · Express + Apollo · Real billing infrastructure · Ships with BullMQ and SQS

refract/

$ refract start

    Product tour

    See Refract in action.

    Pick a chapter: each one plays a different walkthrough on YouTube.

    The Architecture

    Built to survive what you can't predict.

    Four decisions made once, so every future decision costs less.

    ZERO LOCK-IN

    Swap providers.
    Touch zero product logic.

    Every external dependency lives behind a typed adapter interface. Switching providers is a one-line config change — not a sprint.

    // apps/backend/src/configuration/development.ts (tools excerpt)

    tools: {

    analytics.client: AnalyticsClientType.POSTHOG
    logger.client: LoggerClientType.PINO
    queue.client: MQType.BULLMQ
    mailer.client: MailerClientType.LOCAL
    paymentProcessor.client: PaymentProcessorClientType.STRIPE
    cache.client: CacheClientType.REDIS

    }; // product logic untouched ✓

    Auto-advancing

    This is what you inherit on day one — and what stays clean when you change any of it.

    Built to survive your third pricing experiment.

    Most SaaS products don’t fail because they launched poorly. They fail because every new feature gets harder than the last. Refract isolates billing, permissions, workers, and infrastructure into explicit ownership boundaries — so changing one system doesn’t require rewriting four others.

    Astro MarketingAstro · Content + IslandsReact AppTypeScript · Apollo ClientAPI boundaryTypedGraphQLAPIsWebhooksFunctional CoreTypeScript / ExpressBilling EngineRBAC / Multi-TenancyConsumersToolingDatabasesObservabilityMailerQueuesAnalyticsFeatureFlagsAIPaymentProcessoridempotent handlerstyped queue messagestyped adapter interfaces
    Hover over any provider to learn more

    Everything wired. Nothing locked in.

    The parts that cost founders the most — billing state, type propagation, deploy configuration, background workers — are already done.

    Stripe billing engine Subscriptions, trials, downgrades, and webhook reconciliation. One canonical path per business action. Idempotent consumers. No duplicate plan swaps when Stripe retries.
    BullMQ + SQS — both live today Switch between providers with one config value and credentials. Both are fully implemented and tested. The queue package that is not configured does not load.
    End-to-end codegen Backend GraphQL schema to typed portal hooks in one Make target. Rename a field and TypeScript fails every downstream consumer before the deploy starts.
    Full local stack in one command make fresh-start boots backend, portal, marketing, consumers, Stripe CLI, Postgres, Redis, and LocalStack. What runs locally is structurally identical to what runs in production.
    Railway deploy out of the box CD action and Railway templates wired. The deploy pipeline exists on day one.
    Cursor rules ship with the repo Preloaded patterns in .cursor/rules/ so AI agents stay in the right architectural layer and do not cross boundaries the compiler cannot see.
    RBAC + multi-tenancy Scoped permissions and organization membership built in. Access control lives in the domain layer, not scattered across route handlers.
    Observability out of the box Structured logging via Pino and StatsD metrics wired from day one. Every layer of the application — resolvers, queue consumers, webhook handlers — has access to the same logger and metrics interfaces via the toolbelt. LOCAL mock clients in development mean no external dependencies to run locally.
    Transactional email with swappable providers Brevo and Twilio SendGrid both implemented behind the mailer adapter. Switch providers with one config value. Email templates, delivery queuing, and retry logic ship pre-wired — not as a README instruction to set up yourself.
    Feature flags without vendor lock-in tools.featureFlags evaluates rollouts through PostHog or LaunchDarkly behind one contract. Request and optional shared caching keep GraphQL consistent. LOCAL covers development with no external service.
    Swappable adapters across the full stack Queue, mailer, logger, analytics, metrics, feature flags, payment processor, and cache all sit behind typed interfaces in a single config object. Every layer of the application receives the full toolbelt via dependency injection — resolvers, consumers, utilities, and webhook handlers all access the same interfaces the same way. Provider changes are config values, not sprints.
    Tech Stack

    Battle-tested technologies, thoughtfully integrated

    Every tool serves a purpose. No bloat, no experimental dependencies.

    Language & Runtime

    TypeScript logo TypeScript Node.js logo Node.js pnpm logo pnpm

    Frontend

    React logo React Astro logo Astro Vite logo Vite MUI logo MUI

    API

    GraphQL logo GraphQL Apollo logo Apollo

    Database & Cache

    Sequelize logo Sequelize PostgreSQL logo PostgreSQL Redis logo Redis

    Payments

    Stripe logo Stripe

    Infrastructure

    Docker logo Docker Railway logo Railway

    Queues

    BullMQ logo BullMQ AWS SQS logo AWS SQS

    Observability

    DataDog logo DataDog Amplitude logo Amplitude PostHog logo PostHog LaunchDarkly logo LaunchDarkly

    AI

    Anthropic logo Anthropic OpenAI logo OpenAI Google logo Google

    Swappable adapters mean you can replace any integration without rewriting core logic.

    Everything wired up. Nothing locked in.

    Every layer of a production SaaS — built, tested, and ready to extend.

    Plans, entitlements, and integrations stay behind adapter boundaries and config, so you change behavior without rewriting the core.

    Billing & Payments

    Adaptive billing engine Dynamic plans & tiers Product limits by plan Usage-cycle resets One-off products Metered usage Proration Multi-currency Grace periods Idempotent retries Custom checkout UX Billing controls Checkout & upgrade flows Downgrade & cancellation Stripe adapter

    Auth & Users

    Password & OAuth Sessions User management Invites & revokes Multi-tenancy Scoped RBAC

    Infrastructure

    Background job queues Webhook idempotency SQS + BullMQ adapters Caching layer Email flows Brevo & SendGrid adapters Anthropic, OpenAI & Google AI adapters

    Observability & Analytics

    Structured logging Metrics (StatsD) Analytics adapter Feature flags adapter PostHog & LaunchDarkly adapters

    API & Frontend

    GraphQL API GraphQL codegen Apollo server & client TypeScript end-to-end React + MUI frontend

    Developer Experience

    Makefile interface Monorepo layout Docker Compose local parity Lint, build, test & codegen in CI Environment-aware config Railway deployment 80%+ test coverage AI-ready docs & rules

    Architecture

    Clean onion architecture Functional programming patterns Swappable adapter interfaces Agent-legible codebase Growing integrations

    More integrations added with every release.

    Why Refract exists

    Built by someone who felt it on both sides.

    Hi, I'm Yoann. I've spent 15 years building software — from e-commerce and warehouse systems to venture-backed startups including Atrium (Justin Kan) and Loom, where I finished as Billing Tech Lead through the Atlassian acquisition.

    I felt the founder side first. Building my own SaaS, I needed to move in days, watching the codebase say months. Then Loom showed me exactly why — from the inside, at scale, through an acquisition.

    I watched a world-class engineering team spend months untangling decisions that should have been non-events.

    • Billing logic entangled in product features
    • Pricing changes that required a migration sprint
    • Subscription state with no clear owner

    The kind of technical debt that compounds quietly — until a pivot makes it impossible to ignore.

    Refract is 12 months of turning those lessons into the foundation I wish had existed. Not a packaged side project — it powers the website you're reading right now. Every abstraction earns its place the hard way.

    FAQ

    Frequently Asked Questions

    Everything you need to know about Refract and how it works.

    Why should I buy Refract instead of building my own SaaS foundation?

    Building authentication, billing, permissions, queues, observability, deployment, testing and documentation isn't the hard part. Building them well enough to evolve for years is.

    Refract gives you a production-ready architecture built from years of real-world SaaS experience, so you can spend your time building your product instead of rebuilding infrastructure.

    Read why I'm building Refract →

    How is Refract different from other SaaS starter kits?

    Most starter kits optimize for your first deployment. Refract optimizes for your fiftieth.

    Every major system—from billing to infrastructure providers—is designed behind stable contracts, making future changes predictable instead of expensive rewrites.

    Do I own the code?

    Yes. Refract is a one-time purchase, not a subscription.

    Once you purchase a license, you own the source code and can use it commercially according to your license tier. There are no runtime dependencies on Refract servers or licensing checks.

    What happens if Refract is no longer maintained?

    Nothing happens to your application.

    Since you own the source code, your SaaS keeps running exactly as it did before. Updates are a benefit—not a requirement for your application to function.

    Will Refract lock me into its architecture?

    No.

    Infrastructure concerns like payments, email, queues, caching and observability are abstracted behind TypeScript contracts. You can replace providers, remove modules or extend the platform without rewriting your application.

    Why is billing such a core part of Refract?

    Your product will probably change less often than your business model. Pricing, subscriptions and packaging evolve constantly as companies grow.

    Refract treats billing as a first-class architectural concern so changing plans, pricing or providers doesn't require rewriting your product.

    Will AI coding agents understand this codebase?

    Yes.

    Refract is structured with explicit architectural boundaries, strict TypeScript contracts and comprehensive AI documentation through AGENTS.md. The result is code that humans and AI agents can navigate consistently without guessing where changes belong.

    See how AGENTS.md is implemented in production →

    What technologies does Refract use?

    Refract is built with TypeScript throughout the stack, using React, Express, GraphQL, PostgreSQL and Docker.

    The architecture intentionally favors proven technologies with strong ecosystems rather than chasing short-lived trends.

    Read the full breakdown of the stack →

    Can I migrate an existing SaaS onto Refract?

    Yes.

    While Refract is ideal for greenfield projects, many teams introduce it gradually by migrating infrastructure concerns such as billing, authentication or permissions before moving additional features over time.

    Is Refract a good fit for solo founders and small teams?

    Absolutely.

    Refract gives solo founders the engineering foundation normally built by an experienced platform team. As you add teammates, license tiers scale with you, so the architecture doesn't need to change—only your seat count.

    How does licensing work?

    Licensing is tier-based, not per-project. Solo includes 1 seat, Startup includes 5 seats and Agency includes 12 seats with client handoff rights.

    Every tier includes unlimited projects within its scope, purchased once with lifetime usage rights.

    How are updates delivered?

    After purchasing, you'll receive GitHub access to the repository.

    Add Refract as an upstream remote and merge updates whenever you're ready. You're always in control of when and how your project evolves.

    What support is included?

    Every license includes documentation, setup guides and direct support.

    Whether you're getting started, integrating a provider or making an architectural decision, help is available when you need it.

    Pricing preview

    Simple, transparent pricing

    No feature gating. Pay for the license scope that fits your project.

    First 50 licenses at 40% off — locked for life on renewal.

    Solo

    $299 .00

    For technical founders building a portfolio of high-quality products on a single, rock-solid foundation.

    Startup

    $699 .00

    For teams scaling from MVP to production with fewer rewrites and cleaner handoffs.

    Agencies

    $1,499 .00

    For agencies shipping and handing off multiple client product tracks.

    Ready to build

    Start building on solid ground.

    Code is yours, forever 80%+ test coverage, production-ready Direct founder support included

    Purchase a lifetime license for your project or your agency. One-time payment, unlimited builds within your tier.