A production-ready Subscription Management System API that handles real users, real money, and real business logic.
Authenticate users using JWTs, connect a database, create models and schemas, and integrate it with ORMs. Structure the architecture of your API to ensure scalability and seamless communication with the frontend.
Run the API with MongoDB using Docker Compose: bash docker compose up --build
The API will be available at: http://localhost:5500
MongoDB runs inside Docker and is available to the API at: mongodb://mongo:27017/subscription_tracker
For local Docker Compose configuration, create a .env file:
env JWT_SECRET=replace-with-a-secure-secret JWT_EXPIRES_IN=1d ARCJET_KEY=replace-with-your-arcjet-key ARCJET_ENV=development QSTASH_URL=http://localhost:8080 QSTASH_TOKEN=replace-with-your-qstash-token EMAIL_PASSWORD=replace-with-your-email-password
The project includes a GitHub Actions workflow at: .github/workflows/ci-cd.yml
It runs linting, builds the Docker image, validates Docker Compose, and publishes the image to GitHub Container Registry on push.
Published image: ghcr.io//subscription-tracker-api:lates
Swagger API documentation is available after starting the server: http://localhost:5500/api-docs
- Node.js
- Express.js
- MongoDB
👉 Advanced Rate Limiting and Bot Protection: with Arcjet that helps you secure the whole app.
👉 Database Modeling: Models and relationships using MongoDB & Mongoose.
👉 JWT Authentication: User CRUD operations and subscription management.
👉 Global Error Handling: Input validation and middleware integration.
👉 Logging Mechanisms: For better debugging and monitoring.
👉 Email Reminders: Automating smart email reminders with workflows using Upstash.
and many more, including code architecture and reusability
Follow these steps to set up the project locally on your machine.
Prerequisites
Make sure you have the following installed on your machine:
Cloning the Repository
git clone https://github.com/adrianhajdin/subscription-tracker-api.git
cd subscription-tracker-apiInstallation
Install the project dependencies using npm:
npm installSet Up Environment Variables
Create a new file named .env.local in the root of your project and add the following content:
# PORT
PORT=5500
SERVER_URL="http://localhost:5500"
# ENVIRONMENT
NODE_ENV=development
# DATABASE
DB_URI=
# JWT AUTH
JWT_SECRET=
JWT_EXPIRES_IN="1d"
# ARCJET
ARCJET_KEY=
ARCJET_ENV="development"
# UPSTASH
QSTASH_URL=http://127.0.0.1:8080
QSTASH_TOKEN=
# NODEMAILER
EMAIL_PASSWORD=Running the Project
npm run devOpen http://localhost:5500 in your browser or any HTTP client to test the project.
Dummy JSON Data
{
"name": "Javascript Mastery Elite Membership",
"price": 139.00,
"currency": "USD",
"frequency": "monthly",
"category": "Entertainment",
"startDate": "2025-01-20T00:00:00.000Z",
"paymentMethod": "Credit Card"
}- Arcjet - https://launch.arcjet.com/4g2R2e4
- Upstash - https://bit.ly/42ealiN
- Hostinger - https://hostinger.com/mastery10
- WebStorm - https://jb.gg/GetWebStormFree