Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

496 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Meterplex Logo

Meterplex

Open-source B2B usage metering, entitlements, and billing platform.

CI Status OpenSSF Scorecard Best Practices Code Coverage Security: Gitleaks Hooks: Lefthook Documentation MIT License Node: 24

Buy me a coffee at ko-fi.com

ContributingSecurity


What is Meterplex?

Meterplex is a high-performance, developer-first billing engine that manages plans, tracks usage events, enforces quotas in real time, and maintains auditability. Designed as a modular monolith, it allows you to easily scale from a simple SaaS application to an event-driven microservices architecture.


Key Features

  • 👤 Multi-Tenant Identity & Access - Secure JWT authentication, tenant isolation, and Stripe-like API keys (using hashed storage and constant-time comparison).
  • 🏷️ Plans & Entitlements - Programmable features (boolean flags, reset quotas, metered features) with snapshotted entitlements to protect existing contracts.
  • Usage Ingestion Pipeline - Guaranteed, idempotent event delivery using the Transactional Outbox Pattern and Kafka event streams with concurrency safety (SKIP LOCKED).
  • 🔢 Atomic Aggregations - Concurrent real-time usage tracking using Postgres raw SQL upserts and atomic Redis caching with auto-expiring TTLs.
  • 📋 Audit-Ready Ledgers - Append-only transactional database logs and built-in dead-letter auditing to triage and reprocess failed billing events.

Quick Start

Prerequisites

Make sure you have Node.js >= 24, pnpm >= 9, and Docker installed.

1. Clone & Initialize

Run the Interactive Setup Wizard to automatically install dependencies, start containers, and seed the database in a single step:

git clone https://github.com/chitrank2050/meterplex.git
cd meterplex
pnpm dev:init

2. Verify Installation

# Health check (should return status: ok)
curl http://localhost:3000/health

# Open API Swagger / Scalar Documentation
# http://localhost:3000/api/docs

For custom configs, manual setups, or daily commands, refer to the Development Setup Guide.


Architecture

Meterplex is structured as a modular monolith to combine the operational simplicity of a single deployable unit with strict domain boundary isolation.

┌────────────────────────────────────────────────────┐
│                    NestJS App                      │
│                                                    │
│  ┌──────────┐ ┌──────────┐ ┌──────────┐            │
│  │  Tenants │ │  Usage   │ │ Billing  │  ...more   │
│  │  Module  │ │  Module  │ │  Module  │  modules   │
│  └────┬─────┘ └─────┬────┘ └─────┬────┘            │
│       │             │            │                 │
│  ┌────▼─────────────▼────────────▼─────┐           │
│  │          Prisma (PostgreSQL)        │           │
│  └─────────────────────────────────────┘           │
│       │             │           │                  │
│  ┌────▼──┐    ┌─────▼───┐  ┌────▼──┐               │
│  │ Redis │    │  Kafka  │  │ Cron  │               │
│  └───────┘    └─────────┘  └───────┘               │
└────────────────────────────────────────────────────┘
Domain Technology Purpose
Backend NestJS 11 Modular application framework
Language TypeScript 6.0 Type-safe business logic
Database PostgreSQL 18 + Prisma 7 Data persistence & transactional outbox
Messaging Apache Kafka 4.2 Async event-driven processing
Caching Redis 8 Distributed caching & real-time quotas

Learn more about our design decisions in the Architecture Overview.


Documentation

🚀 Live Docs: chitrank2050.github.io/meterplex

Deep-dive technical documentation is organized across:

  • 📖 Architecture Guides - Core design principles, ER diagrams, and data flow.
  • 🛠️ Development Guide - Custom configuration, local troubleshooting, and code conventions.
  • 📡 API Reference - Request/Response structures and routing details.
  • 🔄 Release & Changelog - Git hygiene, conventional commits, and automated release pipelines.

License

Meterplex is licensed under the MIT License.

If you use Meterplex in your project, a star or credit is appreciated.


❤️ Developed by Chitrank Agnihotri

About

Open-source B2B usage metering, entitlements, and billing platform. Built with NestJS, Postgres, Kafka, Redis, and Prisma.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Sponsor this project

Used by

Contributors

Languages