{"id":26972627,"url":"https://github.com/obomhese-raphael/subscription-tracker-backend","last_synced_at":"2025-04-03T09:18:18.429Z","repository":{"id":278554876,"uuid":"935998087","full_name":"Obomhese-Raphael/Subscription-Tracker-Backend","owner":"Obomhese-Raphael","description":null,"archived":false,"fork":false,"pushed_at":"2025-02-20T11:35:41.000Z","size":42,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-20T12:30:08.868Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://subscription-tracker-backend.vercel.app","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Obomhese-Raphael.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2025-02-20T11:13:15.000Z","updated_at":"2025-02-20T11:36:44.000Z","dependencies_parsed_at":"2025-02-20T12:41:35.251Z","dependency_job_id":null,"html_url":"https://github.com/Obomhese-Raphael/Subscription-Tracker-Backend","commit_stats":null,"previous_names":["obomhese-raphael/subscription-tracker-backend"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Obomhese-Raphael%2FSubscription-Tracker-Backend","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Obomhese-Raphael%2FSubscription-Tracker-Backend/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Obomhese-Raphael%2FSubscription-Tracker-Backend/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Obomhese-Raphael%2FSubscription-Tracker-Backend/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Obomhese-Raphael","download_url":"https://codeload.github.com/Obomhese-Raphael/Subscription-Tracker-Backend/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246970318,"owners_count":20862509,"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","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":[],"created_at":"2025-04-03T09:18:17.840Z","updated_at":"2025-04-03T09:18:18.409Z","avatar_url":"https://github.com/Obomhese-Raphael.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Subscription Management System 🚀\n\nWelcome to the **Subscription Management System**, a production-ready backend project designed to handle real users, real money, and real business logic. This project is part of a **Backend Crash Course** by [JavaScript Mastery](https://www.jsmastery.pro), where we build a robust system for managing subscriptions, sending reminders, and lots more.\nThis project is built using modern tools and technologies like **Upstash**, **Hstinger/Vercel**, **Arcjet**, and **WebStorm**, and incorporates best practices for **JWT authentication**, **database modeling**, **API architecture**, **security**, and **automated workflows**.\n\n---\n\n## Features ✨\n\n- **User Authentication**: Secure JWT-based authentication for user registration, login, and session management.\n- **Subscription Management**: Create, update, and manage subscriptions with real-time tracking.\n- **Automated Reminders**: Send email reminders to users before their subscription renews.\n- **Database Modeling**: Efficient and scalable database design using MongoDB.\n- **API Architecture**: RESTful API with clean, modular, and maintainable code.\n- **Security**: Implement best practices for securing user data and preventing common vulnerabilities.\n- **Automated Workflows**: Use **Upstash Workflows** to automate tasks like sending reminders and updating subscriptions.\n- **Deployment**: Deploy the backend on **Hstinger/Vercel** with **Arcjet** for enhanced security.\n\n---\n\n## Tools and Technologies 🛠️\n\n- **Backend Framework**: Node.js with Express\n- **Database**: MongoDB (with Mongoose for modeling)\n- **Authentication**: JSON Web Tokens (JWT)\n- **Workflow Automation**: Upstash Workflows\n- **Email Service**: Nodemailer\n- **Security**: Arcjet for API security\n- **Deployment**: Hstinger / Vercel\n- **IDE**: WebStorm / VsCode\n- **Version Control**: Git and GitHub\n\n---\n\n## Project Structure 📂\n\n```\nsubscription-management-system/\n├── config/                  # Configuration files (database, JWT, etc.)\n├── controllers/             # Route handlers for API endpoints\n├── database/                # Used to handle mongodb database (DB_URI)\n├── middlewares/             # handles authentication, authorization and error handlings\n├── models/                  # Database models (Mongoose schemas)\n├── routes/                  # API routes\n├── utils/                   # Utility functions (send-email, workflows, email-templates etc.)\n├── workflows/               # Upstash workflow definitions\n├── .env                     # Environment variables\n├── .gitignore               # Files to ignore in Git\n├── app.js                   # Main application file\n├── package.json             # Project dependencies\n└── README.md                # Project documentation\n```\n\n---\n\n## Key Concepts Explained 🧠\n\n### 1. **JWT Authentication**\n- JSON Web Tokens (JWT) are used for secure user authentication.\n- Tokens are generated upon login and verified on every protected route.\n- Tokens include user information (e.g., user ID) and expire after a set time.\n\n### 2. **Database Modeling**\n- MongoDB is used as the database, with Mongoose for schema modeling.\n- Key models include:\n  - **User**: Stores user details (name, email, password hash).\n  - **Subscription**: Tracks subscription details (name, price, renewal date, etc.).\n- Relationships are defined between models (e.g., a user can have multiple subscriptions).\n\n### 3. **API Architecture**\n- RESTful API design with clear separation of concerns.\n- Routes are organized into:\n  - **Auth Routes**: User registration, login, and token refresh.\n  - **Subscription Routes**: CRUD operations for subscriptions.\n  - **Workflow Routes**: Trigger automated workflows (e.g., reminders).\n\n### 4. **Security**\n- Passwords are hashed using **bcrypt** before storing in the database.\n- Sensitive data (e.g., API keys) is stored in environment variables.\n- **Arcjet** is used to protect APIs from common attacks (e.g., DDoS, SQL injection).\n\n### 5. **Automated Workflows**\n- **Upstash Workflows** are used to automate tasks like:\n  - Sending email reminders before subscription renewal.\n  - Updating subscription status after payment.\n- Workflows are triggered by API calls or scheduled events.\n\n### 6. **Email Notifications**\n- **Nodemailer** is used to send transactional emails.\n- Email templates are dynamically generated for different reminder types (e.g., 7 days before renewal).\n\n---\n\n## Installation and Setup 🛠️\n\n### Prerequisites\n- Node.js (v18 or higher)\n- MongoDB (local or cloud instance)\n- Upstash account (for workflows)\n- Arcjet account (for API security)\n\n### Steps\n1. Clone the repository:\n   ```bash\n   git clone https://github.com/Obomhese-Raphael/Subscription-Tracker-Backend.git\n   cd subscription-tracker\n   ```\n\n2. Install dependencies:\n   ```bash\n   npm install\n   ```\n\n3. Set up environment variables:\n   - Create a `.env` file in the root directory.\n   - Add the following variables:\n     ```\n     JWT_SECRET=your_jwt_secret_key\n     UPSTASH_TOKEN=your_upstash_token\n     ARCJET_KEY=your_arcjet_api_key\n     EMAIL_USER=your_email_address\n     EMAIL_PASSWORD=your_email_password,\n     PORT,\n     NODE_ENV,\n     DB_URI,\n     JWT_SECRET,\n     JWT_EXPIRES_IN,\n     ARCJET_ENV,\n     QSTASH_TOKEN,\n     QSTASH_URL,\n     SERVER_URL,\n     EMAIL_PASSWORD,\n     ```\n\n4. Start the server:\n   ```bash\n   npm start\n   ```\n\n5. Access the API at `http://localhost:5000`.\n\n---\n\n## Deployment 🚀\n\nThis project is designed to be deployed on **Hostinger/Vercel** with **Arcjet** for enhanced security. Follow these steps:\n\n1. Push your code to GitHub:\n   ```bash\n   git add .\n   git commit -m \"Deploying subscription management system\"\n   git push origin main\n   ```\n\n2. Deploy on **Vercel**:\n   - Connect your GitHub repository to Vercel.\n   - Configure environment variables in the Vercel dashboard.\n   - Deploy the project.\n\n3. Enable **Arcjet**:\n   - Add Arcjet to your Vercel project for API security.\n\n---\n\n## Credits 🙌\n\nThis project is based on a **Backend Crash Course** by [JavaScript Mastery](https://www.javascriptmastery.com). Special thanks to their team for providing an in-depth and practical guide to building production-ready backend systems.\n\n---\n\n## Support and Feedback 💬\n\nIf you have any questions, feedback, or issues, feel free to open an issue on GitHub or reach out to the community at [JavaScript Mastery](https://www.jsmastery.pro) or reach out to me at [Obomheser@gmail.com](obomheser@gmail.com).\n\n---\n\nHappy coding! 🚀🤘\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fobomhese-raphael%2Fsubscription-tracker-backend","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fobomhese-raphael%2Fsubscription-tracker-backend","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fobomhese-raphael%2Fsubscription-tracker-backend/lists"}