Skip to main content

Standardized service layer and data processing abstractions for Django applications.

Project description

django-manager

PyPI version Python versions Django versions License: MIT

Standardized service layer and data processing abstractions for Django applications.

django-manager provides a collection of reusable patterns, middleware, and utilities that help you build well-structured Django REST APIs without reinventing the wheel on every project.


Features

  • Service Layer Abstractions — Decouple business logic from views using a clean service-oriented architecture.
  • Pipeline Engine — Build composable data processing pipelines with built-in error handling and branching support.
  • Adapter Registry — Plug-and-play adapter pattern with health monitoring, circuit breakers, and async support.
  • Schema Validation — Lightweight schema definitions, migration helpers, and backward-compatibility checks.
  • Transport Layer — Unified transport abstraction with connection pooling, retries, and metrics collection.
  • Event Emitters — In-process event bus with filtering, async dispatch, history tracking, and replay.
  • Worker Toolkit — Task queue, worker pools, retry policies, and result backends for background processing.
  • Connector Framework — Managed external service connectors with health checks, pooling, and factory pattern.
  • Codec Support — Pluggable serialization with content negotiation, streaming, and integrity verification.

Quick Start

Installation

pip install django-manager

Add to your Django project

# settings.py
INSTALLED_APPS = [
    ...
    "django_manager.fabric",
]

Basic Pipeline Example

from django_manager.pipeline import PipelineEngine, Stage

class ValidateInput(Stage):
    name = "validate"

    def process(self, data, context):
        if "email" not in data:
            raise ValueError("Email is required")
        return data

class NormalizeData(Stage):
    name = "normalize"

    def process(self, data, context):
        data["email"] = data["email"].strip().lower()
        return data

engine = PipelineEngine()
engine.add_stage(ValidateInput())
engine.add_stage(NormalizeData())

result = engine.execute({"email": "  User@Example.COM  "})
# {"email": "user@example.com"}

Adapter Pattern

from django_manager.adapters import AdapterRegistry, BaseAdapter

class EmailAdapter(BaseAdapter):
    name = "email"

    def execute(self, **kwargs):
        # send email logic
        return {"status": "sent", "to": kwargs["recipient"]}

registry = AdapterRegistry()
registry.register(EmailAdapter())

response = registry.get("email").execute(recipient="user@example.com")

Event Bus

from django_manager.emitters import EventBus

bus = EventBus()

@bus.on("user.created")
def send_welcome(event, **kwargs):
    print(f"Welcome {kwargs['username']}!")

bus.emit("user.created", username="alice")

Schema Validation

from django_manager.schema import SchemaBuilder

schema = (
    SchemaBuilder("UserInput")
    .string("username", required=True)
    .string("email", required=True)
    .integer("age")
    .build()
)

Architecture

django_manager/
├── adapters/       # Adapter pattern with registry, monitoring, policies
├── pipeline/       # Composable data processing pipelines
├── codecs/         # Serialization, compression, content negotiation
├── transport/      # HTTP transport, pooling, retries, metrics
├── workers/        # Task queue, scheduling, result backends
├── emitters/       # Event bus, filtering, async dispatch
├── connectors/     # External service connectors with health checks
├── schema/         # Schema definitions, validation, migrations
├── fabric/         # REST API toolkit (views, serializers, auth)
├── scaffold/       # Project configuration helpers
├── resolvers/      # Data resolution and content processing
├── dispatchers/    # Request dispatching and routing logic
└── providers/      # Authentication and identity providers

Configuration

django-manager can be configured via Django settings:

# settings.py
DJANGO_MANAGER = {
    "DEFAULT_PAGINATION_SIZE": 25,
    "TRANSPORT_TIMEOUT": 30.0,
    "TRANSPORT_MAX_RETRIES": 3,
    "WORKER_POOL_SIZE": 4,
    "EVENT_HISTORY_SIZE": 10000,
    "ADAPTER_CIRCUIT_BREAKER_THRESHOLD": 5,
}

Requirements

  • Python ≥ 3.12
  • Django ≥ 6.0
  • Django REST Framework ≥ 3.16

Changelog

1.3.2 (2026-02-14)

  • Fixed schema backward-compatibility check for optional→required field transitions
  • Improved transport retry budget token replenishment logic

1.3.1 (2026-02-01)

  • Added AsyncBatchConnector for concurrent connector operations
  • Fixed EventHistory.replay() ordering when using since parameter

1.3.0 (2026-01-18)

  • New schema package with validation, migration, and diff support
  • Added emitters.history module for event recording and replay
  • Transport metrics now include p99 latency tracking

1.2.0 (2025-12-20)

  • Connector framework with health checks, pooling, and factory pattern
  • Worker result backends (in-memory, file-based)
  • Added pipeline.branches for conditional and parallel stages

1.1.0 (2025-11-15)

  • Event emitter system with async bus, filters, and decorators
  • Worker task queue with priority scheduling
  • Transport middleware chain support

1.0.0 (2025-10-01)

  • Initial stable release
  • Pipeline engine, adapter registry, codec layer
  • REST API fabric with token auth and custom pagination

License

MIT License — see LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_manager-1.3.4.tar.gz (64.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_manager-1.3.4-py3-none-any.whl (102.1 kB view details)

Uploaded Python 3

File details

Details for the file django_manager-1.3.4.tar.gz.

File metadata

  • Download URL: django_manager-1.3.4.tar.gz
  • Upload date:
  • Size: 64.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.13.0 Darwin/25.0.0

File hashes

Hashes for django_manager-1.3.4.tar.gz
Algorithm Hash digest
SHA256 c49da7d92985caee9aad334ae9596f190714f2d73f871be85fafb3f5d4dfa2d9
MD5 aebc9a46de72d51092a5fb234c2b6342
BLAKE2b-256 c9154822d7dac3b752287b332559a631c4514eefbcdf4029148cd956e539cf52

See more details on using hashes here.

File details

Details for the file django_manager-1.3.4-py3-none-any.whl.

File metadata

  • Download URL: django_manager-1.3.4-py3-none-any.whl
  • Upload date:
  • Size: 102.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.13.0 Darwin/25.0.0

File hashes

Hashes for django_manager-1.3.4-py3-none-any.whl
Algorithm Hash digest
SHA256 906c6e67bb168ec780d807909790e02604fba06fe0b97b44a83962cfc03a8ec7
MD5 e209a371f7ee6424b1747d738697a4a1
BLAKE2b-256 97eedfff182c0282868bca5485176140b7361d6a042b9bf2f73794b6e67114c7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page