Skip to content

pretzelai/lumen

Repository files navigation

Discord Y Combinator Cloud Documentation

DM founders:
Connect Follow
Connect Follow
[email protected]

LumenLumen

The fastest way to add billing and feature access to your SaaS. Lumen is PSP agnostic and support merchants in India, United States and Europe through our integrations with Stripe & Dodo Payments. Integrations for Paddle, checkout.com, Razorpay and Adyen coming soon.

What is Lumen?

Lumen is a modern billing and entitlements platform that eliminates the complexity of implementing subscription management and feature access control. Unlike traditional approaches that scatter plan-based logic throughout your codebase, Lumen focuses on features instead of plans, making it trivial to modify pricing strategies without touching your code.

The Problem with Traditional Billing

Most developers implement Stripe with plan-based checks scattered throughout their codebase:

if (plan === "gold") {
  // give access to feature A
}

if (plan === "gold" || plan === "enterprise") {
  // give access to advanced analytics
  // also give access to feature B
}

When your business needs change (like moving a feature to a different plan or adding a free trial), engineers must hunt down and update every conditional without breaking existing functionality.

Solution

Lumen eliminates plan-based logic by focusing on features:

if (
  await isFeatureEntitled({ feature: "advanced-analytics", userId: user.id })
) {
  // give access
}

With this approach, your CRO can add the "advanced-analytics" feature to any plan with any trial period via the Lumen Dashboard, and everything just works!

Key Benefits

  • Feature-First Architecture: Structure your code around features, not plans
  • No Webhook Management: We handle all the complex Stripe webhook orchestration
  • Built-in UI Components: Ready-to-use React components for pricing tables and usage tracking
  • Usage-Based Billing: Track and bill for feature usage automatically
  • High Rate Limits: Call our APIs as much as you need without worrying about limits
  • Dashboard Management: Non-technical team members can manage pricing without code changes

Quick Integration

1. Install Packages

npm install @getlumen/server
npx shadcn@latest add https://getlumen.dev/pricing-table.json

2. Add Pricing Table (shadcn component)

import { PricingTable } from "@/components/ui/pricing-table";

export default function PricingPage() {
  return (
    <PricingTable
      lumenPublishableKey={process.env.NEXT_PUBLIC_LUMEN_PUBLISHABLE_KEY}
      userId={session?.user?.id}
      loginRedirectUrl="/login"
    />
  );
}

3. Control Feature Access

import { sendEvent, isFeatureEntitled } from "@getlumen/server";

export async function POST(request: NextRequest) {
  const { user } = await getUser();

  if (
    await isFeatureEntitled({
      feature: "ai-chat-requests",
      userId: user.id,
    })
  ) {
    // Your feature logic here...

    // Track usage after completion
    await sendEvent({
      name: "ai-chat-requests",
      userId: user.id,
    });
  }
}

Documentation

Services Overview

Getting Started

  • Start all services: bun run dev
  • Install ALL dependencies: bun install (at root)
  • Clean node modules and install everything fresh: bun run npm:delete-all && bun install
  • Clean DB, generate new schema and apply: bun run db:reset-schema
  • Generate changes to the better-auth schema in the correct location: bun run better-auth:generate-schema
  • Stop Docker services: bun run docker:down

API Server

Frontend

Development Services (via Docker)

  • PostgreSQL: localhost:5432

    • Database Name: lumen
    • Username: lumen
    • Password: lumen_local
  • MinIO:

  • pgAdmin: http://localhost:5050

    When you first log in to pgAdmin, you'll need to add the PostgreSQL server connection with these details:

    • Host: postgres (use the service name from docker-compose)
    • Port: 5432
    • Database: lumen
    • Username: lumen
    • Password: lumen_local

Access Details

About

Ship billing in minutes, not weeks

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages