Quickstart
Get up and running with Lexigram in under 5 minutes.
Install
Section titled “Install”uv add lexigram# orpip install lexigramlexigram-contracts (the zero-dependency protocol layer) is installed automatically as a dependency.
Minimal Application
Section titled “Minimal Application”The Application class is the composition root. Pair it with a Provider to register and wire services:
from __future__ import annotations
import asynciofrom lexigram import Application, ProviderPriorityfrom lexigram.contracts.core.di import ( BootContainerProtocol, ContainerRegistrarProtocol,)from lexigram.di.provider import Provider
class Greeter: def hello(self) -> str: return "Hello, Lexigram!"
class AppProvider(Provider): name = "app" priority = ProviderPriority.APPLICATION
async def register(self, container: ContainerRegistrarProtocol) -> None: container.singleton(Greeter, Greeter())
async def boot(self, container: BootContainerProtocol) -> None: greeter = await container.resolve(Greeter) print(greeter.hello())
async def main() -> None: async with Application.boot(providers=[AppProvider()]) as app: print(f"App running: {app.is_running}")
asyncio.run(main())App running: TrueHello, Lexigram!What Just Happened
Section titled “What Just Happened”| Step | Description |
|---|---|
Application.boot() | Creates the app, registers providers, freezes the container, boots providers |
AppProvider.register() | Binds Greeter as a singleton in the DI container |
AppProvider.boot() | Resolves Greeter from the container — resolution is now safe |
| Context manager exit | Shuts down providers in reverse order and disposes the container |
Next Steps
Section titled “Next Steps”- Guide — core concepts, typical usage, common patterns
- Architecture — layers, lifecycle, extension points
- Configuration — YAML, env vars, profiles
- How-Tos — task-oriented recipes