A production-ready Node.js + Express API for managing subscriptions with JWT authentication, automated email reminders, and a modular, scalable folder structure. Perfect for learning backend patterns or building real-world applications.
- ✅ JWT-based authentication and session management
- 📅 Full subscription CRUD operations
- 📧 Automated email reminders with Upstash Workflows
- 🔒 Advanced rate-limiting and bot protection via Arcjet
- 🧠 MongoDB & Mongoose schema modeling with validation
- ⚙️ Global error handling, input validation, and logging
- 🧰 Modular and scalable folder structure
- ⚡ Ready for production deployment and future extension
- Node.js + Express.js (ES modules)
- MongoDB + Mongoose
- JWT for authentication
- Nodemailer for email handling
- Arcjet for rate limiting and protection
- Upstash Workflows for automation
- dotenv, bcryptjs, cookie-parser, and more
- Development:
nodemonfor live reload
.
├── app.js # Entry point
├── config/ # Environment, Nodemailer, Arcjet, Upstash setup
├── controllers/ # Business logic for routes
├── database/ # MongoDB connection logic
├── middlewares/ # Auth, validation, error handling
├── models/ # User & Subscription schemas
├── routes/ # Express route definitions
├── utils/ # Helpers, email templates
├── tests/ # (Not implemented; only test-user-info.json exists)
├── package.json # Dependencies and metadata
└── jsconfig.json # Path aliases
# Clone the repository
git clone https://github.com/nuwandev/subscription-tracker.git
cd subscription-tracker
# Install dependencies
npm install
# Configure environment variables
cp env.example .env
# Edit .env locally with your credentials (never commit real secrets)
# Run development server
npm run devPOST /sign-up— Register a new userPOST /sign-in— Authenticate user and return JWT
POST /— Create user (WIP)PUT /:id— Update user (WIP)DELETE /:id— Delete user (WIP)
POST /— Create subscription (protected)GET /— List subscriptions (protected, WIP)GET /:id— Get subscription by ID (protected, WIP)PUT /:id— Update subscription (protected)DELETE /:id— Delete subscription (protected)PUT /:id/cancel— Cancel subscription (protected, WIP)GET /upcoming-renewals— Fetch upcoming renewals (WIP)
- Automate email reminders via Upstash
- Register → user created
- Login → JWT returned
- Include
Authorization: Bearer <token>header for protected endpoints
Because of rate-limiting and bot protection (Arcjet), we recommend testing with Postman or Insomnia instead of raw curl.
Below are sample request bodies you can use:
POST /api/v1/auth/sign-up
{
"name": "Demo",
"email": "demo@example.com",
"password": "Pass123!"
}POST /api/v1/auth/sign-in
{
"email": "demo@example.com",
"password": "Pass123!"
}POST /api/v1/subscriptions (requires Authorization: Bearer <JWT_TOKEN>)
{
"name": "Netflix",
"price": 9.99,
"currency": "USD",
"frequency": "monthly",
"category": "lifestyle",
"paymentMethod": "Credit Card",
"status": "active",
"startDate": "2025-08-01T00:00:00.000Z",
"renewalDate": "2025-09-01T00:00:00.000Z",
"user": "<USER_ID>"
}Built and maintained by @nuwandev. Inspired by JavaScript Mastery.