MCPSERV.CLUB
Lago

Lago

Self-Hosted

Open‑source usage‑based billing for SaaS and subscription services

Active(96)
8.7kstars
0views
Updated 2 days ago
Lago screenshot 1
1 / 5

Overview

Discover what makes Lago powerful

Lago is a fully self‑hosted, open‑source billing engine that targets modern SaaS products requiring **usage‑based** and **subscription‑mixed** pricing. From a developer’s perspective, it is an event‑driven microservice that ingests raw usage events, normalizes them against configurable pricing plans, and exposes a rich REST/GraphQL API for invoicing, metering, and revenue recognition. The core idea is to treat every measurable action as an event that can be charged, allowing teams to ship new features without waiting for a billing partner.

Event‑driven metering

Hybrid pricing

Revenue recognition

API‑first

Overview

Lago is a fully self‑hosted, open‑source billing engine that targets modern SaaS products requiring usage‑based and subscription‑mixed pricing. From a developer’s perspective, it is an event‑driven microservice that ingests raw usage events, normalizes them against configurable pricing plans, and exposes a rich REST/GraphQL API for invoicing, metering, and revenue recognition. The core idea is to treat every measurable action as an event that can be charged, allowing teams to ship new features without waiting for a billing partner.

Key Features

  • Event‑driven metering – ingest arbitrary JSON events, map them to billing dimensions via rules, and aggregate on the fly.
  • Hybrid pricing – support tiered, per‑unit, flat‑rate, and overage models in a single plan definition.
  • Revenue recognition – calculate deferred revenue automatically for subscriptions with multiple billing cycles.
  • API‑first – all functionality is exposed through a well‑documented REST API; optional GraphQL for flexible queries.
  • Webhooks & callbacks – notify downstream services when invoices are generated, payments succeed, or usage thresholds hit.
  • Extensible plugins – plug in custom metering logic or payment providers without touching core code.

Technical Stack

LayerTechnology
BackendRuby on Rails (v7), PostgreSQL, Redis for background jobs
Background processingSidekiq, ActionCable for real‑time events
API LayerRails API mode with Swagger/OpenAPI docs, optional GraphQL via graphql-ruby
Auth & RBACDevise + Pundit for fine‑grained permissions
ContainerizationDocker images published on Docker Hub; Helm charts for Kubernetes
CI/CDGitHub Actions with automated tests, linting, and container publishing

The choice of Rails gives rapid iteration while PostgreSQL’s JSONB support allows flexible event storage. Redis is used for job queues and rate‑limiting, ensuring the system can handle millions of events per day.

Core Capabilities

  • Plan Management – CRUD APIs for plans, tiers, and metering rules.
  • Event Ingestion API/events endpoint accepts batched JSON payloads; events are stored, validated, and forwarded to the metering engine.
  • Metering Engine – runs scheduled jobs that aggregate events per customer, compute usage credits, and generate provisional invoices.
  • Invoicing & Payments – integration hooks for Stripe/PayPal; supports webhooks to mark invoices as paid.
  • Analytics – expose usage metrics, revenue per plan, churn predictions via built‑in dashboards or API queries.
  • SDKs – client libraries in Ruby, Python, Node.js (available as open‑source gems or npm packages).

Deployment & Infrastructure

  • Self‑hosted – Deploy via Docker Compose or Kubernetes; no external SaaS dependency.
  • Scalability – Horizontal scaling of Rails workers and Sidekiq; PostgreSQL can be read‑replicated.
  • High Availability – Use Kubernetes StatefulSets for Postgres, Redis Sentinel for failover; Sidekiq clustering for job resilience.
  • Observability – Integrated Prometheus metrics, Grafana dashboards; logs forwarded to ELK stack or Loki.
  • Backups – Automated PostgreSQL snapshots and object storage for event logs.

Integration & Extensibility

  • Payment Gateways – Abstract payment provider via a plugin interface; add Stripe, Braintree, or custom processors.
  • Custom Metering – Define Ruby blocks that run during event processing to compute derived metrics.
  • Webhooks & Callbacks – Subscribe to events such as invoice_created, payment_failed; payloads are JSON‑encoded.
  • API Hooks – Extend the API with custom endpoints by adding Rails controllers; authentication is enforced via JWT or API keys.
  • OpenAPI & GraphQL – Generate client SDKs automatically; developers can introspect the schema for rapid integration.

Developer Experience

  • Documentation – Comprehensive API docs, example payloads, and a “Getting Started” guide; hosted on GitHub Pages.
  • Community – Active Slack channel, GitHub Discussions, and a public roadmap; frequent releases under AGPL‑v3.
  • Configuration – Environment variables control everything from database URLs to Stripe secrets; no hard‑coded values.
  • Testing – RSpec test suite with CI integration; developers can run bundle exec rspec locally and validate against a Docker Compose stack.
  • Licensing – AGPL‑v3 ensures that any derivative works remain open; suitable for internal tools or public services.

Use Cases

  1. SaaS with Metered Features – A platform that charges per API call or data transfer can ingest events from its own services and let Lago handle billing logic.
  2. Freemium with Upsell – Offer a free tier with usage caps; once the cap is exceeded, automatically upgrade to a paid plan.
  3. Marketplace Platforms – Split revenue with third‑party sellers; Lago can allocate usage credits and generate partner invoices.
  4. Embedded Analytics – Expose internal metrics via Lago’s API to a front‑end dashboard for product managers.
  5. Hybrid Billing – Combine subscription billing with

Open SourceReady to get started?

Join the community and start self-hosting Lago today

Weekly Views

Loading...
Support Us

Featured Project

$30/month

Get maximum visibility with featured placement and special badges

Repository Health

Loading health data...

Information

Category
other
License
AGPL-3.0
Stars
8.7k
Technical Specs
Pricing
Open Source
Database
PostgreSQL
Docker
Dockerfile
Supported OS
LinuxDocker
Author
getlago
getlago
Last Updated
2 days ago