creating-providers-and-moduleslisted
Install: claude install-skill dbtinoy-/lexigram-framework-skills
# Creating Providers and Modules
## Overview
Providers wire services into the DI container. Modules group providers and enforce visibility.
## Core Pattern
Provider = registers/boots/shuts down one bounded concern. Module = groups providers, defines imports/exports.
## Provider Lifecycle
```python
from lexigram.di import Provider
from lexigram.contracts.core.di import ContainerRegistrarProtocol, BootContainerProtocol
from lexigram.contracts.core.health import HealthCheckResult, HealthStatus
class MyProvider(Provider):
name = "my_provider"
priority = ProviderPriority.NORMAL
async def register(self, container: ContainerRegistrarProtocol) -> None:
container.singleton(MyProtocol, MyImpl)
container.transient(OtherProtocol, lambda: OtherImpl(...))
async def boot(self, container: BootContainerProtocol) -> None:
svc = await container.resolve(MyProtocol)
await svc.connect()
async def shutdown(self) -> None:
await self._cleanup()
async def health_check(self, timeout: float = 5.0) -> HealthCheckResult:
return HealthCheckResult(component=self.name, status=HealthStatus.HEALTHY)
```
### Rules
- `register()` gets `ContainerRegistrarProtocol` — binds only, no resolution
- `boot()` gets `BootContainerProtocol` — may resolve AND register
- Optional hooks: `on_error(error, phase)`, `shutdown()`, `health_check(timeout)`
- No business logic on Provider classes
- All I/O in boot/shutdown is async
### Provider Pri