Skip to main content

DataMan (Data MiddleMan)

Quickstart Guide

DataMan is a dynamic, CLI-driven backend framework built on top of Django and Django REST Framework. It eliminates the boilerplate of writing standard CRUD APIs, routing, and serializers by allowing you to scaffold endpoints instantly from the command line while preserving your ability to inject custom business logic and strict validation whenever you need it.

👉 Looking to build an API in 5 minutes? Check out the Developer Quickstart Tutorial!


Features

  • Instant CRUD APIs: Automatically generate RESTful APIs from simple model definitions.
  • CLI Scaffolding: Setup projects and table structures with simple commands.
  • Hook-Based Business Logic: Inject custom logic via service.py (before_create, after_delete, etc.) without touching serializers or viewsets.
  • Validation Injection: Run custom data validators before database commits via validation.py.
  • Fine-Grained Authentication: Lock down endpoints using granular, table-and-operation specific scopes (e.g., customer:read, order:write).
  • Dynamic Routing & Pagination: Built-in DRF integration with default pagination and dynamic URL mappings.
  • Production Health Probes: Built-in /health/live/ and /health/ready/ endpoints for Kubernetes/Docker container monitoring, database vitality, and migration checks.
  • Multi-Database Routing: Organize tables by database directory (<database>/<table>) and route traffic, migrations, and health checks across isolated databases.
  • ASGI High-Concurrency Engine: Built-in uvicorn server execution mode (dataman server start --asgi) for high throughput asynchronous performance.

Installation

Ensure you have Python 3.13+ installed.

# Using uv (Recommended)
uv add dataman-engine

# Using pip
pip install dataman-engine

Quick Start

Get a full REST API running in under a minute!

1. Initialize a Project

Run the following in an empty directory to scaffold the necessary environment:

dataman init

This generates your project configuration:

my-project/
├── .env           # Environment variables & secrets
├── database.py    # Database connection & pooling (SQLite default, Postgres, MySQL)
├── config.py      # Project settings (Hosts, CORS, pagination, custom middleware)
└── tables/        # API tables & database migrations

2. Configure Database & Project Settings (Optional)

Easily customize your database backend in database.py (e.g., PostgreSQL or MySQL) and global settings in config.py:

# database.py
DATABASES = {
    "default": dj_database_url.config(
        default="postgres://user:pass@localhost:5432/my_db",
        conn_max_age=600,
    )
}

3. Create a Table

Scaffold a new table (e.g., Customer) with full CRUD operations (-o crud):

dataman create table Customer -o crud

4. Define Your Fields

Open the generated tables/Customer/models.py and define your Django fields:

from django.db import models


class Customer(models.Model):
    name = models.CharField(max_length=255)
    email = models.EmailField(unique=True)
    created_at = models.DateTimeField(auto_now_add=True)

    class Meta:
        db_table = "customer"

4. Migrate and Run

Apply the database migrations and start the server!

dataman makemigration
dataman migrate

# Start development WSGI server
dataman server start

# OR start high-concurrency production ASGI server with Uvicorn
dataman server start --asgi --host 0.0.0.0 --port 8000 --workers 4

Your API is now live at http://127.0.0.1:8000/api/customer/!


Advanced Usage

DataMan abstracts away the boring parts but leaves you full control over the important logic. Every table generated under tables/<TableName>/ comes with four critical files:

1. config.py (API Settings)

Control exactly what HTTP methods are exposed and whether the table requires authentication.

# tables/Customer/config.py
ALLOWED_OPERATIONS = ["C", "R"]  # Only allow Create (POST) and Read (GET)
REQUIRE_AUTH = True  # Lock down this endpoint
DEPTH = 1  # Automatically serialize nested Foreign Key relationships on read (GET)

# Advanced Filtering, Search & Ordering
FILTER_FIELDS = {
    "price": ["gte", "lte", "exact"],
    "name": ["icontains", "exact"],
    "is_active": ["exact"],
}  # Or simple list: ["name", "email"]
SEARCH_FIELDS = ["name", "email"]
ORDERING_FIELDS = ["created_at", "price"]

