Application Configuration:
- FastAPI application factory pattern
- CORS middleware for cross-origin support
- Global exception handlers for consistent error responses
- AppException handler for custom errors
- RequestValidationError handler for Pydantic validation
- General exception handler for unexpected errors
- Lifespan management for startup/shutdown events
- Router registration for all API endpoints
- OpenAPI schema with interactive documentation
Models Service:
- Integration with ModelRegistry
- List available models endpoint
- Model capability discovery
Test Infrastructure:
- Pytest configuration with async support
- Test client fixtures for sync and async testing
- Comprehensive main application tests (14 tests):
- App creation and metadata
- Router registration verification
- CORS middleware and functionality
- Exception handler registration and behavior
- Lifespan event handling
- OpenAPI schema generation
- Documentation accessibility
- Validation error handling
- Models API tests (2 tests)
- Total: 95 tests, 78.95% coverage
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Implement application factory pattern with clean main.py.
Separate routers for each domain, centralized exception handling.
Core Router (src/core/router.py):
- Root endpoint (/)
- Health check endpoint (/health)
- Simple status responses
- No prefix (mounted at root)
Main Application (src/main.py):
- create_application() factory function
- Clean configuration-focused main.py
- CORS middleware setup
- Exception handler registration
- Router registration with proper prefixes
- Global config integration
Application Architecture:
- Application factory pattern for testability
- Routers imported from separate controllers
- Exception handlers in dedicated function
- All routes cleanly separated by domain
Exception Handling:
- OpenAI-compatible error format
- Custom AppException handler
- Validation error handler (422)
- Generic exception handler (500)
Following Best Practices:
- Separation of concerns
- Factory pattern for DI
- Clean main.py (config only)
- Type hints throughout
Status: Production-ready structure
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>