Glossary
Relevant source files - .env.example - app.js - config/arcjet.js - config/nodemailer.js - config/upstash.js - controllers/subscription.controller.js - controllers/workflow.controller.js - middlewares/arcjet.middleware.js - middlewares/error.middleware.js - models/subscription.model.js - models/user.model.js - package.json - utils/email-template.js
This page provides definitions for codebase-specific terms, architectural concepts, and third-party integrations used within the Subscription Tracker. It serves as a reference for onboarding engineers to understand the domain language and how it maps to specific code entities.
Domain Concepts
Subscription Lifecycle
The state and timing of a user's recurring payment.
- Renewal Date: The calculated date when the next payment is due. It is automatically generated if not provided, based on the
frequency(daily, weekly, monthly, yearly) models/subscription.model.js70-81 - Status: The current state of the subscription. Possible values include
active,inactive,canceled,pending, andexpiredmodels/subscription.model.js35-39 - Expiration: A subscription is automatically marked as
expiredduring a pre-save hook if therenewalDateis in the past models/subscription.model.js83-84
Reminders
Automated notifications sent to users before their subscription renews. The system follows a fixed schedule of [7, 5, 2, 1] days before the renewalDatecontrollers/workflow.controller.js8
Technical Terms & Integrations
Arcjet
A security layer used as middleware to protect API routes.
- Shield: WAF-like protection against common attacks config/arcjet.js9
- Bot Detection: Identifies and blocks automated agents, while allowing search engines config/arcjet.js10-13
- Token Bucket: A rate-limiting algorithm. The system is configured with a capacity of 10 and a refill rate of 5 every 10 seconds config/arcjet.js14-19
Upstash Workflow
A durable execution engine used to manage long-running subscription reminders.
- Workflow Client: The interface used to trigger new workflows upon subscription creation controllers/subscription.controller.js22-31
- Context (context.run / context.sleepUntil): Upstash-specific methods to ensure steps are idempotent and the execution can pause for days without consuming server resources controllers/workflow.controller.js36-44
Brevo (formerly Sendinblue)
The SMTP provider used for dispatching reminder emails. Configuration involves a transporter using host smtp-relay.brevo.com on port 587 config/nodemailer.js13-20
Code Entity Mapping
The following diagrams illustrate the relationship between natural language concepts and the specific classes, functions, and files that implement them.
Subscription Creation & Workflow Trigger
This diagram shows how a "Subscription Creation" request maps to the database and the asynchronous workflow engine.
[Flowchart Diagram]
Sources:controllers/subscription.controller.js5-43models/subscription.model.js3-68app.js29
Security & Request Filtering
This diagram maps "Security Protection" to the specific middleware and configuration entities.
[Flowchart Diagram]
Sources:middlewares/arcjet.middleware.js3-36config/arcjet.js4-21app.js25
Key Abbreviations
| Abbreviation | Full Term | Context in Codebase |
|---|---|---|
| JWT | JSON Web Token | Used for stateless authentication via the authorize middleware. |
| WAF | Web Application Firewall | Implemented via Arcjet's shield rule config/arcjet.js9 |
| SMTP | Simple Mail Transfer Protocol | Used by nodemailer to connect to Brevo config/nodemailer.js13-14 |
| ESM | ECMAScript Modules | The module system used ("type": "module") allowing import/exportpackage.json5 |
Implementation Reference Table
| Concept | File Pointer | Key Function/Variable |
|---|---|---|
| Global Error Handling | middlewares/error.middleware.js1-37 | errorMiddleware |
| Database Connection | database/mongodb.js | connectDb |
| Email Dispatch | utils/send-email.js | sendReminderEmail |
| Workflow Entry Point | controllers/workflow.controller.js10-33 | sendReminders |
| Rate Limit Config | config/arcjet.js14-19 | tokenBucket |
| Subscription Schema | models/subscription.model.js3-68 | subscriptionSchema |
Sources:app.js1-61package.json1-37middlewares/arcjet.middleware.js1-38controllers/subscription.controller.js1-167config/nodemailer.js1-47config/arcjet.js1-23middlewares/error.middleware.js1-37models/subscription.model.js1-88controllers/workflow.controller.js1-57models/user.model.js1-30