A NestJS REST API with MongoDB, JWT authentication, and cryptocurrency payment integration. Portfolio project showcasing modern backend architecture patterns.
Backend API for a subscription-based task execution service:
- User registration and authentication (JWT + OAuth2)
- Subscription tier management (Free, Pro, Enterprise)
- Cryptocurrency payment processing via NowPayments
- Task execution with configurable auto-stop timers
- Real-time metrics collection and analytics
- NestJS 11 - Backend framework with modular architecture
- MongoDB + Mongoose - Database with ODM
- Passport.js - Authentication (JWT + OAuth2)
- NowPayments API - Crypto payments (BTC, ETH, LTC, SOL, USDT)
- Nodemailer + Brevo - Email verification and notifications
- TypeScript 5.7 - Strict mode
Authentication
- Email/password registration with verification
- JWT access tokens + refresh tokens
- OAuth2 providers (Google, GitHub)
- Password reset flow
Payments
- Cryptocurrency payment integration
- Subscription tier upgrades
- Payment webhook handling
- Transaction history
Task Management
- Auto-stop scheduling (max 180 minutes)
- Metrics collection per task
- API token-based access
- Role-based permissions
Analytics
- Real-time metrics dashboard
- Task execution statistics
- User activity tracking
# Register
POST /auth/register
{
"email": "user@example.com",
"password": "secure123",
"username": "johndoe"
}
# Login
POST /auth/login
{
"email": "user@example.com",
"password": "secure123"
}
# Get user metrics
GET /metrics/:userId
Authorization: Bearer <api-token>src/
├── analytics/ # Metrics collection and dashboards
├── auth/ # Authentication and authorization
├── executor/ # Task execution logic
├── metrics/ # Metrics API
├── payments/ # Crypto payment processing
├── subscriptions/ # Tier management
├── users/ # User management
└── mail/ # Email services
Layered Design
- Controllers → DTOs + Validation
- Services → Business logic
- Repositories → Data access
- Guards → Authorization
- Interceptors → Response transformation
- API response time: <50ms average
- Request throughput: 1000+ req/s
- Database queries: <10ms (with indexes)
- Memory usage: <200MB
npm install
cp .env.example .env
# Configure MongoDB, NowPayments API key, SMTP settings
npm run start:devMONGODB_URI=mongodb://localhost:27017/task-execution
JWT_SECRET=your-secret-key
JWT_REFRESH_SECRET=your-refresh-secret
NOWPAYMENTS_API_KEY=your-nowpayments-key
SMTP_HOST=smtp-relay.brevo.com
SMTP_USER=your-email
SMTP_PASS=your-password- NestJS modular architecture and dependency injection
- JWT token lifecycle management (access + refresh)
- Cryptocurrency payment webhook verification
- MongoDB schema design for relational-ish data
- Email verification flows with token expiration
- Rate limiting and API security basics
This is a portfolio demonstration. For production you'd need:
- Security audit (especially payment handling)
- Proper secrets management
- Monitoring and logging
- Backup and disaster recovery
- Load testing and optimization
- GDPR compliance for user data
MIT
Stefan Kunde