Skip to content

Repository files navigation

Revenue Dashboard

A live dashboard of your Stripe revenue: MRR, new customers, and recent charges, refreshed on load with alerts posted to Slack. Built on One.

Template page: withone.ai/templates-vibe/revenue-dashboard

Revenue Dashboard

What it does

  • Live MRR, new-customer count, and recent charges straight from Stripe through the One SDK
  • Numbers refresh on every load. No cron jobs, no webhooks.
  • Posts a Slack alert when a payment over your threshold lands
  • One file of config: currency, threshold, Slack channel (src/lib/config.ts)

Out of the box the app runs on demo data, so it works before you add any keys.

Quick start

npm install
cp .env.example .env   # fill it in (see below)
npm run dev            # http://localhost:3000

Keys

Variable What it is
ONE_API_KEY Your One API key. Run one init or copy it from the One dashboard.
ONE_CONNECTION_STRIPE The key of your Stripe connection on One. Connect with one add stripe, then one list shows the key.
ONE_CONNECTION_SLACK Optional. Your Slack connection on One (one add slack). Leave empty to skip alerts.
SLACK_CHANNEL Optional. Where alerts go, e.g. #revenue or a channel ID. Required for alerts.

Optional tuning: ALERT_THRESHOLD (alert on payments at or over this amount in whole currency units, default 1000) and CURRENCY (ISO code for formatting, default usd).

One-click launch

After importing, add the keys above as secrets and restart.

How it works

Stripe ──One SDK──▶ subscriptions · customers · charges
                            │
                            ▼
              server computes MRR + deltas
                  on every page load
                            │
             payment over threshold?
                            │
              yes ──One SDK──▶ Slack alert
  • src/lib/revenue.ts: Stripe fetch, MRR math, Slack alerts
  • src/lib/config.ts: currency, alert threshold, Slack channel
  • src/app/dashboard.tsx: the dashboard UI (server rendered)

The One SDK queries Stripe for subscriptions, customers, and charges. The dashboard computes MRR and deltas server-side on each load. Yearly prices count as amount / 12, weekly as amount x 4.33.

Alert de-duplication is in memory: a Set of charge ids per server process. A restart forgets it, so a recent big payment can alert once more after a redeploy. Swap in a database if you need exactly-once.

License

MIT

About

A live dashboard of your Stripe revenue: MRR, new customers, and recent charges, with large-payment alerts posted to Slack. Built on One.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages