Production-ready multi-tenant SaaS billing platform with microservices architecture, comprehensive testing, and enterprise observability.
β‘ Quick Stats:
- π¦ 5 Microservices + API Gateway
- β 213 Tests (100% passing)
- π Prometheus + Grafana Monitoring
- π³ Docker + Kubernetes Ready
- π CI/CD with GitHub Actions
- Row-Level Security (RLS) for data isolation
- Tenant-aware logging and metrics
- Scalable subscription management
- Auth Service - JWT authentication, session management (Redis)
- Billing Service - Subscriptions, invoices, usage-based metering
- Payment Service - Stripe integration, payment methods, refunds
- Notification Service - Email (SMTP), SMS (Twilio), webhooks
- API Gateway - Request routing, rate limiting, CORS
- Prometheus - Metrics collection from all services
- Grafana - 6 dashboards, 18 production alerts
- Winston - Structured logging with daily rotation
- Real-time monitoring of business and system metrics
- Docker - Containerized services with multi-stage builds
- Kubernetes - Production-ready manifests with Kustomize
- CI/CD - Automated testing and Docker builds (GitHub Actions)
- Terraform - Infrastructure as Code
Backend:
- Node.js 18+ with TypeScript 5.x
- Express.js for REST APIs
- PostgreSQL 14 with Row-Level Security
- Redis 7 for sessions and caching
Testing:
- Jest with 213 automated tests
- Supertest for integration testing
- Mock implementations for external services
Monitoring:
- Prometheus for metrics
- Grafana for visualization
- Winston for structured logging
Infrastructure:
- Docker & Docker Compose
- Kubernetes with Kustomize
- GitHub Actions for CI/CD
- Terraform for cloud provisioning
- Node.js 18+
- Docker & Docker Compose
- PostgreSQL 14+
- Redis 7+
# Clone the repository
git clone https://github.com/GoddeyUwamari/cloudbill.git
cd cloudbill
# Install dependencies
npm install
# Start infrastructure (PostgreSQL + Redis)
docker-compose up -d postgres redis
# Run database migrations
npm run db:migrate
# Start all services
docker-compose up -d
# Verify all services are healthy
docker-compose ps
# Run tests
npm test- API Gateway: http://localhost:8080
- Grafana: http://localhost:3000 (admin/admin)
- Prometheus: http://localhost:9090
Email: admin@democompany.com
Password: Admin123!
Tenant ID: 00000000-0000-0000-0000-000000000001
Access Grafana at http://localhost:3000 (admin/admin)
Available Dashboards:
- System Overview - Cross-service health and performance
- API Gateway - Traffic, latency, error rates
- Auth Service - Login metrics, token generation
- Billing Service - Subscriptions, invoices, usage
- Payment Service - Transaction volumes, success rates
- Notification Service - Email/SMS/webhook delivery
All services expose metrics at /metrics endpoint:
- HTTP request metrics (count, duration, active connections)
- Database query performance
- Redis operation latency
- Business metrics (subscriptions, payments, notifications)
# Test authentication and generate metrics
for i in {1..50}; do
curl -X POST http://localhost:8080/api/auth/login \
-H "Content-Type: application/json" \
-H "X-Tenant-ID: 00000000-0000-0000-0000-000000000001" \
-d '{"email":"admin@democompany.com","password":"Admin123!"}'
sleep 0.5
doneWatch metrics populate in Grafana in real-time!
CloudBill Platform
ββ API Gateway (Port 8080)
β ββ Request routing & proxying
β ββ Rate limiting (Redis-based)
β ββ CORS & security headers
β ββ Health check aggregation
β
ββ Auth Service (Port 3001)
β ββ JWT authentication
β ββ Session management (Redis)
β ββ User registration & login
β ββ Password reset flows
β
ββ Billing Service (Port 3002)
β ββ Subscription management
β ββ Invoice generation
β ββ Usage-based metering
β ββ Multi-tier pricing plans
β
ββ Payment Service (Port 3003)
β ββ Stripe integration
β ββ Payment method management
β ββ Refund processing
β ββ Webhook handling
β
ββ Notification Service (Port 3004)
β ββ Email (SMTP/Nodemailer)
β ββ SMS (Twilio)
β ββ Webhook delivery
β ββ Template management
β
ββ PostgreSQL (Port 5433)
β ββ Multi-tenant with RLS
β ββ Production & test databases
β ββ Automated migrations
β
ββ Redis (Port 6380)
β ββ Session storage
β ββ Rate limiting
β ββ Caching layer
β
ββ Monitoring Stack
ββ Prometheus (Port 9090)
ββ Grafana (Port 3000)
ββ 18 production alerts
# All 213 tests
npm test
# With coverage report
npm run test:coverage
# Specific service
cd services/auth-service && npm test
cd services/billing-service && npm test
cd services/payment-service && npm test
cd services/notification-service && npm testββββββββββββββββββββββββββ¬ββββββββ¬ββββββββββ¬βββββββββββ
β Service β Tests β Passing β Coverage β
ββββββββββββββββββββββββββΌββββββββΌββββββββββΌβββββββββββ€
β Auth Service β 34 β 34 β 100% β
β Billing Service β 80 β 80 β 100% β
β Payment Service β 69 β 69 β 100% β
β Notification Service β 30 β 30 β 100% β
ββββββββββββββββββββββββββΌββββββββΌββββββββββΌβββββββββββ€
β TOTAL β 213 β 213 β 100% β
ββββββββββββββββββββββββββ΄ββββββββ΄ββββββββββ΄βββββββββββ
# Start all services
docker-compose up -d
# Check service health
docker-compose ps
# View logs
docker-compose logs -f api-gateway
# Stop all services
docker-compose down# Deploy to development environment
kubectl apply -k infrastructure/kubernetes/overlays/dev/
# Deploy to production
kubectl apply -k infrastructure/kubernetes/overlays/production/
# Verify deployment
kubectl get pods -n cloudbill
kubectl get services -n cloudbill
# Access services (port-forward)
kubectl port-forward svc/api-gateway 8080:8080 -n cloudbill# Login
POST http://localhost:8080/api/auth/login
Content-Type: application/json
X-Tenant-ID: 00000000-0000-0000-0000-000000000001
{
"email": "admin@democompany.com",
"password": "Admin123!"
}
# Response
{
"success": true,
"data": {
"user": { "id": "...", "email": "...", "role": "SUPER_ADMIN" },
"accessToken": "eyJhbGc...",
"expiresIn": 900
}
}# Create subscription
POST http://localhost:8080/api/billing/subscriptions
Authorization: Bearer <token>
X-Tenant-ID: <tenant-id>
{
"planId": "professional",
"paymentMethodId": "pm_..."
}# Create payment
POST http://localhost:8080/api/payments/create
Authorization: Bearer <token>
X-Tenant-ID: <tenant-id>
{
"amount": 2999,
"currency": "usd",
"paymentMethodId": "pm_..."
}Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- TypeScript strict mode enabled
- ESLint for code quality
- Prettier for formatting
- 100% test coverage for new features
- Meaningful commit messages
This project is licensed under the MIT License - see the LICENSE file for details.
Goddey Uwamari
- GitHub: @GoddeyUwamari
- LinkedIn: Goddey Uwamari
Built with:
- Express.js - Web framework
- TypeScript - Type safety
- PostgreSQL - Database
- Redis - Caching & sessions
- Stripe - Payment processing
- Prometheus - Metrics
- Grafana - Visualization
- Docker - Containerization
- Kubernetes - Orchestration
β If you find this project useful, please consider giving it a star!