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.3.tar.gz (64.3 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.3-py3-none-any.whl (101.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: django_manager-1.3.3.tar.gz
  • Upload date:
  • Size: 64.3 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.3.tar.gz
Algorithm Hash digest
SHA256 f3b6a2c4e4166d66bcc9c8edb72adabf79d4b5abe8d0bab908c86e0b99f36734
MD5 655767bf31bbc78fbfdb9476a4e1780e
BLAKE2b-256 fe63ce3235bebe7c9f6a696953f8e450a4bf6269d604ba69b417852dbde6cc79

See more details on using hashes here.

File details

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

File metadata

  • Download URL: django_manager-1.3.3-py3-none-any.whl
  • Upload date:
  • Size: 101.9 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f9bb597f512d69bd45464f2e0b18c83a4dc9e616181a24446025aa183d858be9
MD5 57e4b4105ee01c9b4d1a78d62bf388d9
BLAKE2b-256 eaad9cf0568c2e8bbd1b8ebed5315be87c373e2d305f81d55375366d65f87a00

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