Type-safe dependency injection
Lightweight, modular dependency injection for TypeScript services, AI agents, and WebAssembly workloads on Bun, Node.js, and Cloudflare Workers.
Documentation · Get Started · GitHub
Install: bun x @di-framework/cli init
Capabilities
- Core DI Container — Singleton and transient scopes, decorator lifecycle, and emit-time parameter checks from TypeScript types.
- HTTP & OpenAPI — Declarative @Controller routes, @Endpoint metadata, and build-time OpenAPI 3.1 documents.
- Schema codegen — Versioned schema manifests become HTTP controllers, event bridges, and opt-in RPC services and AI tools.
- WebAssembly platform — Build WASI HTTP components, deploy them with di-framework platform, and operate a tenant from the local console.
- AI agents — Chat, tools, RAG, MCP, and agents, plus Agent Skills and the di-ml ONNX trainer.
- Auto GraphQL — Generate GraphQL schemas from decorated TypeScript domain objects and resolver classes.
- Event messaging — Bridge container events across Kafka, NATS, or in-memory buses with @Subscriber().
- Auth & WebAuthn — JWT sessions, OAuth2/OIDC, and WebAuthn passkeys on WebCrypto.
Specialized packages
- @di-framework/core — Singleton & transient scopes, decorator lifecycle, and compile-time type-safe resolution.
- @di-framework/cli — Scaffold projects and install command groups, including the platform and AI extensions.
- @di-framework/http — Declarative @Controller routes, @Endpoint metadata, and OpenAPI 3.1 generation.
- @di-framework/codegen — Generate HTTP, event, RPC, and tool surfaces from versioned schema manifests.
- @di-framework/graphql — Auto-generate GraphQL schemas from decorated domain objects and resolvers.
- @di-framework/events — Bridge container events across Kafka, NATS, or in-memory buses with @Subscriber().
- @di-framework/queues — Durable jobs with at-least-once delivery, retries, and dead-letter inspection.
- @di-framework/actors — Local virtual actors with serialized mailboxes and typed references.
- @di-framework/auth — JWT sessions, OAuth2/OIDC providers, and WebAuthn passkey assertions.
- @di-framework/authz — Policy-based authorization guards that plug into the DI container lifecycle.
- @di-framework/config — Typed configuration loading with env overrides and validated runtime schemas.
- @di-framework/socket — Encrypted WebSocket, TCP, and UDP channels via ECDH & AES-GCM WebCrypto.
- @di-framework/rpc — Type-safe remote procedure calls between services with container-aware clients.
- @di-framework/ai — Injectable model providers, tooling hooks, and streaming inference helpers.
- @di-framework/ai-utils — Agent Skills (SKILL.md), jailed file tools, todos, and opt-in Write / Edit / Bash.
- @di-framework/ml — ONNX Runtime inference for a di-ml checkpoint, with prebuilt trainer CLIs.
- @di-framework/cli-plugin-ai — Agent configuration and Agent Skills commands under di-framework ai.
- @di-framework/cli-plugin-platform — Build WASI components, deploy workloads, and open the local tenant console.
- @di-framework/platform — Pulumi cluster install for wasmCloud: tenancy, backing services, and the operator.
- @di-framework/bindings — Guest bindings for Postgres, key-value, messaging, config, and secrets on the platform host.
- @di-framework/repo — Repository pattern adapters for persistence with DI-managed unit-of-work scopes.
Directory, OAuth clients, and audit are incubating in the identity-server repository.