💸 profitable
- SaaS metrics for your Rails app
Calculate the MRR, ARR, churn, LTV, ARPU, total revenue & estimated valuation of your pay
-powered Rails SaaS app, and display them in a simple dashboard.
Why
pay
is the easiest way of handling payments in your Rails application. Think of profitable
as the complement to pay
that calculates business SaaS metrics like MRR, ARR, churn, total revenue & estimated valuation directly within your Rails application.
Usually, you would look into your Stripe Dashboard or query the Stripe API to know your MRR / ARR / churn – but when you're using pay
, you already have that data available and auto synced to your own database. So we can leverage it to make handy, composable ActiveRecord queries that you can reuse in any part of your Rails app (dashboards, internal pages, reports, status messages, etc.)
Think doing something like: "Your app is currently at $#{Profitable.mrr} MRR – Estimated to be worth $#{Profitable.valuation_estimate("3x")} at a 3x valuation"
Installation
Add this line to your application's Gemfile:
gem 'profitable'
Then run bundle install
.
Provided you have a valid pay
installation (Pay::Customer
, Pay::Subscription
, Pay::Charge
, etc.) everything is already set up and you can just start using Profitable
methods right away.
Mount the /profitable
dashboard
profitable
also provides a simple dashboard to see your main business metrics.
In your config/routes.rb
file, mount the profitable
engine:
mount Profitable::Engine => '/profitable'
It's a good idea to make sure you're adding some sort of authentication to the /profitable
route to avoid exposing sensitive information:
authenticate :user, ->(user) { user.admin? } do
mount Profitable::Engine => '/profitable'
end
You can now navigate to /profitable
to see your app's business metrics like MRR, ARR, churn, etc.
Main Profitable
methods
All methods return numbers that can be converted to a nicely-formatted, human-readable string using the to_readable
method.
Revenue metrics
Profitable.mrr
: Monthly Recurring Revenue (MRR)Profitable.arr
: Annual Recurring Revenue (ARR)Profitable.all_time_revenue
: Total revenue since launchProfitable.revenue_in_period(in_the_last: 30.days)
: Total revenue (recurring and non-recurring) in the specified periodProfitable.recurring_revenue_in_period(in_the_last: 30.days)
: Only recurring revenue in the specified periodProfitable.recurring_revenue_percentage(in_the_last: 30.days)
: Percentage of revenue that is recurring in the specified periodProfitable.new_mrr(in_the_last: 30.days)
: New MRR added in the specified periodProfitable.churned_mrr(in_the_last: 30.days)
: MRR lost due to churn in the specified periodProfitable.average_revenue_per_customer
: Average revenue per customer (ARPC)Profitable.lifetime_value
: Estimated customer lifetime value (LTV)Profitable.estimated_valuation(at: "3x")
: Estimated company valuation based on ARR
Customer metrics
Profitable.total_customers
: Total number of customers who have ever made a purchase or had a subscription (current and past)Profitable.total_subscribers
: Total number of customers who have ever had a subscription (active or not)Profitable.active_subscribers
: Number of customers with currently active subscriptionsProfitable.new_customers(in_the_last: 30.days)
: Number of new customers added in the specified periodProfitable.new_subscribers(in_the_last: 30.days)
: Number of new subscribers added in the specified periodProfitable.churned_customers(in_the_last: 30.days)
: Number of customers who churned in the specified period
Other metrics
Profitable.churn(in_the_last: 30.days)
: Churn rate for the specified periodProfitable.mrr_growth_rate(in_the_last: 30.days)
: MRR growth rate for the specified periodProfitable.time_to_next_mrr_milestone
: Estimated time to reach the next MRR milestone
Growth metrics
Profitable.mrr_growth(in_the_last: 30.days)
: Calculates the absolute MRR growth over the specified periodProfitable.mrr_growth_rate(in_the_last: 30.days)
: Calculates the MRR growth rate (as a percentage) over the specified period
Milestone metrics
Profitable.time_to_next_mrr_milestone
: Estimates the time to reach the next MRR milestone
Usage examples
Profitable.mrr.to_readable
Profitable.new_customers(in_the_last: 60.days).to_readable
Profitable.churn(in_the_last: 3.months).to_readable
Profitable.new_mrr(in_the_last: 24.hours).to_readable(2)
Profitable.estimated_valuation(multiple: 5).to_readable
Profitable.estimated_valuation(at: "4.5x").to_readable
Profitable.time_to_next_mrr_milestone.to_readable
All time-based methods default to a 30-day period if no time range is specified.
Numeric values and readable format
Numeric values are returned in the same currency as your pay
configuration. The to_readable
method returns a human-readable format:
- Currency values are prefixed with "$" and formatted as currency.
- Percentage values are suffixed with "%" and formatted as percentages.
- Integer values are formatted with thousands separators but without currency symbols.
For more precise calculations, you can access the raw numeric value:
Profitable.mrr
Notes on specific metrics
mrr_growth_rate
: This calculation compares the MRR at the start and end of the specified period. It assumes a linear growth rate over the period, which may not reflect short-term fluctuations. For more accurate results, consider using shorter periods or implementing a more sophisticated growth calculation method if needed.time_to_next_mrr_milestone
: This estimation is based on the current MRR and the recent growth rate. It assumes a constant growth rate, which may not reflect real-world conditions. The calculation may be inaccurate for very new businesses or those with irregular growth patterns.
Development
After checking out the repo, run bin/setup
to install dependencies. Then, run rake spec
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
.
TODO
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/rameerez/profitable. Our code of conduct is: just be nice and make your mom proud of what you do and post online.
License
The gem is available as open source under the terms of the MIT License.