Skip to content

chitrank2050/meterplex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

456 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
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

Contributing β€’ Security


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

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Sponsor this project

Contributors