A decentralized utility payment platform enabling users to pay electricity & water bills using Stellar blockchain.
This project implements a Database Per Service microservices architecture, ensuring:
- Data isolation between services
- Independent scaling capabilities
- Technology diversity support
- Autonomous deployment
- User Service - Authentication, profiles, sessions
- Notification Service - Email, SMS, push notifications
- Document Service - File storage (S3/IPFS)
- Utility Service - Utility provider management
- Payment Service - Payment processing via Stellar
- Billing Service - Bill management and coupons
- Analytics Service - Reporting and metrics
- Webhook Service - Event webhooks
- Node.js 18+
- Docker & Docker Compose
- PostgreSQL client tools
- Stellar account (testnet)
- Clone and install dependencies
git clone <repository-url>
cd nepa
npm install- Start database containers
npm run db:docker-up- Configure environment
cp .env.example .env
# Update database URLs and other configurations- Generate Prisma clients
npm run db:generate-all- Run migrations
npm run db:migrate-all- Start the application
npm run dev# Setup all databases
npm run db:setup
# Generate all Prisma clients
npm run db:generate-all
# Run all migrations
npm run db:migrate-all
# Backup all databases
npm run db:backup
# Health check
npm run db:health-check
# Monitor connection pools
npm run db:monitor-pools
# Docker commands
npm run db:docker-up # Start containers
npm run db:docker-down # Stop containers
npm run db:docker-logs # View logsEach service has its own PostgreSQL database:
| Service | Database | Port |
|---|---|---|
| User | nepa_user_service | 5432 |
| Notification | nepa_notification_service | 5433 |
| Document | nepa_document_service | 5434 |
| Utility | nepa_utility_service | 5435 |
| Payment | nepa_payment_service | 5436 |
| Billing | nepa_billing_service | 5437 |
| Analytics | nepa_analytics_service | 5438 |
| Webhook | nepa_webhook_service | 5439 |
Services communicate through domain events:
import EventBus from './databases/event-patterns/EventBus';
import MessageBroker from './databases/event-patterns/MessageBroker';
import { createPaymentSuccessEvent } from './databases/event-patterns/events';
// Publish event (in-memory)
EventBus.publish(createPaymentSuccessEvent(paymentId, billId, userId, amount));
// Publish event (persistent queue)
await MessageBroker.connect();
await MessageBroker.publish(event);
// Subscribe to event
EventBus.subscribe('payment.success', async (event) => {
// Handle event
});npm run messaging:start # Start RabbitMQ & Redis
npm run test:events # Test event system- URL: http://localhost:15672
- User: admin / Pass: admin
Distributed transactions use the Saga pattern:
import PaymentSaga from './databases/saga/PaymentSaga';
const result = await PaymentSaga.executePayment({
userId,
billId,
amount,
method: 'STELLAR',
transactionId
});npm test # Run all tests
npm run test:unit # Unit tests
npm run test:integration # Integration tests
npm run test:e2e # End-to-end tests
npm run db:test-saga # Test saga implementation# Check database health
npm run db:health-check
# Monitor connection pools
npm run db:monitor-pools 300000 10000 # 5 min duration, 10s intervalnpm run dev # Start development server
npm run build # Build for production
npm run lint # Lint code
npm run type-check # TypeScript type checking# Start all observability services
npm run observability:start
# Test observability
npm run observability:test
# View logs
npm run observability:logs- Grafana: http://localhost:3000 (admin/admin)
- Prometheus: http://localhost:9090
- Jaeger: http://localhost:16686
- Alertmanager: http://localhost:9093
- Structured Logging: JSON logs with correlation IDs
- Distributed Tracing: OpenTelemetry + Jaeger
- Metrics Collection: Prometheus + Grafana
- Log Aggregation: Loki + Promtail
- Alerting: Alertmanager with Slack/PagerDuty
- SLA Monitoring: Automated SLA tracking
- Anomaly Detection: ML-based anomaly detection
See Observability Documentation for details.
- β Microservices architecture with database per service
- β Event-driven communication between services
- β Saga pattern for distributed transactions
- β Stellar blockchain integration for payments
- β Multi-utility support (electricity, water)
- β Webhook system for external integrations
- β Document storage (S3/IPFS)
- β Comprehensive analytics and reporting
- β Real-time notifications
- β Automated backups and disaster recovery
- β Distributed monitoring and observability
- β SLA tracking and anomaly detection
- β Event-driven architecture with RabbitMQ
- β Asynchronous event processing with retry logic
- β Event sourcing for audit trails
MIT