| name | fastapi-factory-utilities |
| description | Build FastAPI microservices with plugins, message brokers, OAuth2/OIDC, OpenTelemetry, and structured logging. Use when this capability is needed. |
| metadata | {"author":"DeerHide"} |
FastAPI Factory Utilities
When to use this skill?
- Use this skill when building FastAPI microservices with the fastapi_factory_utilities library.
- Use this skill when implementing plugin-based architectures in FastAPI applications.
- Use this skill when setting up OAuth2/OIDC authentication with Hydra or Kratos.
- Use this skill when configuring MongoDB with Beanie ODM in FastAPI applications.
- Use this skill when implementing RabbitMQ message brokers with AioPika.
- Use this skill when setting up background task processing with Taskiq and Redis.
- Use this skill when configuring OpenTelemetry for distributed tracing and metrics.
- Use this skill when implementing structured logging with structlog.
- Use this skill when using dependency injection patterns with FastAPI's Depends system.
- Use this skill when creating mock resources for testing (AioHttp, ODM repositories).
- Use this skill when implementing repository patterns for data access.
- Use this skill when configuring health checks and status services.
- Use this skill when implementing JWT Bearer authentication with JWKS verification.
A library for building production-ready FastAPI microservices with plugin-based architecture.
Quick Start
See assets/quick_start_example.py for a minimal application setup.
Dependency Injection and Testing
The library uses FastAPI's Depends for dependency injection. Plugins expose resources via dependency functions (e.g., AioHttpResourceDepends, depends_status_service, depends_scheduler_component).
For testing, several plugins provide mockers to create mock resources:
- AioHttp:
build_mocked_aiohttp_resource, build_mocked_aiohttp_response - Mock HTTP clients and responses
- ODM:
AbstractRepositoryInMemory - In-memory repository for unit testing without MongoDB
- See AioHttp reference and Repository Pattern for detailed mocking examples
Reference Documentation
Core
Plugins
Services
Security
Utilities
Best Practices
- Plugin Order - Load plugins in dependency order (ODM before repositories)
- Configuration - Use YAML files with
${ENV_VAR:default} syntax
- Lifecycle - Keep
configure() lightweight, use on_startup() for connections
- Observability - Enable OpenTelemetry in production
- Logging - Use JSON mode in production for log aggregation
- Testing - Use mockers from aiohttp plugin for HTTP client tests
Source: DeerHide/fastapi_factory_utilities — distributed by TomeVault.