Skip to content

Shewale41/subscription-tracker-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

11 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Subscription Management System API

A production-ready backend API for managing subscriptions, authentication, reminders, and automation workflows


πŸ“‹ Table of Contents

  1. Introduction
  2. Tech Stack
  3. Features
  4. Project Architecture
  5. Quick Start
  6. Example Request Payload
  7. API Overview
  8. Environment Variables
  9. Development Notes

πŸ€– Introduction

This project is a Subscription Management System API designed to simulate real-world backend workflows involving authentication, billing logic, and automated reminders.

It demonstrates how to:

  • Secure APIs with authentication middleware
  • Model real business data with MongoDB
  • Automate workflows using background job scheduling
  • Send transactional email reminders
  • Build scalable backend architecture

The system is structured to resemble production-grade APIs used in SaaS platforms.


βš™οΈ Tech Stack

  • Node.js β€” backend runtime
  • Express.js β€” API framework
  • MongoDB + Mongoose β€” database modeling
  • JWT β€” authentication & authorization
  • Arcjet β€” rate limiting & bot protection
  • Upstash Workflow/QStash β€” background scheduling
  • Nodemailer β€” transactional email delivery
  • Day.js β€” date/time handling

πŸ”‹ Features

πŸ‘‰ Secure authentication using JWT

πŸ‘‰ Subscription CRUD management

πŸ‘‰ Automated reminder scheduling

πŸ‘‰ Background workflow orchestration

πŸ‘‰ Email notification system

πŸ‘‰ Database modeling with relationships

πŸ‘‰ Global error handling middleware

πŸ‘‰ Rate limiting & bot protection

πŸ‘‰ Clean modular architecture

πŸ‘‰ Production-style API structure


πŸ— Project Architecture

controllers/
routes/
models/
middleware/
utils/
config/
database/
workflows/

The architecture separates:

  • Business logic
  • API routing
  • database modeling
  • background workflow processing
  • email utilities

This ensures maintainability and scalability.


🀸 Quick Start

Prerequisites

Make sure you have installed:

  • Git
  • Node.js (v18+)
  • npm
  • MongoDB (local or cloud)

Clone Repository

git clone <your-repository-url>
cd subscription-tracker

Install Dependencies

npm install

Configure Environment Variables

Create:

.env.development.local

Add:

# Server
PORT=5500
SERVER_URL=http://localhost:5500

# Environment
NODE_ENV=development

# Database
DB_URI=

# JWT
JWT_SECRET=
JWT_EXPIRES_IN=1d

# Arcjet
ARCJET_KEY=
ARCJET_ENV=development

# Upstash Workflow
QSTASH_URL=http://127.0.0.1:8080
QSTASH_TOKEN=

# Email
EMAIL_PASSWORD=

Start Local Workflow Server

npx @upstash/qstash-cli dev

Keep this terminal running.


Start API Server

npm run dev

Server runs at:

http://localhost:5500

πŸ§ͺ Example Request Payload

{
  "name": "Streaming Subscription",
  "price": 19.99,
  "currency": "USD",
  "frequency": "monthly",
  "category": "Entertainment",
  "startDate": "2026-01-10T00:00:00.000Z",
  "paymentMethod": "Card"
}

πŸ”— API Overview

Authentication

POST /api/v1/auth/register
POST /api/v1/auth/login

Users

GET /api/v1/users/:id

Subscriptions

POST /api/v1/subscriptions
GET /api/v1/subscriptions/:userId

Workflow Trigger

POST /api/v1/workflows/subscription/remainder

Schedules automated renewal reminder emails.


πŸ” Environment Variables

Sensitive values should never be committed.

Required:

  • Database connection string
  • JWT secrets
  • Email credentials
  • Workflow tokens

πŸš€ Development Notes

  • Keep QStash dev server running for workflows
  • Reminder workflows execute asynchronously
  • Email sending requires valid SMTP credentials
  • MongoDB connection must be active

Recommended tools:

  • Postman / Insomnia for testing
  • MongoDB Compass for inspection

πŸ“Œ Future Improvements

  • Payment integration
  • Subscription analytics
  • Admin dashboard
  • Notification channels (SMS/Webhooks)
  • Frontend client

πŸ“„ License

MIT β€” free to use and extend.


Built for learning, experimentation, and production-style backend design.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors