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
| Layer | Technology |
|---|---|
| Backend | Ruby on Rails (v7), PostgreSQL, Redis for background jobs |
| Background processing | Sidekiq, ActionCable for real‑time events |
| API Layer | Rails API mode with Swagger/OpenAPI docs, optional GraphQL via graphql-ruby |
| Auth & RBAC | Devise + Pundit for fine‑grained permissions |
| Containerization | Docker images published on Docker Hub; Helm charts for Kubernetes |
| CI/CD | GitHub 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 –
/eventsendpoint 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 rspeclocally 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
- 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.
- Freemium with Upsell – Offer a free tier with usage caps; once the cap is exceeded, automatically upgrade to a paid plan.
- Marketplace Platforms – Split revenue with third‑party sellers; Lago can allocate usage credits and generate partner invoices.
- Embedded Analytics – Expose internal metrics via Lago’s API to a front‑end dashboard for product managers.
- Hybrid Billing – Combine subscription billing with
Open SourceReady to get started?
Join the community and start self-hosting Lago today
Related Apps in other
Immich
Self‑hosted photo and video manager
Syncthing
Peer‑to‑peer file sync, no central server
Strapi
Open-source headless CMS for modern developers
reveal.js
Create stunning web‑based presentations with HTML, CSS and JavaScript
Stirling-PDF
Local web PDF editor with split, merge, convert and more
MinIO
Fast, S3-compatible object storage for AI and analytics
Weekly Views
Repository Health
Information
Explore More Apps
Tamari
Your personal recipe manager and meal planner
NodeBB
Modern, real‑time community forum platform
Flipt
Git-native feature flags for safe, instant deployments
Puter
Your personal internet OS for files, apps, and games

Jami
Peer‑to‑peer encrypted communication for all devices
HyperSwitch
Composable open‑source payments infrastructure
.png&w=3840&q=75)