A REST API for managing personal subscriptions with automated renewal tracking and email notifications.
- User authentication with JWT
- Subscription CRUD operations
- Spending analytics and insights
- Email notifications for renewals
- Automated status updates via cron jobs
- Rate limiting and security middleware
- Node.js + Express.js
- MongoDB + Mongoose
- JWT authentication
- Nodemailer for emails
- Node-cron for scheduling
- Clone and install dependencies:
git clone https://github.com/Sumant3086/Subscription-tracker.git
cd Subscription-tracker
npm install- Configure environment variables:
cp .env.example .env.development.localEdit .env.development.local:
PORT=5500
NODE_ENV=development
DB_URI=mongodb+srv://username:password@cluster.mongodb.net/database
JWT_SECRET=your_jwt_secret
EMAIL_USER=your_email@gmail.com
EMAIL_PASS=your_app_password
EMAIL_FROM=your_email@gmail.com- Start the server:
npm run devPOST /api/v1/auth/sign-up- Register userPOST /api/v1/auth/sign-in- Login user
GET /api/v1/subscriptions- List subscriptions with analyticsPOST /api/v1/subscriptions- Create subscriptionPUT /api/v1/subscriptions/:id- Update subscriptionDELETE /api/v1/subscriptions/:id- Delete subscriptionPATCH /api/v1/subscriptions/:id/cancel- Cancel subscriptionGET /api/v1/subscriptions/analytics- Get spending analyticsGET /api/v1/subscriptions/upcoming-renewals- Get upcoming renewals
GET /api/v1/users/profile- Get user profilePUT /api/v1/users/profile- Update profile
- Register a new user:
POST /api/v1/auth/sign-up
{
"name": "John Doe",
"email": "john@example.com",
"password": "password123"
}- Login to get JWT token:
POST /api/v1/auth/sign-in
{
"email": "john@example.com",
"password": "password123"
}- Add subscriptions (use token in Authorization header):
POST /api/v1/subscriptions
Authorization: Bearer <jwt_token>
{
"name": "Netflix",
"price": 15.99,
"currency": "USD",
"frequency": "monthly",
"category": "entertainment",
"payment": "Credit Card",
"startDate": "2024-01-01"
}- View analytics and manage subscriptions:
GET /api/v1/subscriptions/analytics
GET /api/v1/subscriptions/upcoming-renewalsRun the test suite:
node test-api.js├── controllers/ # Request handlers
├── models/ # Database schemas
├── routes/ # API routes
├── middlewares/ # Custom middleware
├── services/ # Business logic (email, cron)
├── config/ # Configuration
├── database/ # DB connection
└── app.js # Express app
MIT