Billing Service Architecture
The Billing Service manages all financial operations for the MATIH platform. Running on port 8087, it provides usage metering, invoice generation, subscription management, Stripe payment integration, cost center allocation, quota enforcement, coupon management, and real-time cost tracking. The service processes billable events from Kafka and generates invoices on a scheduled basis using ShedLock for distributed scheduling.
Service Overview
| Property | Value |
|---|---|
| Service Name | billing-service |
| Port | 8087 |
| Technology | Spring Boot 3.2, Java 21 |
| Database | PostgreSQL (JPA/Hibernate) |
| Payment Provider | Stripe |
| Event Bus | Kafka (usage events, billing events) |
| Scheduling | ShedLock (distributed job locking) |
| Notifications | Integration with Notification Service |
Controllers
| Controller | Base Path | Purpose |
|---|---|---|
BillingController | /api/v1/billing | Usage, invoices, subscriptions, plans, Stripe |
CostCenterController | /api/v1/billing/cost-centers | Cost center management |
CostDashboardController | /api/v1/billing/cost-dashboard | Cost analytics and dashboards |
QuotaController | /api/v1/billing/quotas | Resource quota management |
CouponController | /api/v1/billing/coupons | Coupon and discount management |
RealtimeCostController | /api/v1/billing/realtime-cost | Real-time cost metrics and alerts |
CostIngestionController | /api/v1/billing/cost-ingestion | Cloud cost data ingestion |
SimplifiedPricingController | /api/v1/billing/pricing | Simplified pricing calculations |
MilestoneController | /api/v1/billing/milestones | Usage milestone tracking |
Key Entities
| Entity | Description |
|---|---|
UsageRecord | Individual usage events (API calls, storage, compute) |
UsageAggregate | Aggregated usage data for billing periods |
Invoice | Generated invoices with line items |
Subscription | Tenant subscription to a plan |
Plan | Pricing plan definitions |
ResourceQuota | Per-tenant resource quotas |
CostCenter | Cost allocation centers |
RealtimeCostMetric | Real-time cost tracking data |
Next Steps
- Usage Metering -- recording and aggregating usage
- Invoices -- invoice generation and management
- Subscriptions -- subscription lifecycle
- Stripe Integration -- payment processing
- Cost Centers -- cost allocation
- Quotas -- resource quota enforcement
- Coupons -- coupon and discount management
- API Reference -- complete endpoint listing