Quickstart
Install the package:
uv add lexigram-tenancyMinimal example
Section titled “Minimal example”import asynciofrom lexigram.app import Applicationfrom lexigram.tenancy import TenancyModule, TenancyConfig
async def main() -> None: config = TenancyConfig() app = Application(name="my-app") app.add_module(TenancyModule.configure(config=config)) async with Application.boot(name="my-app", modules=[TenancyModule.configure(config=config)]) as app: from lexigram.contracts.tenancy.protocols import TenantProviderProtocol
provider = await app.container.resolve(TenantProviderProtocol) result = await provider.create_tenant( CreateTenantCommand(slug="acme", name="ACME Corp") ) if result.is_ok(): tenant = result.unwrap() print(f"Created tenant: {tenant.tenant_id}")
asyncio.run(main())What just happened
Section titled “What just happened”TenancyModule.configure()registered the tenancy provider stack (resolution chain, validator, lifecycle service, isolation strategies)- The
TenantProviderProtocolwas resolved from the container — backed byInMemoryTenantProviderby default - A tenant was created with slug
acmeand nameACME Corp
Next steps
Section titled “Next steps”- Guide — mental model, resolution chain, isolation strategies
- Architecture — provider composition, contracts, lifecycle
- Configuration — resolver order, TTLs, integration toggles
- How-Tos — custom resolvers, SQL backend, per-tenant config overrides