A production-ready RESTful API built with Node.js, Express, and MongoDB to help users track their subscriptions, manage costs, and receive automated email reminders for upcoming renewals.
This project integrates advanced features like Upstash Workflows for background jobs (email reminders) and Arcjet for security and rate limiting.
-
🔐 Authentication & Authorization:
- Secure Sign Up, Sign In, and Sign Out using JWT (JSON Web Tokens).
- Password hashing with
bcryptjs.
-
👤 User Management:
- Create, Read, Update, and Delete (CRUD) operations for user profiles.
-
EZ Subscription Management:
- Track subscription details (name, price, currency, frequency, category).
- Automatic renewal date calculation.
- Status tracking (Active, Cancelled, Expired).
-
📧 Automated Email Reminders:
- Smart email notifications sent 7, 5, 2, and 1 day(s) before subscription renewal.
- Powered by Upstash Workflow and Nodemailer.
-
🛡️ Security & Performance:
- Rate Limiting & Bot Protection using Arcjet.
- Global Error Handling middleware.
- Data validation using Mongoose.
- Runtime: Node.js
- Framework: Express.js
- Database: MongoDB (via Mongoose ODM)
- Authentication: JWT & Bcrypt
- Background Jobs: Upstash Workflow
- Security: Arcjet
- Email Service: Nodemailer
├── config/ # Configuration files (Env, Database, Arcjet, Upstash)
├── controllers/ # Request handlers (Auth, User, Subscription, Workflow)
├── database/ # Database connection logic
├── middlewares/ # Custom middlewares (Auth, Error Handling, Arcjet)
├── models/ # Mongoose schemas/models
├── routes/ # API Route definitions
├── utils/ # Utility functions (Email templates, Send email)
├── app.js # Entry point of the application
└── package.json # Project dependencies and scripts
Ensure you have the following installed/setup:
- Node.js (v18+)
- MongoDB (Local or Atlas)
- Upstash Account (For QStash/Workflows)
- Arcjet Account (For security)
git clone https://github.com/vasanthrs-dev/subscription-tracker.git
cd subscription-tracker
npm install
Create a .env.development.local (or .env.production.local) file in the root directory and populate it with the following:
# Server Configuration
PORT=3000
SERVER_URL="http://localhost:3000"
NODE_ENV="development"
# Database
DB_URI="your_mongodb_connection_string"
# Authentication
JWT_SECRET="your_super_secret_jwt_key"
JWT_EXPIRES_IN="1d"
# Arcjet Security
ARCJET_KEY="your_arcjet_key"
ARCJET_ENV="development"
# Upstash (Workflow & QStash)
QSTASH_URL="http://127.0.0.1:8080" # Or your production QStash URL
QSTASH_TOKEN="your_qstash_token"
QSTASH_CURRENT_SIGNING_KEY="your_current_signing_key"
QSTASH_NEXT_SIGNING_KEY="your_next_signing_key"
# Email Service (Nodemailer)
EMAIL_PASSWORD="your_email_app_password"
Development Mode (with Nodemon):
npm run dev
Production Mode:
npm start
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/v1/auth/sign-up |
Register a new user |
POST |
/api/v1/auth/sign-in |
Login and receive JWT |
POST |
/api/v1/auth/sign-out |
Sign out user |
| Method | Endpoint | Description |
|---|---|---|
GET |
/api/v1/users |
Get all users (Admin) |
GET |
/api/v1/users/:id |
Get user details |
PUT |
/api/v1/users/:id |
Update user profile |
DELETE |
/api/v1/users/:id |
Delete user account |
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/v1/subscriptions |
Create a new subscription |
GET |
/api/v1/subscriptions |
Get all subscriptions (Admin) |
GET |
/api/v1/subscriptions/:id |
Get specific subscription details |
PUT |
/api/v1/subscriptions/:id |
Update subscription details |
DELETE |
/api/v1/subscriptions/:id |
Delete a subscription |
GET |
/api/v1/subscriptions/user/:id |
Get all subscriptions for a specific user |
PUT |
/api/v1/subscriptions/:id/cancel |
Cancel a subscription |
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/v1/workflows/subscription/reminder |
Trigger subscription reminder workflow |
This project uses Upstash Workflow to handle reminders. When a subscription is created:
- The
createSubscriptioncontroller triggers the workflow endpoint. - The workflow checks if the renewal date is approaching.
- It schedules reminders for 7, 5, 2, and 1 day(s) before renewal.
- Emails are sent automatically via Nodemailer.
To test locally, you may need to use ngrok to expose your local server to Upstash, or use the local QStash development server.
Contributions are welcome!
- Fork the project.
- Create your feature branch (
git checkout -b feature/AmazingFeature). - Commit your changes (
git commit -m 'Add some AmazingFeature'). - Push to the branch (
git push origin feature/AmazingFeature). - Open a Pull Request.
This project is licensed under the MIT License.