A backend-first Subscription & Entitlement Management System built with Django and Django REST Framework. This application manages plans, subscriptions, usage limits, and meters in a clean, scalable, and industry-aligned way.
- 🔐 JWT Authentication (Login / Secure APIs)
- 📦 Subscription Plans (Free, Basic, Pro, etc.)
- 📊 Usage Meters (API calls, credits, feature usage)
- 🚦 Entitlements & Limits per plan
- 🔁 Atomic Transactions (ACID compliant)
- 🧩 Modular App Design (Subscriptions, Metering, Core)
- 📈 Scalable & Production-Ready Architecture
- Backend: Django 5.x, Django REST Framework
- Auth: JWT (djangorestframework-simplejwt)
- Database: PostgreSQL (SQLite for local dev)
- Caching (optional): Redis
- API Docs: DRF / Swagger (optional)
subscriptionEngine/
│── core/ # Users, base models, utilities
│── subscriptions/ # Plans, subscriptions, entitlements
│── metering/ # Usage meters & limits
│── resources/ # Courts, coaches, equipment (if enabled)
│── manage.py
│── requirements.txt
- User logs in using
/api/token/ - Receives access & refresh tokens
- Access token is sent in headers:
Authorization: Bearer <access_token>
- Protected APIs validate subscription & limits
-
User subscribes to a plan
-
Plan defines:
- Feature access
- Usage limits
-
Each API call:
- Checks active subscription
- Validates entitlement
- Updates usage meter atomically
- ACID Transactions (
transaction.atomic()) - Row-level locking to prevent race conditions
- Clean separation of concerns
- RESTful API design
git clone <repo-url>
cd subscriptionEnginepython -m venv venv
source venv/bin/activate # Windows: venv\\Scripts\\activatepip install -r requirements.txtUpdate settings.py:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'subscription_db',
'USER': 'postgres',
'PASSWORD': 'password',
'HOST': 'localhost',
'PORT': '5432',
}
}python manage.py makemigrations
python manage.py migrate
python manage.py runserverGet active subscription details
GET /api/subscriptions/me/
Response:
{
"plan": "Pro",
"limits": {
"api_calls": 1000
},
"usage": {
"api_calls": 120
}
}- Payment gateway integration (Stripe / Razorpay)
- Webhook-based subscription updates
- Admin analytics dashboard
- Rate limiting middleware
- Flutter / React frontend integration
Aryan Singh Backend Developer | Django | REST APIs
⭐ If you found this project useful, give it a star!