- Introduction
- Tech Stack
- Features
- Project Architecture
- Quick Start
- Example Request Payload
- API Overview
- Environment Variables
- Development Notes
This project is a Subscription Management System API designed to simulate real-world backend workflows involving authentication, billing logic, and automated reminders.
It demonstrates how to:
- Secure APIs with authentication middleware
- Model real business data with MongoDB
- Automate workflows using background job scheduling
- Send transactional email reminders
- Build scalable backend architecture
The system is structured to resemble production-grade APIs used in SaaS platforms.
- Node.js — backend runtime
- Express.js — API framework
- MongoDB + Mongoose — database modeling
- JWT — authentication & authorization
- Arcjet — rate limiting & bot protection
- Upstash Workflow/QStash — background scheduling
- Nodemailer — transactional email delivery
- Day.js — date/time handling
👉 Secure authentication using JWT
👉 Subscription CRUD management
👉 Automated reminder scheduling
👉 Background workflow orchestration
👉 Email notification system
👉 Database modeling with relationships
👉 Global error handling middleware
👉 Rate limiting & bot protection
👉 Clean modular architecture
👉 Production-style API structure
controllers/
routes/
models/
middleware/
utils/
config/
database/
workflows/
The architecture separates:
- Business logic
- API routing
- database modeling
- background workflow processing
- email utilities
This ensures maintainability and scalability.
Make sure you have installed:
- Git
- Node.js (v18+)
- npm
- MongoDB (local or cloud)
git clone <your-repository-url>
cd subscription-trackernpm installCreate:
.env.development.local
Add:
# Server
PORT=5500
SERVER_URL=http://localhost:5500
# Environment
NODE_ENV=development
# Database
DB_URI=
# JWT
JWT_SECRET=
JWT_EXPIRES_IN=1d
# Arcjet
ARCJET_KEY=
ARCJET_ENV=development
# Upstash Workflow
QSTASH_URL=http://127.0.0.1:8080
QSTASH_TOKEN=
# Email
EMAIL_PASSWORD=npx @upstash/qstash-cli devKeep this terminal running.
npm run devServer runs at:
http://localhost:5500
{
"name": "Streaming Subscription",
"price": 19.99,
"currency": "USD",
"frequency": "monthly",
"category": "Entertainment",
"startDate": "2026-01-10T00:00:00.000Z",
"paymentMethod": "Card"
}POST /api/v1/auth/register
POST /api/v1/auth/login
GET /api/v1/users/:id
POST /api/v1/subscriptions
GET /api/v1/subscriptions/:userId
POST /api/v1/workflows/subscription/remainder
Schedules automated renewal reminder emails.
Sensitive values should never be committed.
Required:
- Database connection string
- JWT secrets
- Email credentials
- Workflow tokens
- Keep QStash dev server running for workflows
- Reminder workflows execute asynchronously
- Email sending requires valid SMTP credentials
- MongoDB connection must be active
Recommended tools:
- Postman / Insomnia for testing
- MongoDB Compass for inspection
- Payment integration
- Subscription analytics
- Admin dashboard
- Notification channels (SMS/Webhooks)
- Frontend client
MIT — free to use and extend.