Lago is an open-source billing and metering platform designed for product-led SaaS companies that need flexible, hybrid pricing models combining subscriptions with usage-based charges. Built to replace proprietary solutions like Stripe Billing and Chargebee, Lago provides end-to-end billing capabilities including event ingestion, price plan configuration, coupon management, invoicing, and prepaid credits—all while keeping your financial data within your own infrastructure. It’s engineered for engineers who need full control over their billing stack without vendor lock-in or revenue-sharing fees. The platform supports both self-hosted and cloud deployments, with a modular architecture that integrates seamlessly with existing systems like CRMs, payment gateways, and analytics tools.
Lago is particularly valuable for startups and mid-sized SaaS businesses that outgrow simple subscription models but aren’t ready to invest in expensive commercial billing platforms. With its AGPLv3 license, it offers transparency and freedom to modify and extend the system as your pricing logic evolves. The project is backed by Y Combinator and has gained traction among engineering teams at companies like Qonto, Algolia, and Segment who needed more control over their billing infrastructure.
What You Get
- Event-based metering - Track usage through incoming events (e.g., API calls, feature usage) to dynamically calculate charges based on actual consumption, enabling fair pay-as-you-go pricing.
- Hybrid price plans - Create and manage complex pricing models that combine recurring subscription fees with variable usage-based charges in a single plan configuration.
- Automated invoicing - Generate and send invoices automatically at the end of billing cycles based on usage data, with support for tax calculations and multiple currencies.
- Coupons and discounts - Define and distribute promotional codes that apply percentage or fixed-value discounts to customer invoices, with configurable expiration and usage limits.
- Add-ons (one-time charges) - Apply on-demand, non-recurring charges to customer accounts mid-billing-cycle—for example, for premium support or one-time feature upgrades.
- Prepaid credits - Enable customers to purchase credits upfront and deduct them from usage-based charges, unlocking recurring revenue streams for pay-as-you-go models.
- Self-hosted deployment - Deploy the entire billing stack on your infrastructure using Docker Compose, ensuring data privacy and compliance with regulations like GDPR or SOC 2.
- Multi-language SDKs - Access Lago’s API via official Go, Python, Ruby, and JavaScript clients for seamless integration into your existing tech stack.
Common Use Cases
- Building a multi-tenant SaaS dashboard with usage-based pricing - A B2B analytics tool tracks user activity (e.g., 10,000 API calls/month) and charges customers $0.01 per call beyond a free tier, using Lago’s event ingestion and dynamic invoicing.
- Creating a mobile-first e-commerce platform with 10k+ SKUs - A retailer offers subscription boxes with variable item counts; Lago meters each shipment and generates invoices combining fixed monthly fees + per-item charges.
- Problem: Manual billing processes causing revenue leakage → Solution: Lago automates usage tracking and invoice generation - A cloud infrastructure startup was manually calculating usage from logs, leading to billing errors. Lago ingests event data from their Kafka pipeline and auto-generates accurate invoices with 99.9% reliability.
- DevOps teams managing microservices across multiple cloud providers - Teams use Lago to unify billing data from AWS, GCP, and Azure usage logs into a single dashboard, correlating resource consumption with customer billing tiers.
Under The Hood
The project is a Go-based event processing system designed for real-time billing and subscription management, emphasizing scalability, observability, and extensibility. It provides a modular architecture that supports flexible data ingestion and service orchestration.
Architecture
The system adopts a layered and component-driven architecture to manage complex event workflows with clear separation of concerns.
- The codebase is organized into distinct modules such as config, models, processors, and utilities, each with well-defined responsibilities
- Design patterns like strategy and service orientation are applied to support tracing, caching, and event enrichment
- Interfaces and abstractions are used to decouple components, enhancing testability and maintainability
Tech Stack
The project leverages Go’s performance characteristics and integrates with cloud-native tools for robust infrastructure support.
- Built primarily in Go, utilizing standard library packages and third-party modules for HTTP, database, and messaging operations
- Relies on Kafka for event streaming, Redis for caching, and PostgreSQL for persistence; integrates with Datadog and OpenTelemetry for tracing
- Employs Docker for containerization, Traefik for reverse proxying, and automation scripts for local development and deployment
- Uses Go’s native testing framework along with custom utilities and mocked services to ensure reliability and maintainability
Code Quality
The codebase reflects a moderate level of quality with structured testing and consistent practices, though some areas show room for improvement.
- Test coverage is comprehensive in key modules like database and Kafka configurations, with dedicated test files for core logic
- Error handling follows idiomatic Go patterns with appropriate exception management in configuration and workflow components
- Code consistency is maintained through established naming and modular structure, although minor style deviations exist
- Technical debt is evident in limited integration tests and minimal coverage for core business logic, indicating a need for enhanced validation
What Makes It Unique
This system distinguishes itself through its focus on real-time event processing in billing contexts, with a strong emphasis on extensibility and observability.
- Features a pluggable connector architecture that supports various data sources such as Kafka and SQS, enabling flexible ingestion pipelines
- Offers built-in support for multiple tracing backends with seamless configuration switching to enhance observability
- Incorporates caching and enrichment services to optimize event workflows in real-time billing scenarios
- Prioritizes developer experience with detailed Docker setups, local dev environments, and extensive deployment documentation