Home¶
Drop the beat on your dependencies.
dijay is the "remix" your architecture needs: NestJS-style modularity, native async performance, and rigorous typing for Python 3.13+. Less boilerplate, more harmony.
Features¶
- Modular Architecture — Organize code into
@modules withimports,providers, andexports. - Constructor Injection — Clean, testable injection via
__init__andAnnotated. - Flexible Scopes —
SINGLETON,TRANSIENT, andREQUEST. - Async Native — First-class support for asynchronous factories and lifecycle hooks.
- Custom Providers —
Providedataclass for value, class and factory bindings. - Lifecycle Hooks —
@on_bootstrapand@on_shutdowndecorators. - Circular Dependency Detection — Immediate
RuntimeErroron cycles.
Quick Example¶
import asyncio
from dijay import Container, injectable, module
@injectable()
class CatsService:
def get_all(self):
return ["Meow", "Purr"]
@module(providers=[CatsService], exports=[CatsService])
class CatsModule: ...
@module(imports=[CatsModule])
class AppModule: ...
async def main():
async with Container.from_module(AppModule) as container:
service = await container.resolve(CatsService)
print(service.get_all())
if __name__ == "__main__":
asyncio.run(main())
Next Steps¶
- Getting Started — Install and create your first app
- Modules — Organize your architecture
- Providers — Custom bindings with
Provide - Lifecycle Hooks — Bootstrap and shutdown hooks
- FastAPI — Integrate with FastAPI
- API Reference — Full API documentation