2. Authentication & Scopes

If REQUIRE_AUTH = True, clients must provide a token in the Authorization header. You can generate fine-grained access tokens directly from the CLI:

dataman users create-token MyFrontendService --scopes customer:read,customer:create

Use the token in your requests:

Authorization: Token <your_generated_token_key>

3. validation.py (Data Validation)

Validate incoming JSON payloads before they are passed to the database. Raise ValidationError to immediately return a 400 Bad Request.

# tables/Customer/validation.py
from rest_framework.exceptions import ValidationError


def validate(data):
    if "admin" in data.get("name", "").lower():
        raise ValidationError({"name": "Reserved keyword used."})

    # You can also mutate incoming data
    data["name"] = data["name"].strip().title()
    return data

4. service.py (Pre/Post Hooks)

Run business logic right before or after the database commits a transaction. Available hooks: before_create, after_create, before_update, after_update, before_destroy, after_destroy.

# tables/Customer/service.py
def before_create(data):
    # E.g., hash a password, trigger a background task, or enforce rules
    if not data.get("email"):
        raise ValueError("Email is strictly required")


def after_create(instance):
    # instance is the saved Django model object
    print(f"Successfully created customer: {instance.name}")

5. Health Checks & Readiness Probes

DataMan comes with built-in health check endpoints designed for cloud platforms, load balancers, and orchestrators (Kubernetes, AWS ECS, Docker):

  • GET /health/live/ (or /api/health/live/): Liveness probe returning 200 OK indicating the process is alive.
  • GET /health/ready/ (or /api/health/ready/): Readiness probe validating active database connection integrity and unapplied migrations (returns 200 OK or 503 Service Unavailable).
  • GET /health/ (or /api/health/): Unified health status with database latency metrics.

6. Multi-Database Architecture

Organize large projects with isolated physical databases:

my_project/
├── database.py
├── config.py
├── analytics_db/
│   ├── events/
│   │   ├── models.py
│   │   └── config.py
│   └── metrics/
│       ├── models.py
│       └── config.py
└── core_db/
    └── users/
        ├── models.py
        └── config.py
  1. Create a database:
dataman create database analytics_db
  1. Scaffold a table bound to that database:
dataman create table events --database analytics_db
  1. Run migrations across all databases (or target a single database):
dataman migrate
# or
dataman migrate --database analytics_db

Endpoints are automatically registered at both api/<table_name>/ and namespaced api/<database_name>/<table_name>/.


Testing

DataMan is rigorously tested with 95%+ branch coverage, verifying extreme edge cases, token validations, and dynamic hook executions.

To run the test suite:

uv run pytest tests/ -v

License

MIT License

Release files for dataman-engine 0.2.0

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

Source distribution (sdist)

Source distribution for dataman-engine 0.2.0
File Size Uploaded
dataman_engine-0.2.0.tar.gz 49.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dataman-engine 0.2.0
File Interpreter ABI Platform
dataman_engine-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 105.5 kB

Release files / dataman_engine-0.2.0.tar.gz

Download URL dataman_engine-0.2.0.tar.gz
Size 49.0 kB
Tags Source
SHA-256 checksum
How to use checksums
88e2ff50846c6cb687553d7f0c7f58f22bb464bcde026742d7b81c88cbdba944
BLAKE2b-256 checksum
How to use checksums
94f34cb7f808c632af7abe588badfd844aa17ca1edd375d21487c99d78b63629
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 17, 2026.

Transparency log

Release files / dataman_engine-0.2.0-py3-none-any.whl

Download URL dataman_engine-0.2.0-py3-none-any.whl
Size 56.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4ececf200dfdf4acfa708bf7d36cac13e996307e9617b0c1a5a8ba239f48f37c
BLAKE2b-256 checksum
How to use checksums
a33e7bc1bf2a67996a365bd27ebb6a5611a56f2aef10f158a427a187e7c1fadc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 17, 2026.

Transparency log

Release history Release notifications | RSS feed

0.4.0

2 release files

0.3.0

2 release files

This release

0.2.0 This release

2 release files

0.1.1

2 release files

0.1.0

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