Skip to content

epic: Production-Ready Developer Experience Improvements #336

@mikelane

Description

@mikelane

Vision

Transform dioxide from a functional DI framework into a production-ready, net-promoter-score-worthy library that developers actively recommend. This epic addresses the key gaps identified through developer feedback that prevent dioxide from being "production-ready."

The Problem

dioxide v1.0 delivers on the core MLP promise (making DIP feel inevitable), but real-world production usage reveals six critical DX gaps:

Gap Impact User Pain
Config injection unclear Adapters have hidden Settings() dependencies "How do I inject config INTO my adapters?"
No request scope Can't do per-request DB sessions, user context "Not production-ready for web apps"
Sync-only lifecycle Real adapters need async init (pools, clients) "I can't use async setup for my Redis client"
Unhelpful error messages "No adapter found" with no context "I have no idea what went wrong"
Tedious fake creation Hand-write every fake implementation "So much boilerplate for testing"
No introspection Can't see what's registered or debug resolution "How do I debug my wiring?"

Success Criteria

  • Config objects can be injected into adapters without hidden imports
  • REQUEST scope works with FastAPI and Flask request lifecycle
  • Async initialize() and dispose() methods fully supported
  • Error messages show registered adapters, current profile, and fix suggestions
  • Base classes exist for common fake patterns (InMemoryRepository, FakeClock, etc.)
  • container.debug(), container.explain(Port), and container.graph() available
  • All features have documentation with examples
  • All features have comprehensive tests

Out of Scope

  • IDE/LSP integration
  • CLI code generators
  • AOP/interceptors (post-MLP)
  • XML/YAML configuration

Sub-Issues

P0: Request Scoping (Blocking for production web apps)

P1: Async Lifecycle (Blocking for real infrastructure adapters)

P1: Better Error Messages (High-impact, low-effort DX win)

P2: Config Injection (Common pain point)

P2: Container Introspection (Essential for debugging)

P3: Fake Helpers (Nice-to-have, reduces boilerplate)

Story Structure

Each improvement area is broken into stories that prevent shortcuts:

  1. API/Interface Story - Define the public API (acceptance: mypy passes)
  2. Implementation Story - Core logic (blocked by API story)
  3. Integration Story - Wire into existing systems (blocked by implementation)
  4. Documentation Story - Docs and examples (blocked by integration)

Technical Approach

1. Config Injection

Make Pydantic Settings (or any config class) first-class citizens that can be injected via constructor parameters, eliminating hidden Settings() calls inside adapters.

2. Request Scoping

Add Scope.REQUEST that integrates with web framework middleware to provide per-request instances that are automatically cleaned up.

3. Async Lifecycle

The @lifecycle decorator already validates async methods. This work ensures the container properly awaits them during start() and stop().

4. Better Error Messages

Enrich AdapterNotFoundError and ServiceNotFoundError with:

  • List of registered adapters for the port
  • Current active profile
  • Suggested fixes with code examples

5. Fake Helpers

Provide reusable base classes:

  • InMemoryRepository[T] - Generic CRUD fake
  • FakeClock - Controllable time
  • FakeEventBus - Captured events
  • FakeHttpClient - Recorded requests

6. Container Introspection

Add debugging methods:

  • container.debug() - Print registered components
  • container.explain(Type) - Show resolution chain
  • container.graph() - Return dependency graph (Mermaid format)

Links

  • MLP Vision: docs/MLP_VISION.md
  • Testing Guide: docs/TESTING_GUIDE.md
  • Current Scope Implementation: python/dioxide/scope.py
  • Current Lifecycle: python/dioxide/lifecycle.py
  • Current Exceptions: python/dioxide/exceptions.py

Sub-issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: dxDeveloper experienceepicEpic issue that tracks multiple related sub-issuespriority: highHigh prioritytype: featureNew feature or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions