{"id":30764685,"url":"https://github.com/paulwritescode/subscription-tracker-api","last_synced_at":"2025-10-12T13:06:51.708Z","repository":{"id":309113450,"uuid":"1035205856","full_name":"paulwritescode/subscription-tracker-api","owner":"paulwritescode","description":"A powerful, production-ready RESTful API for tracking and managing personal subscriptions with advanced security, automated workflows, and intelligent email reminders.","archived":false,"fork":false,"pushed_at":"2025-08-10T22:11:31.000Z","size":84,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-04T17:17:51.459Z","etag":null,"topics":["arcjet","controllers","expressjs","javascript","jwt","middleware","mongodb","mongoose","nodemailer","nodemon","upstash","workflow-api"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/paulwritescode.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-08-09T22:05:44.000Z","updated_at":"2025-08-10T22:16:17.000Z","dependencies_parsed_at":"2025-08-10T00:11:06.781Z","dependency_job_id":null,"html_url":"https://github.com/paulwritescode/subscription-tracker-api","commit_stats":null,"previous_names":["paulwritescode/subscription-tracker-api"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/paulwritescode/subscription-tracker-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paulwritescode%2Fsubscription-tracker-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paulwritescode%2Fsubscription-tracker-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paulwritescode%2Fsubscription-tracker-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paulwritescode%2Fsubscription-tracker-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/paulwritescode","download_url":"https://codeload.github.com/paulwritescode/subscription-tracker-api/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paulwritescode%2Fsubscription-tracker-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279011468,"owners_count":26084947,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-12T02:00:06.719Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arcjet","controllers","expressjs","javascript","jwt","middleware","mongodb","mongoose","nodemailer","nodemon","upstash","workflow-api"],"created_at":"2025-09-04T17:12:19.842Z","updated_at":"2025-10-12T13:06:51.689Z","avatar_url":"https://github.com/paulwritescode.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003cbr /\u003e\n  \u003cdiv\u003e\n    \u003cimg src=\"https://img.shields.io/badge/node.js-339933?style=for-the-badge\u0026logo=Node.js\u0026logoColor=white\" alt=\"node.js\" /\u003e\n    \u003cimg src=\"https://img.shields.io/badge/express.js-000000?style=for-the-badge\u0026logo=express\u0026logoColor=white\" alt=\"express.js\" /\u003e\n    \u003cimg src=\"https://img.shields.io/badge/-MongoDB-13aa52?style=for-the-badge\u0026logo=mongodb\u0026logoColor=white\" alt=\"mongodb\" /\u003e\n    \u003cimg src=\"https://img.shields.io/badge/JWT-000000?style=for-the-badge\u0026logo=JSON%20web%20tokens\u0026logoColor=white\" alt=\"jwt\" /\u003e\n    \u003cimg src=\"https://img.shields.io/badge/Arcjet-FF6B6B?style=for-the-badge\u0026logo=shield\u0026logoColor=white\" alt=\"arcjet\" /\u003e\n    \u003cimg src=\"https://img.shields.io/badge/Upstash-00D9FF?style=for-the-badge\u0026logo=upstash\u0026logoColor=white\" alt=\"upstash\" /\u003e\n  \u003c/div\u003e\n\n  \u003ch3 align=\"center\"\u003eSubscription Tracker API (SubDub)\u003c/h3\u003e\n\n   \u003cdiv align=\"center\"\u003e\n     A powerful, production-ready RESTful API for tracking and managing personal subscriptions with advanced security, automated workflows, and intelligent email reminders.\n    \u003c/div\u003e\n\u003c/div\u003e\n\n## 📋 \u003ca name=\"table\"\u003eTable of Contents\u003c/a\u003e\n\n1. 🤖 [Introduction](#introduction)\n2. ⚙️ [Tech Stack](#tech-stack)\n3. 🔋 [Features](#features)\n4. 🛠️ [System Architecture](#architecture)\n5. 🌐 [API Routes](#api-routes)\n6. 🤸 [Quick Start](#quick-start)\n7. 🕸️ [Code Snippets](#snippets)\n8. 🔗 [Links](#links)\n9. 🚀 [More](#more)\n\n## \u003ca name=\"introduction\"\u003e🤖 Introduction\u003c/a\u003e\n\nBuild a **production-ready Subscription Management API** that handles **real users, real subscriptions, and real business logic**.  \n\nThis comprehensive API provides secure user authentication using JWTs, robust database management with MongoDB, advanced rate limiting and bot protection with Arcjet, and automated email workflows using Upstash. The architecture ensures scalability and seamless communication with any frontend application.\n\nPerfect for developers looking to build a complete subscription tracking system or integrate subscription management into existing applications.\n\n## \u003ca name=\"tech-stack\"\u003e⚙️ Tech Stack\u003c/a\u003e\n\n**Backend Framework \u0026 Runtime**\n- Node.js (ES Modules)\n- Express.js 4.21.2\n\n**Database \u0026 ODM**\n- MongoDB 6.18.0\n- Mongoose ODM 8.17.1\n\n**Authentication \u0026 Security**\n- JSON Web Tokens (jsonwebtoken 9.0.2)\n- bcryptjs 3.0.2 for password hashing\n- Arcjet 1.0.0-beta.10 for advanced security \u0026 bot protection\n\n**Email \u0026 Workflow Automation**\n- Upstash Workflow 0.2.17 for automated email reminders\n- Nodemailer 7.0.5 for email functionality\n- DayJS 1.11.13 for date/time management\n\n**Development \u0026 Monitoring**\n- Morgan 1.10.1 for HTTP request logging\n- ESLint 9.32.0 with modern ES2022 support\n- Nodemon 3.1.10 for development\n\n**Additional Tools**\n- Cookie Parser 1.4.4\n- dotenv 17.2.1 for environment management\n\n## \u003ca name=\"features\"\u003e🔋 Features\u003c/a\u003e\n\n👉 **Advanced Security \u0026 Bot Protection**: Arcjet integration provides comprehensive protection against bots, DDoS attacks, and malicious requests with intelligent rate limiting.\n\n👉 **JWT Authentication System**: Secure user registration, login, and logout with token-based authentication and cookie management.\n\n👉 **Comprehensive Subscription Management**: Full CRUD operations for subscriptions with user-specific data, renewal tracking, and cancellation support.\n\n👉 **Automated Email Workflows**: Smart email reminder system using Upstash Workflows that automatically sends subscription renewal notifications.\n\n👉 **User Profile Management**: Complete user account management with secure data handling and profile operations.\n\n👉 **Database Modeling**: Robust MongoDB schemas and relationships using Mongoose ODM with proper validation and indexing.\n\n👉 **Global Error Handling**: Centralized error management with custom middleware for consistent API responses.\n\n👉 **Request Logging \u0026 Monitoring**: Comprehensive logging system using Morgan for better debugging and API monitoring.\n\n👉 **Environment-based Configuration**: Secure environment variable management for different deployment stages.\n\n👉 **Modern ES6+ Architecture**: Built with ES modules, async/await, and modern JavaScript best practices.\n\nand many more, including scalable code architecture and high reusability\n\n## \u003ca name=\"architecture\"\u003e🛠️ System Architecture\u003c/a\u003e\n\n```\n┌─────────────────┐    ┌──────────────────┐    ┌─────────────────┐\n│   Client Apps   │    │   Arcjet Shield  │    │   Email Service │\n│                 │    │                  │    │                 │\n│ • Web Frontend  │    │ • Rate Limiting  │    │ • Nodemailer    │\n│ • Mobile Apps   │◄──►│ • Bot Protection │◄──►│ • SMTP Config   │\n│ • Third Party   │    │ • DDoS Guard     │    │ • Templates     │\n└─────────────────┘    └──────────────────┘    └─────────────────┘\n         │                        │                        │\n         ▼                        ▼                        ▼\n┌─────────────────────────────────────────────────────────────────┐\n│                    Express.js API Server                        │\n│                                                                 │\n│  ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌────────────┐│\n│  │    Auth     │ │Subscription │ │    User     │ │ Workflow   ││\n│  │   Routes    │ │   Routes    │ │   Routes    │ │   Routes   ││\n│  └─────────────┘ └─────────────┘ └─────────────┘ └────────────┘│\n│                                                                 │\n│  ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌────────────┐│\n│  │    Auth     │ │Subscription │ │    User     │ │ Workflow   ││\n│  │Controllers  │ │Controllers  │ │Controllers  │ │Controllers ││\n│  └─────────────┘ └─────────────┘ └─────────────┘ └────────────┘│\n│                                                                 │\n│         ┌──────────────────────────────────────────┐           │\n│         │              Middleware Stack            │           │\n│         │ • JWT Authorization                      │           │\n│         │ • Arcjet Security                        │           │\n│         │ • Error Handling                         │           │\n│         │ • Request Logging                        │           │\n│         └──────────────────────────────────────────┘           │\n└─────────────────────────────────────────────────────────────────┘\n                                 │\n                                 ▼\n         ┌─────────────────────────────────────────────┐\n         │              MongoDB Database                │\n         │                                             │\n         │  ┌─────────────┐ ┌─────────────────────────┐│\n         │  │    Users    │ │      Subscriptions      ││\n         │  │ Collection  │ │       Collection        ││\n         │  └─────────────┘ └─────────────────────────┘│\n         └─────────────────────────────────────────────┘\n                                 │\n                                 ▼\n              ┌─────────────────────────────────┐\n              │      Upstash Workflows          │\n              │                                 │\n              │ • Scheduled Email Reminders     │\n              │ • Subscription Renewal Alerts   │\n              │ • Automated Notifications       │\n              └─────────────────────────────────┘\n```\n\n## \u003ca name=\"api-routes\"\u003e🌐 API Routes\u003c/a\u003e\n\n### Authentication Routes (`/api/v1/auth`)\n| Method | Endpoint | Description | Auth Required |\n|--------|----------|-------------|---------------|\n| `POST` | `/signup` | Register a new user account | ❌ |\n| `POST` | `/signin` | Login user and get JWT token | ❌ |\n| `POST` | `/signout` | Logout user and clear tokens | ❌ |\n\n### Subscription Routes (`/api/v1/subscriptions`)\n| Method | Endpoint | Description | Auth Required |\n|--------|----------|-------------|---------------|\n| `GET` | `/` | Get all subscriptions | ❌ |\n| `GET` | `/:id` | Get specific subscription details | ❌ |\n| `POST` | `/` | Create a new subscription | ✅ |\n| `PUT` | `/:id` | Update existing subscription | ❌ |\n| `DELETE` | `/:id` | Delete a subscription | ❌ |\n| `GET` | `/user/:id` | Get user's subscriptions | ✅ |\n| `GET` | `/:id/cancel` | Cancel a subscription | ❌ |\n| `GET` | `/upcoming-renewals` | Get upcoming renewal dates | ❌ |\n\n### User Routes (`/api/v1/users`)\n| Method | Endpoint | Description | Auth Required |\n|--------|----------|-------------|---------------|\n| `GET` | `/` | Get all users | ❌ |\n| `GET` | `/:id` | Get specific user profile | ✅ |\n| `POST` | `/` | Create a new user | ❌ |\n| `PUT` | `/:id` | Update user information | ❌ |\n| `DELETE` | `/:id` | Delete user account | ❌ |\n\n### Workflow Routes (`/api/v1/workflows`)\n| Method | Endpoint | Description | Auth Required |\n|--------|----------|-------------|---------------|\n| `POST` | `/subscription/reminder` | Send subscription reminders | ❌ |\n\n## \u003ca name=\"quick-start\"\u003e🤸 Quick Start\u003c/a\u003e\n\nFollow these steps to set up the project locally on your machine.\n\n**Prerequisites**\n\nMake sure you have the following installed on your machine:\n\n- [Git](https://git-scm.com/)\n- [Node.js](https://nodejs.org/en) (v16 or higher)\n- [npm](https://www.npmjs.com/) (Node Package Manager)\n- [MongoDB](https://www.mongodb.com/) (Local installation or MongoDB Atlas)\n\n**Cloning the Repository**\n\n```bash\ngit clone https://github.com/your-username/subscription-tracker-api.git\ncd subscription-tracker-api\n```\n\n**Installation**\n\nInstall the project dependencies using npm:\n\n```bash\nnpm install\n```\n\n**Set Up Environment Variables**\n\nCreate a new file named `.env.development.local` in the root of your project and add the following content:\n\n```env\n# PORT CONFIGURATION\nPORT=5500\nSERVER_URL=\"http://localhost:5500\"\n\n# ENVIRONMENT\nNODE_ENV=development\n\n# DATABASE CONFIGURATION\nDB_URI=mongodb://localhost:27017/subscription-tracker\n# Or use MongoDB Atlas: mongodb+srv://username:password@cluster.mongodb.net/subscription-tracker\n\n# JWT AUTHENTICATION\nJWT_SECRET=your-super-secret-jwt-key-here\nJWT_EXPIRES_IN=\"7d\"\n\n# ARCJET SECURITY (Get your key from https://app.arcjet.com)\nARCJET_KEY=your-arcjet-key-here\nARCJET_ENV=\"development\"\n\n# UPSTASH WORKFLOW (Get from https://console.upstash.com)\nQSTASH_URL=https://qstash.upstash.io\nQSTASH_TOKEN=your-qstash-token-here\n\n# EMAIL CONFIGURATION (For Gmail, use App Password)\nEMAIL_PASSWORD=your-email-app-password-here\nEMAIL_USER=your-email@gmail.com\n```\n\n**Running the Project**\n\nFor development with auto-reload:\n```bash\nnpm run dev\n```\n\nFor production:\n```bash\nnpm start\n```\n\nOpen [http://localhost:5500](http://localhost:5500) in your browser or use an HTTP client like Postman to test the API endpoints.\n\n**Testing the API**\n\nTest the welcome endpoint:\n```bash\ncurl http://localhost:5500\n```\n\nYou should see: `\"Welcome to the subscription Tracker API!\"`\n\n## \u003ca name=\"snippets\"\u003e🕸️ Code Snippets\u003c/a\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ccode\u003eCreate Subscription Request\u003c/code\u003e\u003c/summary\u003e\n\n```bash\ncurl -X POST http://localhost:5500/api/v1/subscriptions \\\n  -H \"Content-Type: application/json\" \\\n  -H \"Authorization: Bearer YOUR_JWT_TOKEN\" \\\n  -d '{\n    \"name\": \"Netflix Premium\",\n    \"price\": 15.99,\n    \"currency\": \"USD\",\n    \"frequency\": \"monthly\",\n    \"category\": \"Entertainment\",\n    \"startDate\": \"2025-01-01T00:00:00.000Z\",\n    \"paymentMethod\": \"Credit Card\",\n    \"description\": \"Streaming service subscription\"\n  }'\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ccode\u003eUser Registration Request\u003c/code\u003e\u003c/summary\u003e\n\n```bash\ncurl -X POST http://localhost:5500/api/v1/auth/signup \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"name\": \"John Doe\",\n    \"email\": \"john.doe@example.com\",\n    \"password\": \"securePassword123\",\n    \"confirmPassword\": \"securePassword123\"\n  }'\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ccode\u003eLogin Request\u003c/code\u003e\u003c/summary\u003e\n\n```bash\ncurl -X POST http://localhost:5500/api/v1/auth/signin \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"email\": \"john.doe@example.com\",\n    \"password\": \"securePassword123\"\n  }'\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ccode\u003eSend Email Reminder\u003c/code\u003e\u003c/summary\u003e\n\n```bash\ncurl -X POST http://localhost:5500/api/v1/workflows/subscription/reminder \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"userId\": \"user123\",\n    \"subscriptionId\": \"sub456\",\n    \"reminderType\": \"renewal\",\n    \"daysUntilRenewal\": 3\n  }'\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ccode\u003eSubscription Object Schema\u003c/code\u003e\u003c/summary\u003e\n\n```json\n{\n  \"_id\": \"64a1b2c3d4e5f6789abcdef0\",\n  \"name\": \"Spotify Premium\",\n  \"price\": 9.99,\n  \"currency\": \"USD\",\n  \"frequency\": \"monthly\",\n  \"category\": \"Music\",\n  \"startDate\": \"2025-01-01T00:00:00.000Z\",\n  \"nextPayment\": \"2025-02-01T00:00:00.000Z\",\n  \"paymentMethod\": \"Credit Card\",\n  \"status\": \"active\",\n  \"userId\": \"64a1b2c3d4e5f6789abcdef1\",\n  \"description\": \"Music streaming service\",\n  \"createdAt\": \"2025-01-01T12:00:00.000Z\",\n  \"updatedAt\": \"2025-01-01T12:00:00.000Z\"\n}\n```\n\n\u003c/details\u003e\n\n## \u003ca name=\"links\"\u003e🔗 Links\u003c/a\u003e\n\n- **Arcjet Security** - [https://arcjet.com](https://arcjet.com) - Advanced API security and bot protection\n- **Upstash Workflows** - [https://upstash.com](https://upstash.com) - Serverless workflow automation  \n- **MongoDB Atlas** - [https://www.mongodb.com/atlas](https://www.mongodb.com/atlas) - Cloud database service\n- **Node.js** - [https://nodejs.org](https://nodejs.org) - JavaScript runtime\n- **Express.js** - [https://expressjs.com](https://expressjs.com) - Web framework for Node.js\n\n## \u003ca name=\"more\"\u003e🚀 More\u003c/a\u003e\n\n**Production Deployment Tips**\n\n- Use environment-specific configuration files (`.env.production.local`)\n- Set up proper MongoDB Atlas clusters for production\n- Configure Arcjet with production keys and appropriate rate limits\n- Set up Upstash workflows for production email delivery\n- Use process managers like PM2 for production deployments\n- Implement proper logging with services like Winston or Pino\n- Set up monitoring with tools like New Relic or DataDog\n\n**Development Best Practices**\n\n- Follow RESTful API design principles\n- Implement proper error handling and validation\n- Use TypeScript for better type safety (future enhancement)\n- Write comprehensive unit and integration tests\n- Document API endpoints with tools like Swagger/OpenAPI\n- Implement API versioning for backward compatibility\n- Use database transactions for critical operations\n- Set up automated CI/CD pipelines\n\n**Security Considerations**\n\n- Regularly update dependencies for security patches\n- Implement input validation and sanitization\n- Use HTTPS in production environments\n- Configure proper CORS policies\n- Implement request rate limiting per user/IP\n- Use secure HTTP headers with libraries like helmet\n- Regular security audits with tools like npm audit\n- Implement proper logging for security events\n\n---\n\n\u003cdiv align=\"center\"\u003e\n  \u003cp\u003eBuilt with ❤️ using modern Node.js, Express.js, and MongoDB\u003c/p\u003e\n  \u003cp\u003eReady for production deployment and scalable architecture\u003c/p\u003e\n\u003c/div\u003e","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaulwritescode%2Fsubscription-tracker-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpaulwritescode%2Fsubscription-tracker-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaulwritescode%2Fsubscription-tracker-api/lists"}