# How to Vibe Code Your Own Baremetrics (and Stop Paying for It)

> Subscription Analytics for your Business

- Site: https://baremetrics.com
- Category: SaaS Analytics & Metrics
- Platforms: Web app
- Verdict: **Solid side project** (68/100 vibecodeable)
- Estimated effort: 3-4 weeks of focused development and debugging

## Verdict

Build a single-gateway personal clone for your own SaaS in a few weekends, but keep paying for Baremetrics if you need multi-gateway billing normalization and audit-grade financial precision.

The UI and basic dashboard charts are straightforward to generate with an AI agent. The real engineering trap is writing the financial calculation engine: correctly categorizing MRR movements (new, expansion, contraction, churn) from raw asynchronous billing webhooks without double-counting prorations or trial conversions requires meticulous date math and idempotent transaction ledgers. Expect to spend significant iteration time debugging edge cases in subscription lifecycle state machines.

### What you can't replicate

- Certified integrations across dozens of billing gateways (Chargebee, Recurly, Braintree, Shopify)
- Proprietary benchmark data across 900+ real companies
- Guaranteed payment recovery ROI models

## What it does

Subscription analytics and financial metrics platform that aggregates billing data from providers like Stripe to calculate MRR, ARR, churn, and LTV.

### Core features

- Billing webhook ingestion engine (Stripe, etc.)
- Financial ledger normalization and MRR calculation engine
- MRR movement categorization (new, expansion, contraction, churn)
- Interactive financial metrics dashboard (MRR, ARR, LTV, churn)
- Automated dunning and payment recovery workflow
- Cancellation exit survey and win-back form
- Forecasting and scenario planning modeler
- Team user management and role permissions

## The business

### Pricing

- Launch: $75/mo — For businesses up to $360K ARR with single integration
- Growth: $255/mo — For businesses up to $3.6M ARR with up to two integrations
- Scale: $1,152/mo — For enterprises with $3.6M+ ARR and unlimited integrations

Founded 2013.
Team size: 10-20.

## The hard parts

- Timezone-aligned MRR calculation edge cases (prorations, mid-cycle upgrades, refunds, trial conversions)
- Asynchronous webhook retry and idempotency handling across high-volume event streams
- Financial accuracy matching exact accounting standards with zero arithmetic drift

## How to vibe code Baremetrics

### Prerequisites

- Node.js (free): Required runtime for Next.js and TypeScript tooling.
- GitHub (free): Source control and deployment pipeline integration.
- Stripe Account (free): Source billing data and webhook testing for your personal SaaS.

### Recommended AI tools

- Claude Code: Autonomous multi-file agentic coding tool ideal for building complex calculation backends and database schemas.
- Cursor: AI-native editor for refining chart components, dashboard layouts, and reviewing code diffs.

### Stack

- Frontend: Next.js with Tailwind CSS and Recharts
- Backend: Next.js App Router API Routes
- Database: Turso (SQLite at the edge)
- Auth: better-auth
- Payments: Stripe (Webhook ingestion target only)
- Other: Resend for email alerts and dunning

### Hosting

- Cloudflare (Hosting Next.js frontend, API routes, and Turso database connection over edge): $0-5/mo

### Build guide

1. **Project Scaffolding & Database Schema** — Initialize the Next.js project with TypeScript, Tailwind CSS, and Turso SQLite via better-auth, establishing database tables for organizations, customers, subscriptions, invoices, and webhook audit logs.

```
Create a new Next.js 16 project using the App Router, TypeScript, and Tailwind CSS. Configure better-auth with email/password authentication linked to a Turso SQLite database using Drizzle ORM. Set up database tables for: organizations, customers (id, external_id, name, email, created_at), subscriptions (id, customer_id, status, plan_name, mrr, billing_interval, current_period_start, current_period_end, canceled_at), invoices (id, customer_id, subscription_id, amount_due, amount_paid, status, created_at), and webhook_logs (id, event_id, type, payload, processed_at, status). Include proper indexes on customer_id and subscription timestamps.
```

2. **Stripe Webhook Ingestion Engine** — Build secure webhook ingestion endpoints for Stripe events (customer.subscription.created, updated, deleted, invoice.payment_succeeded, invoice.payment_failed), ensuring idempotent processing and robust error catching.

