How alandonohoe/usage_service works
Main Components
a) Web Layer:
• FastAPI Application (Primary HTTP Server)
• API Routes Structure (v1 endpoints and health monitoring)
• Swagger Documentation endpoint
b) Service Layer:
• Usage Service
• Usage Calculator
• Message and Report Services
c) Infrastructure Layer:
• Message API Infrastructure
• Reports API Infrastructure
d) Data Models:
• Message Model
• Report Model
• Usage Model
┌─────────────────────────────────────────────────────┐
• Client Requests │
• ┘
• ↓
┌─────────────────────────────────────────────────────┐
• Web Layer │
• ┌─────────────┐ ┌─────────────┐ ┌────────────┐ │
• FastAPI │ │ Router │ │ Health │ │
• Application │ │ (v1 API) │ │ Endpoint │ │
• ┘ └─────────────┘ └────────────┘ │
• ┘
• ↓
┌─────────────────────────────────────────────────────┐
• Service Layer │
• ┌─────────────┐ ┌─────────────┐ ┌────────────┐ │
• Usage │ │ Usage │ │ External │ │
• Service │←→│ Calculator │ │ Services │ │
• ┘ └─────────────┘ └────────────┘ │
• ┘
• ↓
┌─────────────────────────────────────────────────────┐
• Infrastructure Layer │
• ┌─────────────┐ ┌─────────────┐ │
• Messages │ │ Reports │ │
• API │ │ API │ │
• ┘ └─────────────┘ │
• ┘
Important Details
a) Configuration Management:
• Environment variables configuration
• Settings management through pydantic
b) Deployment Options:
• Docker container
• Development environment
• Production environment
c) Testing Infrastructure:
• Unit tests
• Integration tests
• Test fixtures
Specific Implementation Notes
• The separation between API versions (v1)
• The monitoring/health check system
• The usage calculation flow
• The interaction between services and infrastructure
• The model relationships