Back to projects
Subscription Management API

Subscription Management API

Farhan Asfar / October 8, 2025

A REST API built with Node.js, Express, and MongoDB. Features secure authentication (JWT, bcrypt), role-based access control (RBAC), Dockerized deployment, Swagger/OpenAPI documentation, and CI/CD via GitHub Actions.

Features

  • RESTful endpoints for user accounts and subscriptions
  • JWT-based authentication and bcrypt password hashing
  • Role-based access control (admin routes)
  • Swagger/OpenAPI documentation
  • Dockerized for easy deployment; deployed on Render
  • CI/CD with GitHub Actions

Tech Stack

  • Languages: JavaScript
  • Frameworks: Node.js, Express
  • Database: MongoDB (Mongoose)
  • Auth: JWT, bcrypt
  • Testing: Jest, Supertest
  • Docs: Swagger/OpenAPI
  • DevOps: Docker, GitHub Actions, Render
  • Optional: Cloudinary (user profile images)

Prerequisites

  • Node.js v20+
  • MongoDB (local or Atlas)
  • Docker (optional)

Installation

Clone and install:

git clone https://github.com/FarhanAsfar/subscription-Management-API.git
cd subscription-Management-API
npm install

Create a .env file in the project root:

PORT=3000
MONGODB_URI=mongodb://localhost:27017/subscription-api
JWT_SECRET=your_jwt_secret
CLOUDINARY_URL=your_cloudinary_url

Running

Run locally:

npm start
# API: http://localhost:3000

Run tests:

npm test

Run with Docker:

docker build -t arnob21/subscription-api .
docker run -p 3000:3000 --env-file .env arnob21/subscription-api

API Endpoints

Swagger UI Link


Deployment & CI/CD

  • Live Demo
  • Docker Image
  • CI/CD: GitHub Actions workflows:
    • build.yml — installs dependencies and runs tests on PRs
    • deploy.yml — builds and pushes Docker image on push to main

Testing

  • Unit tests: validate helpers (e.g., JWT generation, bcrypt hashing)
  • Integration tests: test endpoints using Supertest
  • Run: npm test