Documentation
Typed dependency injection for small Python apps.
Injex wires services, CLIs, workers, and tests with regular Python type hints, explicit registrations, scoped lifetimes, overrides, and startup validation.
Start
Getting started
Install, register services, validate the graph, resolve use cases.
Safety
Graph validation
Find missing registrations and cycles before services are built.
Decision
Comparison guide
Choose between manual wiring, framework DI, Injex, and larger containers.
Speed
Performance notes
Benchmark shape, local results, and reproduction command.
Boundary
Compared to FastAPI Depends
Use FastAPI at the HTTP edge and keep app wiring reusable.
Async
Async resolution
Async factories, async-resource lifecycles, and per-request async scopes.
Trade-offs
Compared to DI frameworks
Manual wiring, Injex, Wireup, Dishka, and dependency-injector.
Recipes
Application wiring recipes
FastAPI composition root, worker job scope, CLI commands, and test overrides.
Migration
Migrating from factories
Move a hand-written factories.py to Injex without changing application classes.
Reference
API reference
Container methods, scopes, overrides, validation, and exceptions.
Guide
Python dependency injection
Understand when DI helps in Python and how Injex stays small.
Article
Why tiny Python DI
An article about explicit wiring for Python services.
Hashnode
Where should dependency wiring live?
FastAPI, Typer, workers, tests, and the app composition root.
DEV
Fast dependency injection in Python
Injex 1.3.0, benchmark context, and framework boundaries.
Install
pip install injex
Best fit
- Service layers reused by API handlers, CLIs, workers, and tests.
- Clean architecture code that should not depend on a web framework.
- Tests that need temporary dependency overrides.
- Startup checks that should validate the dependency graph early.
Rule of thumb: keep container calls at the composition root. Application services should depend on normal Python types.