Skip to main content

NexusDI

PyPI version Python versions PyPI - Status License: MIT

A lightweight and powerful dependency injection framework for Python

NexusDI provides elegant dependency injection with support for multiple lifecycles, automatic dependency resolution, component scanning, and circular dependency handling via lazy proxies.


✨ Key Features

  • 🔄 Multiple Lifecycles: Singleton, transient, and scoped dependencies
  • ⚡ Automatic Resolution: Type-hint based dependency resolution
  • ♻️ Circular Dependencies: Lazy proxies to handle complex graphs
  • 🔍 Component Scanning: Auto-discovery of decorated components
  • 🧵 Thread-Safe: Reliable for concurrent applications
  • 💡 Lightweight: Minimal overhead with maximum flexibility

🚀 Quick Example

from nexusdi import singleton, transient, inject, initialize

@singleton
class DatabaseService:
    def __init__(self):
        self.connection = "database_connection"

@transient
class UserRepository:
    def __init__(self, db_service: DatabaseService):
        self.db = db_service

    def get_user(self, user_id: int):
        return f"User {user_id} from {self.db.connection}"

@inject
def get_user_data(user_repo: UserRepository, user_id: int = 1):
    return user_repo.get_user(user_id)

# Initialize the DI system
initialize()

# Dependencies are automatically injected
result = get_user_data(user_id=123)
print(result)  # "User 123 from database_connection"

📦 Installation

Install NexusDI with pip:

pip install nexusdi

Or with poetry:

poetry add nexusdi

🎯 Core Concepts

Lifecycles

  • singleton: A single instance for the application lifetime
  • transient: A new instance per request
  • scoped: Shared within a defined scope

Injection

  • Use @inject on functions to resolve dependencies automatically

Scanning

  • Decorate classes to enable automatic component discovery

Circular Dependencies

  • NexusDI resolves circular graphs via lazy proxies


🤝 Contributing

Contributions are welcome! Please feel free to open an issue or submit a Pull Request.


📄 License

This project is licensed under the MIT License – see the LICENSE file for details.


👤 Author

Harrison Alonso Arroyave Gaviria

Metadata

Release files for nexusdi 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nexusdi 0.0.1
File Size Uploaded
nexusdi-0.0.1.tar.gz 13.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for nexusdi 0.0.1
File Interpreter ABI Platform
nexusdi-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 28.9 kB

Release files / nexusdi-0.0.1.tar.gz

Download URL nexusdi-0.0.1.tar.gz
Size 13.6 kB
Tags Source
SHA-256 checksum
How to use checksums
e0917202c55a859d2c9e5ff37e57a3d93ed246856b1f4e9d318ff4e98d8d0901
BLAKE2b-256 checksum
How to use checksums
cc796c340e75b9e1ae108b944ee27f9cdcdd4df0276dce4824126c6c0778f627
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.9

Release files / nexusdi-0.0.1-py3-none-any.whl

Download URL nexusdi-0.0.1-py3-none-any.whl
Size 15.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
561a26f3d442dd82fd8ba39dc01bf04949016cf69403363aaf317fbffede4fd9
BLAKE2b-256 checksum
How to use checksums
1dcea6cd7a197f27842e63ffb21bc49e5d0201743ff6eb9cc728cdaf1106f5ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.9

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page