https://github.com/peppapig13132/stripemetrics-backend
Stripe Analytic Dashboard Web Application Backend
https://github.com/peppapig13132/stripemetrics-backend
cron-jobs express express-js node postgresql sequelize-orm stripe stripeapi typescipt
Last synced: 2 months ago
JSON representation
Stripe Analytic Dashboard Web Application Backend
- Host: GitHub
- URL: https://github.com/peppapig13132/stripemetrics-backend
- Owner: peppapig13132
- License: mit
- Created: 2024-05-20T13:17:37.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-07-18T00:20:57.000Z (over 1 year ago)
- Last Synced: 2025-03-31T17:25:49.725Z (8 months ago)
- Topics: cron-jobs, express, express-js, node, postgresql, sequelize-orm, stripe, stripeapi, typescipt
- Language: TypeScript
- Homepage:
- Size: 128 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# StripeMetrics (Backend)



## Features
- [x] MRR
- [x] Subscribers
- [x] MRR Movements
- [x] Average Staying
- [x] Customer Lifetime Value
- [x] Customer Churn Rate
- [x] Free to paid subscriptions
- [x] Free trials
- [x] Annual Run Rate
## Deployment
### Frontend
[Frontend Repository](https://github.com/peppapig13132/StripeMetrics-Frontend)
### Steps
1. Clone the repository from GitHub
```
git clone https://github.com/peppapig13132/StripeMetrics-Backend.git
cd StripeMetrics-Backend
```
2. Install Dependencies
Install the necessary dependencies for Backend - Express.js project.
```
npm install
```
3. Set Environment variables
Replace filename `.env.example` to `.env`.
```
# This variable used for JWT
SECRETKEY=
```
4. Prepare Frontend Codes
Move Compiled Frontend Codes into `static` directory.
5. Run Development mode
Running without hotload
```
npm start
```
Running with hotload (Used nodemon)
```
npm run dev
```
6. Run Production mode
Build the code: This command will create `dist` directory in the project folder.
```
npm run build
```
```
cd dist
npm start
```
7. Synchronize Database
Use environment variable `DB_SYNC` to synchronize database.
```
# Synchronize database
DB_SYNC=true
# Ignore synchronization
DB_SYNC=false
```
To synchronize a specific model, find `src/db.ts`
## Calculation
### Customer Lifetime Value
- **ARPU** (Average Monthly Revenue Per User)
```
ARPU = Total Monthly Revenue / Number of Active Customers
```
- **Monthly Churn Rate**
```
Monthly Churn Rate = Number of Customers Lost in a Month / Number of Customers at the Start of the Month
```
- **Customer Lifetime**
```
Customer Lifetime = 1 / Monthly Churn Rate
```
- **CLV** (Customer Lifetime Value)
```
CLV = ARPU * Customer Lifetime
```
### Customer Churn Rate
- **Customer Churn Rate**
```
Churn Rate = (Number of Canceled Subscriptions / Number of Active Subscriptions at the Start) * 100
```
### Annual Run Rate
- **Annual Run Rate**
Be sure, Annual Run Rate calcualted by following formular as the provider has only monthly subscriptions.
```
Annual Run Rate = MRR * 12
```
## Deploy Node.js application on cPanel
- Modify your `.htaccess` file in the domain root directory.
```
# If your server running on port 8000
RewriteEngine on
RewriteRule ^(.*)$ http://127.0.0.1:8000/$1 [P]
```
- Use `pm2` module. More about `pm2`, click [here](https://pm2.keymetrics.io/).
```
# Start process
pm2 start
# Check process
pm2 list
# Stop process
pm2 delete
```
## Logic Verification
- [x] MRR
- [x] Subscribers
- [x] MRR Movements
- [ ] Average Staying
- [ ] Customer Lifetime Value
- [x] Customer Churn Rate
- [x] Free to paid subscriptions
- [ ] Free trials
- [x] Annual Run Rate