```
Build a secure Stripe webhook API route in Next.js (/api/webhooks/stripe) that verifies webhook signatures using the Stripe SDK. Implement idempotent event handling by checking the webhook_logs table. Handle the following events: customer.subscription.created, customer.subscription.updated, customer.subscription.deleted, invoice.payment_succeeded, and invoice.payment_failed. On each event, parse the payload, update or insert customer and subscription records in the Turso database, and log the raw event. Ensure timezone handling normalizes all subscription amounts to monthly recurring revenue (MRR) values regardless of billing interval (annual, monthly).
```

3. **Financial Calculation Engine (MRR & Churn)** — Implement the core analytics calculation engine that computes MRR, ARR, Net Revenue Retention (NRR), Customer Lifetime Value (LTV), and breaks down MRR movements into new, expansion, contraction, and churn.

```
Write a robust calculation utility in TypeScript for SaaS subscription metrics. Implement functions to compute: Total MRR, ARR (MRR * 12), Average Revenue Per User (ARPU), Customer Churn Rate, Revenue Churn Rate, and LTV. Implement an MRR movement breakdown engine that compares a customer's active subscriptions between month N-1 and month N to accurately categorize MRR deltas into: New MRR (first-time subscribers), Expansion MRR (upgrades), Contraction MRR (downgrades), and Churn MRR (cancellations). Write comprehensive unit test cases covering edge cases like mid-cycle proration and trial conversions.
```

4. **Dashboard Control Center UI** — Design and build the main analytics dashboard with Recharts, displaying high-level KPI metric cards and historical MRR movement trend charts.

```
Build the main dashboard view in Next.js using Tailwind CSS and Recharts. Create KPI metric cards at the top for Current MRR, ARR, Net Churn Rate, ARPU, and Total Active Customers, showing month-over-month percentage changes. Below the KPI cards, implement two interactive charts: an area chart showing MRR growth breakdown (New, Expansion, Contraction, Churn) over the last 12 months, and a line chart tracking customer count and churn over time. Fetch data dynamically from internal API routes querying the Turso metrics tables.
```

5. **Automated Dunning & Payment Recovery** — Implement payment failure detection, automated email dunning sequences via Resend, and branded card-update landing pages.

```
Build a payment recovery (dunning) subsystem. When an invoice.payment_failed webhook arrives, record a dunning session and trigger an automated email via Resend to the customer with a secure, tokenized link to a hosted card-update page. Create a frontend page (/billing/update-payment/[token]) where customers can securely update their default payment method via Stripe Elements. Upon successful card update, automatically clear the dunning alert and trigger an API call to retry the failed invoice in Stripe.
```

6. **Cancellation Insights & Exit Surveys** — Build a cancellation feedback flow and exit survey widget that captures cancellation reasons and feeds into churn analytics.

```
Build a cancellation insights module. Create an embeddable exit survey modal component that triggers when a user attempts to cancel their subscription. The survey should collect structured feedback (reasons like 'too expensive', 'missing features', 'switching to competitor', 'other') and optional free-text comments, saving responses to a cancellation_surveys table. Build a dedicated analytics view in the dashboard that visualizes churn reasons by percentage and total lost MRR per cancellation category.
```

7. **Testing, Deployment & Polish** — Perform end-to-end testing with Stripe CLI test events, verify calculation accuracy, and deploy the application to Cloudflare.

```
Perform a comprehensive review and polish of the application. Set up Stripe CLI test webhook forwarding to test end-to-end data flow from test checkout sessions through webhook ingestion to dashboard metric rendering. Add loading skeletons, error boundaries, and mobile-responsive layout adjustments using Tailwind CSS. Configure environment variables for Turso, Stripe, and Resend, and prepare the project deployment configuration for Cloudflare.
```

### Cost vs paying

**Starting costs (one-time):**

- AI Coding Assistant Subscriptions: $20
- Domain Name (optional): $12
- Total: ~$32 one-time

**Ongoing costs (monthly):**

- Cloudflare Workers & Turso Database: $0
- Resend Email API (Free tier): $0
- Total: ~$0/mo

- Paying for the SaaS instead: $75/mo (Launch tier)
- Build time: 40-60 hours
- AI tool credits: $20/mo (Claude Pro / Cursor Pro)
- Break-even: Self-hosted personal clone is free forever; paying for SaaS makes sense only if you need multi-gateway support and zero-maintenance reliability.

## Sources

- [Baremetrics Homepage](https://baremetrics.com)
- [Baremetrics Pricing Page](https://baremetrics.com/pricing)