Pmitz is our open-source toolkit for developers to enforce subscriptions and usage limits in multi-tenant applications, available as a Java library or a remote server.
GitHub: https://github.com/terpomo-io/pmitz
What it does
- Gate features by subscription and plan
- Enforce count limits and calendar-period rate limits
- Override limits per user, subscription, or directory group
- Store usage in JDBC databases (PostgreSQL, MySQL, SQL Server)
- Run embedded in your app or as a Spring Boot server with API key auth
Install
Maven:
<dependency>
<groupId>io.terpomo.pmitz</groupId>
<artifactId>pmitz-all</artifactId>
<version>0.9.0</version>
</dependency>
Gradle:
dependencies {
implementation 'io.terpomo.pmitz:pmitz-all:0.9.0'
}
Requirements: Java 17.
Run it with Docker
docker run -d \
-p 8080:8080 \
-e SPRING_PROFILES_ACTIVE=postgresql \
-e PMITZ_API_KEY=my-secure-api-key \
-e SPRING_DATASOURCE_URL=jdbc:postgresql://your-db-host:5432/pmitz \
-e SPRING_DATASOURCE_USERNAME=pmitz \
-e SPRING_DATASOURCE_PASSWORD=your-db-password \
terpomo/pmitz-remoteserver:0.9.0
API examples
Add a product:
curl -X POST http://localhost:8080/products \
-H "Content-Type: application/json" \
-H "X-Api-Key: YOUR_API_KEY" \
-d '{
"productId": "Library",
"features": [{
"featureId": "Books",
"limits": [{
"type": "CountLimit",
"id": "Max books",
"count": 5,
"unit": "books"
}]
}]
}'
Check usage:
curl -H "X-Api-Key: YOUR_API_KEY" \
"http://localhost:8080/users/user1/usage/Library/Books"
Record usage:
curl -X POST "http://localhost:8080/users/user1/usage/Library/Books" \
-H "Content-Type: application/json" \
-H "X-Api-Key: YOUR_API_KEY" \
-d '{"units": {"Max books": 2}, "reduceUnits": false}'
Resources
- Source and docs: https://github.com/terpomo-io/pmitz
- Docker image: https://hub.docker.com/r/terpomo/pmitz-remoteserver
- License: Apache 2.0
