django-revolution


Namedjango-revolution JSON
Version 1.0.8 PyPI version JSON
download
home_pagehttps://unrealos.com
SummaryZone-based API architecture for Django. Install and go.
upload_time2025-07-12 03:04:48
maintainerNone
docs_urlNone
authorUnrealos
requires_python>=3.9
licenseNone
keywords django api openapi rest zones typescript python client generation
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Django Revolution

> **Zero-config TypeScript & Python client generator for Django REST Framework** ๐Ÿš€

[![PyPI version](https://badge.fury.io/py/django-revolution.svg)](https://badge.fury.io/py/django-revolution)
[![Python Support](https://img.shields.io/pypi/pyversions/django-revolution.svg)](https://pypi.org/project/django-revolution/)
[![Django Support](https://img.shields.io/pypi/djversions/django-revolution.svg)](https://pypi.org/project/django-revolution/)
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT)

## โœจ What is Django Revolution?

**The fastest way to generate fully-authenticated TypeScript + Python clients from Django REST Framework.**

- ๐Ÿงฉ Organize your API into **zones** (`public`, `admin`, `mobile`, etc.)
- โš™๏ธ Generate strongly typed clients with **one command**
- ๐Ÿ” Built-in support for **Bearer tokens**, refresh logic, and API keys
- ๐Ÿ”„ Zero config for **Swagger/OpenAPI URLs**, **frontend integration**, and **monorepos**
- ๐ŸŽฏ **Optional monorepo integration** - works with or without monorepo structure

> No boilerplate. No manual sync. Just clean clients in seconds.

## ๐Ÿงช Example: Instantly Get a Typed API Client

```typescript
import API from '@myorg/api-client';

const api = new API('https://api.example.com');
api.setToken('your-access-token');

const profile = await api.public.getProfile();
const items = await api.public.listItems();
```

> ๐Ÿ” Auth, โš™๏ธ Headers, ๐Ÿ”„ Refresh โ€“ handled automatically.

## โ›” Without Django Revolution

Manually update OpenAPI spec โ†’ Run generator โ†’ Fix broken types โ†’ Sync clients โ†’ Write token logic โ†’ Repeat on every change.

## โœ… With Django Revolution

One command. Done.

## ๐ŸŽฏ **Ready-to-Use Pydantic Configs**

**No more manual configuration!** Django Revolution provides **pre-built, typed configurations**:

### **DRF + Spectacular Config**

```python
from django_revolution.drf_config import create_drf_config

# One function call - everything configured!
drf_config = create_drf_config(
    title="My API",
    description="My awesome API",
    version="1.0.0",
    schema_path_prefix="/api/",
    enable_browsable_api=False,
    enable_throttling=True,
)

# Get Django settings
settings = drf_config.get_django_settings()
REST_FRAMEWORK = settings['REST_FRAMEWORK']
SPECTACULAR_SETTINGS = settings['SPECTACULAR_SETTINGS']
```

### **Zone Configuration**

```python
from django_revolution.app_config import ZoneConfig, get_revolution_config

# Typed zone definitions
zones = {
    'public': ZoneConfig(
        apps=['accounts', 'billing', 'payments', 'support', 'public'],
        title='Public API',
        description='API for public client applications',
        public=True,
        auth_required=False,
        version='v1',
        path_prefix='public'
    ),
    'internal': ZoneConfig(
        apps=['system', 'mailer'],
        title='Internal API',
        description='Internal API for backend services',
        public=False,
        auth_required=True,
        version='v1',
        path_prefix='internal'
    ),
    'admin': ZoneConfig(
        apps=['admin_panel', 'services'],
        title='Admin API',
        description='Administrative API endpoints',
        public=False,
        auth_required=True,
        version='v1',
        path_prefix='admin'
    )
}

# Option 1: Without monorepo (simplest)
config = get_revolution_config(project_root=Path.cwd(), zones=zones)

# Option 2: With monorepo integration
from django_revolution.app_config import MonorepoConfig
monorepo = MonorepoConfig(
    enabled=True,
    path=str(Path.cwd().parent / 'monorepo'),
    api_package_path='packages/api/src'
)
config = get_revolution_config(project_root=Path.cwd(), zones=zones, monorepo=monorepo)
```

**Benefits:**

- โœ… **Type-safe** - Full Pydantic validation
- โœ… **Zero boilerplate** - Pre-configured defaults
- โœ… **Environment-aware** - Auto-detects paths and settings
- โœ… **IDE support** - Autocomplete and error checking
- โœ… **Production-ready** - Optimized for client generation
- โœ… **Flexible** - Works with or without monorepo

## ๐Ÿš€ 5-Minute Setup

### 1. Install

```bash
pip install django-revolution
```

### 2. Add to Django Settings

```python
# settings.py
INSTALLED_APPS = [
    'drf_spectacular',
    'django_revolution',  # Add this line
]
```

### 3. **Easy Configuration with Ready-to-Use Configs** ๐ŸŽฏ

Django Revolution provides **pre-built Pydantic configurations** that you can import and use directly:

#### **DRF + Spectacular Configuration** (services.py)

```python
# api/settings/config/services.py
from django_revolution.drf_config import create_drf_config

class SpectacularConfig(BaseModel):
    """API documentation configuration using django_revolution DRF config."""

    title: str = Field(default='API')
    description: str = Field(default='RESTful API')
    version: str = Field(default='1.0.0')
    schema_path_prefix: str = Field(default='/apix/')
    enable_browsable_api: bool = Field(default=False)
    enable_throttling: bool = Field(default=False)

    def get_django_settings(self) -> Dict[str, Any]:
        """Get drf-spectacular settings using django_revolution config."""
        # Use django_revolution DRF config - zero boilerplate!
        drf_config = create_drf_config(
            title=self.title,
            description=self.description,
            version=self.version,
            schema_path_prefix=self.schema_path_prefix,
            enable_browsable_api=self.enable_browsable_api,
            enable_throttling=self.enable_throttling,
        )

        return drf_config.get_django_settings()
```

#### **Zone Configuration** (revolution.py)

```python
# api/settings/config/revolution.py
from django_revolution.app_config import (
    DjangoRevolutionConfig,
    ZoneConfig,
    MonorepoConfig,
    get_revolution_config
)

def create_revolution_config(env) -> Dict[str, Any]:
    """Get Django Revolution configuration as dictionary."""

    # Define zones with typed Pydantic models
    zones = {
        'public': ZoneConfig(
            apps=['accounts', 'billing', 'payments', 'support', 'public'],
            title='Public API',
            description='API for public client applications',
            public=True,
            auth_required=False,
            version='v1',
            path_prefix='public'
        ),
        'internal': ZoneConfig(
            apps=['system', 'mailer'],
            title='Internal API',
            description='Internal API for backend services',
            public=False,
            auth_required=True,
            version='v1',
            path_prefix='internal'
        ),
        'admin': ZoneConfig(
            apps=['admin_panel', 'services'],
            title='Admin API',
            description='Administrative API endpoints',
            public=False,
            auth_required=True,
            version='v1',
            path_prefix='admin'
        )
    }

    # Option 1: Without monorepo (simplest setup)
    project_root = env.root_dir
    return get_revolution_config(project_root=project_root, zones=zones, debug=env.debug)

    # Option 2: With monorepo integration
    # monorepo = MonorepoConfig(
    #     enabled=True,
    #     path=str(env.root_dir.parent / 'monorepo'),
    #     api_package_path='packages/api/src'
    # )
    # return get_revolution_config(project_root=project_root, zones=zones, debug=env.debug, monorepo=monorepo)
```

### 4. Generate Clients

```bash
# Generate everything
python manage.py revolution

# Generate specific zones
python manage.py revolution --zones client admin

# TypeScript only
python manage.py revolution --typescript

# Without monorepo sync
python manage.py revolution --no-monorepo
```

## ๐Ÿงฌ What Does It Generate?

| Language       | Location                      | Structure                                                 |
| -------------- | ----------------------------- | --------------------------------------------------------- |
| **TypeScript** | `openapi/clients/typescript/` | `public/`, `admin/` โ†’ `index.ts`, `types.ts`, `services/` |
| **Python**     | `openapi/clients/python/`     | `public/`, `admin/` โ†’ `client.py`, `models/`, `setup.py`  |

๐Ÿ’ก Each zone gets its own NPM/PyPI-style package. Ready to publish or import.

## โšก๏ธ TypeScript Client Auth & Usage

Django Revolution automatically generates a smart TypeScript API client with built-in authentication and token management:

- **Zone-based organization** - All endpoints grouped by zones (client, admin, internal, etc.)
- **Authentication ready** - Bearer tokens, refresh tokens, custom headers out of the box
- **Simple integration** - Works with React, Next.js, Vue, or any frontend framework
- **Type-safe** - Full TypeScript support with autocomplete

**Example Usage:**

```typescript
import API from '@myorg/api-client';

const api = new API('https://api.example.com');

// Authentication
api.setToken('your-access-token', 'your-refresh-token');

// Call any endpoint
const user = await api.public.getCurrentUser();
const products = await api.public.listProducts();

// Check authentication status
if (api.isAuthenticated()) {
  // User is logged in
}

// Change API URL
api.setApiUrl('https://api.newhost.com');
```

**Features included:**

- โœ… Automatic token management (localStorage)
- โœ… Custom headers support
- โœ… API key authentication
- โœ… Zone-based endpoint organization
- โœ… TypeScript types for all endpoints
- โœ… Error handling and validation

> **No need to write authentication logic - everything is handled automatically!**

## ๐ŸŒ Auto-Generated URLs

Django Revolution **automatically generates** all necessary URLs for your API zones:

```python
# urls.py
from django_revolution import add_revolution_urls

urlpatterns = [
    # Your existing URLs
    path('admin/', admin.site.urls),
]

# Django Revolution automatically adds:
# - /api/public/schema/ (Swagger UI)
# - /api/public/schema.yaml (OpenAPI spec)
# - /api/admin/schema/ (Swagger UI)
# - /api/admin/schema.yaml (OpenAPI spec)
# - /openapi/archive/ (Generated clients)
urlpatterns = add_revolution_urls(urlpatterns)
```

**Generated URLs:**

- `/api/{zone}/schema/` - Interactive Swagger UI
- `/api/{zone}/schema.yaml` - OpenAPI specification
- `/openapi/archive/` - Download generated clients

## ๐Ÿงช CLI Toolbox

### Django Management Commands

```bash
# Generate all clients
python manage.py revolution

# Specific zones
python manage.py revolution --zones public admin

# Generator options
python manage.py revolution --typescript
python manage.py revolution --python
python manage.py revolution --no-archive

# Monorepo options
python manage.py revolution --no-monorepo

# Utility commands
python manage.py revolution --status
python manage.py revolution --list-zones
python manage.py revolution --validate
python manage.py revolution --clean
```

### Standalone CLI (Interactive)

```bash
# Interactive CLI with rich interface
django-revolution

# Or run directly
python -m django_revolution.cli
```

The standalone CLI provides an interactive interface with:

- ๐ŸŽฏ Zone selection with checkboxes
- ๐Ÿ”ง Client type selection (TypeScript/Python)
- ๐Ÿ“ฆ Archive creation options
- ๐Ÿ“Š Real-time progress tracking
- โœ… Generation summary with results table

## ๐Ÿช† Monorepo Integration (Optional)

Django Revolution **optionally integrates** with your monorepo:

### With Monorepo

```python
# settings.py - With monorepo integration
from django_revolution.app_config import MonorepoConfig

monorepo = MonorepoConfig(
    enabled=True,
    path=str(BASE_DIR.parent.parent / 'monorepo'),
    api_package_path='packages/api/src'
)

DJANGO_REVOLUTION = get_revolution_config(
    project_root=BASE_DIR,
    zones=zones,
    monorepo=monorepo
)
```

**Auto-generated monorepo structure:**

```yaml
# pnpm-workspace.yaml (auto-generated)
packages:
  - 'packages/**'
  - 'packages/api/**' # Added automatically
```

**Package.json dependencies:**

```json
{
  "dependencies": {
    "@markolofsen/public-api-client": "workspace:*",
    "@markolofsen/admin-api-client": "workspace:*"
  }
}
```

### Without Monorepo

```python
# settings.py - Without monorepo (simplest)
DJANGO_REVOLUTION = get_revolution_config(
    project_root=BASE_DIR,
    zones=zones
)
```

**Generated locally:**

- `openapi/clients/typescript/` - TypeScript clients
- `openapi/clients/python/` - Python clients
- `openapi/archive/` - Versioned archives

## ๐Ÿ”ง Configuration

### **Easy Configuration with Ready-to-Use Configs** ๐ŸŽฏ

Django Revolution provides **pre-built Pydantic configurations** that eliminate manual setup:

#### **1. DRF + Spectacular Configuration**

```python
# api/settings/config/services.py
from django_revolution.drf_config import create_drf_config

# One function call - everything configured!
drf_config = create_drf_config(
    title="My API",
    description="My awesome API",
    version="1.0.0",
    schema_path_prefix="/api/",
    enable_browsable_api=False,
    enable_throttling=True,
)

# Get Django settings
settings = drf_config.get_django_settings()
REST_FRAMEWORK = settings['REST_FRAMEWORK']
SPECTACULAR_SETTINGS = settings['SPECTACULAR_SETTINGS']
```

#### **2. Zone Configuration**

```python
# api/settings/config/revolution.py
from django_revolution.app_config import ZoneConfig, get_revolution_config

# Typed zone definitions with Pydantic models
zones = {
    'public': ZoneConfig(
        apps=['accounts', 'billing', 'payments'],
        title='Public API',
        description='API for public client applications',
        public=True,
        auth_required=False,
        version='v1',
        path_prefix='public'
    ),
    'admin': ZoneConfig(
        apps=['admin_panel', 'analytics'],
        title='Admin API',
        description='Administrative API endpoints',
        public=False,
        auth_required=True,
        version='v1',
        path_prefix='admin'
    )
}

# Option 1: Without monorepo (simplest)
config = get_revolution_config(project_root=Path.cwd(), zones=zones)

# Option 2: With monorepo integration
from django_revolution.app_config import MonorepoConfig
monorepo = MonorepoConfig(
    enabled=True,
    path=str(Path.cwd().parent / 'monorepo'),
    api_package_path='packages/api/src'
)
config = get_revolution_config(project_root=Path.cwd(), zones=zones, monorepo=monorepo)
```

### **Legacy Configuration** (for backward compatibility)

#### Environment Variables

```bash
export DJANGO_REVOLUTION_DEBUG=true
export DJANGO_REVOLUTION_API_PREFIX=apix
export DJANGO_REVOLUTION_AUTO_INSTALL_DEPS=true
```

#### Manual Zone Configuration

```python
'zones': {
    'zone_name': {
        'apps': ['app1', 'app2'],           # Required
        'title': 'Human Readable Title',    # Optional
        'description': 'Zone description',  # Optional
        'public': True,                     # Optional
        'auth_required': False,             # Optional
        'rate_limit': '1000/hour',          # Optional
        'permissions': ['perm1', 'perm2'],  # Optional
        'version': 'v1',                    # Optional
        'prefix': 'custom_prefix',          # Optional
        'cors_enabled': False,              # Optional
    }
}
```

## โœ… When to Use

### โœ… Perfect For

- **Large Django projects** with multiple API audiences
- **Monorepo architectures** with frontend/backend separation
- **Teams** needing consistent API client generation
- **Projects** requiring zone-based API organization
- **Automated CI/CD** pipelines
- **Simple projects** without monorepo (optional integration)

### โŒ Not For

- **Simple single-zone APIs** (overkill)
- **Non-Django projects** (use Fern.dev instead)
- **Manual control freaks** (use drf-spectacular + generators)

## ๐Ÿง  Power Features

### Archive Management

```bash
# Automatic versioning with timestamped archives
openapi/archive/
โ”œโ”€โ”€ files/
โ”‚   โ”œโ”€โ”€ 2024-01-15_14-30-00/
โ”‚   โ”‚   โ”œโ”€โ”€ public.zip
โ”‚   โ”‚   โ””โ”€โ”€ admin.zip
โ”‚   โ””โ”€โ”€ 2024-01-15_15-45-00/
โ”‚       โ”œโ”€โ”€ public.zip
โ”‚       โ””โ”€โ”€ admin.zip
โ””โ”€โ”€ latest/
    โ”œโ”€โ”€ public.zip
    โ””โ”€โ”€ admin.zip
```

Each archive contains both TypeScript and Python clients:

- `typescript/` - Generated TypeScript client
- `python/` - Generated Python client

### Custom Templates

```python
'generators': {
    'typescript': {
        'custom_templates': './templates/typescript'
    },
    'python': {
        'custom_templates': './templates/python'
    }
}
```

### Programmatic Usage

```python
from django_revolution import OpenAPIGenerator, get_settings

config = get_settings()
generator = OpenAPIGenerator(config)
summary = generator.generate_all(zones=['public', 'admin'])
```

## ๐Ÿ“Š Comparison Table

| Feature                           | Django Revolution  | drf-spectacular + generators | openapi-generator-cli | Fern.dev | Manual Setup |
| --------------------------------- | ------------------ | ---------------------------- | --------------------- | -------- | ------------ |
| **Zone-based architecture**       | โœ… **UNIQUE**      | โŒ                           | โŒ                    | โœ…       | โŒ           |
| **Automatic URL generation**      | โœ… **UNIQUE**      | โŒ                           | โŒ                    | โŒ       | โŒ           |
| **Monorepo integration**          | โœ… **OPTIONAL**    | โŒ                           | โŒ                    | โœ…       | โŒ           |
| **Django management commands**    | โœ… **UNIQUE**      | โŒ                           | โŒ                    | โŒ       | โŒ           |
| **Archive management**            | โœ… **UNIQUE**      | โŒ                           | โŒ                    | โŒ       | โŒ           |
| **TypeScript + Python clients**   | โœ…                 | โœ…                           | โœ…                    | โœ…       | โœ…           |
| **DRF native integration**        | โœ… **SEAMLESS**    | โœ…                           | โš ๏ธ (via schema)       | โŒ       | โœ…           |
| **Ready-to-use Pydantic configs** | โœ… **UNIQUE**      | โŒ                           | โŒ                    | โŒ       | โŒ           |
| **Zero configuration**            | โœ… **UNIQUE**      | โŒ                           | โŒ                    | โŒ       | โŒ           |
| **Environment variables**         | โœ… **Pydantic**    | โŒ                           | โŒ                    | โŒ       | โŒ           |
| **CLI interface**                 | โœ… **Rich output** | โŒ                           | โœ…                    | โœ…       | โŒ           |

## ๐Ÿ™‹ FAQ

**Q: Is this production-ready?**  
โœ… Yes. Used in monorepos and multi-tenant production apps.

**Q: What if I use DRF with custom auth?**  
Use `setHeaders()` or `setApiKey()` to inject custom logic.

**Q: Can I use this in non-monorepo setups?**  
Absolutely! Monorepo integration is completely optional. Just don't pass the `monorepo` parameter.

**Q: What if I need only TypeScript clients?**  
Use `--typescript` flag to generate only TS clients.

**Q: Does it support custom OpenAPI decorators?**  
Yes, built on `drf-spectacular` so all extensions apply.

**Q: How do I use the ready-to-use Pydantic configs?**  
Simply import and use: `from django_revolution.drf_config import create_drf_config` and `from django_revolution.app_config import ZoneConfig, get_revolution_config`.

**Q: Are the Pydantic configs type-safe?**  
Yes! Full Pydantic v2 validation with IDE autocomplete and error checking.

**Q: How do I disable monorepo integration?**  
Either don't pass the `monorepo` parameter to `get_revolution_config()`, or use the `--no-monorepo` flag when running the command.

## ๐Ÿค Contributing

```bash
# Development setup
git clone https://github.com/markolofsen/django-revolution.git
cd django-revolution
pip install -e ".[dev]"

# Run tests
pytest
black django_revolution/
isort django_revolution/
```

## ๐Ÿ“ž Support

- **Documentation**: [https://markolofsen.github.io/django-revolution/](https://markolofsen.github.io/django-revolution/)
- **Issues**: [https://github.com/markolofsen/django-revolution/issues](https://github.com/markolofsen/django-revolution/issues)
- **Discussions**: [https://github.com/markolofsen/django-revolution/discussions](https://github.com/markolofsen/django-revolution/discussions)

## ๐Ÿ“ License

MIT License - see [LICENSE](LICENSE) file for details.

---

**Made with โค๏ธ by the [Unrealos Team](https://unrealos.com)**

**Django Revolution** - The **ONLY** tool that makes Django API client generation **truly automated** and **zone-aware**.

            

Raw data

            {
    "_id": null,
    "home_page": "https://unrealos.com",
    "name": "django-revolution",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": "Unrealos <developers@unrealos.com>",
    "keywords": "django, api, openapi, rest, zones, typescript, python, client, generation",
    "author": "Unrealos",
    "author_email": "Unrealos <developers@unrealos.com>",
    "download_url": "https://files.pythonhosted.org/packages/41/2c/f4d175308919d84434a7404035bdd218ffd8263b771193d27c99c641a51d/django_revolution-1.0.8.tar.gz",
    "platform": null,
    "description": "# Django Revolution\n\n> **Zero-config TypeScript & Python client generator for Django REST Framework** \ud83d\ude80\n\n[![PyPI version](https://badge.fury.io/py/django-revolution.svg)](https://badge.fury.io/py/django-revolution)\n[![Python Support](https://img.shields.io/pypi/pyversions/django-revolution.svg)](https://pypi.org/project/django-revolution/)\n[![Django Support](https://img.shields.io/pypi/djversions/django-revolution.svg)](https://pypi.org/project/django-revolution/)\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT)\n\n## \u2728 What is Django Revolution?\n\n**The fastest way to generate fully-authenticated TypeScript + Python clients from Django REST Framework.**\n\n- \ud83e\udde9 Organize your API into **zones** (`public`, `admin`, `mobile`, etc.)\n- \u2699\ufe0f Generate strongly typed clients with **one command**\n- \ud83d\udd10 Built-in support for **Bearer tokens**, refresh logic, and API keys\n- \ud83d\udd04 Zero config for **Swagger/OpenAPI URLs**, **frontend integration**, and **monorepos**\n- \ud83c\udfaf **Optional monorepo integration** - works with or without monorepo structure\n\n> No boilerplate. No manual sync. Just clean clients in seconds.\n\n## \ud83e\uddea Example: Instantly Get a Typed API Client\n\n```typescript\nimport API from '@myorg/api-client';\n\nconst api = new API('https://api.example.com');\napi.setToken('your-access-token');\n\nconst profile = await api.public.getProfile();\nconst items = await api.public.listItems();\n```\n\n> \ud83d\udd10 Auth, \u2699\ufe0f Headers, \ud83d\udd04 Refresh \u2013 handled automatically.\n\n## \u26d4 Without Django Revolution\n\nManually update OpenAPI spec \u2192 Run generator \u2192 Fix broken types \u2192 Sync clients \u2192 Write token logic \u2192 Repeat on every change.\n\n## \u2705 With Django Revolution\n\nOne command. Done.\n\n## \ud83c\udfaf **Ready-to-Use Pydantic Configs**\n\n**No more manual configuration!** Django Revolution provides **pre-built, typed configurations**:\n\n### **DRF + Spectacular Config**\n\n```python\nfrom django_revolution.drf_config import create_drf_config\n\n# One function call - everything configured!\ndrf_config = create_drf_config(\n    title=\"My API\",\n    description=\"My awesome API\",\n    version=\"1.0.0\",\n    schema_path_prefix=\"/api/\",\n    enable_browsable_api=False,\n    enable_throttling=True,\n)\n\n# Get Django settings\nsettings = drf_config.get_django_settings()\nREST_FRAMEWORK = settings['REST_FRAMEWORK']\nSPECTACULAR_SETTINGS = settings['SPECTACULAR_SETTINGS']\n```\n\n### **Zone Configuration**\n\n```python\nfrom django_revolution.app_config import ZoneConfig, get_revolution_config\n\n# Typed zone definitions\nzones = {\n    'public': ZoneConfig(\n        apps=['accounts', 'billing', 'payments', 'support', 'public'],\n        title='Public API',\n        description='API for public client applications',\n        public=True,\n        auth_required=False,\n        version='v1',\n        path_prefix='public'\n    ),\n    'internal': ZoneConfig(\n        apps=['system', 'mailer'],\n        title='Internal API',\n        description='Internal API for backend services',\n        public=False,\n        auth_required=True,\n        version='v1',\n        path_prefix='internal'\n    ),\n    'admin': ZoneConfig(\n        apps=['admin_panel', 'services'],\n        title='Admin API',\n        description='Administrative API endpoints',\n        public=False,\n        auth_required=True,\n        version='v1',\n        path_prefix='admin'\n    )\n}\n\n# Option 1: Without monorepo (simplest)\nconfig = get_revolution_config(project_root=Path.cwd(), zones=zones)\n\n# Option 2: With monorepo integration\nfrom django_revolution.app_config import MonorepoConfig\nmonorepo = MonorepoConfig(\n    enabled=True,\n    path=str(Path.cwd().parent / 'monorepo'),\n    api_package_path='packages/api/src'\n)\nconfig = get_revolution_config(project_root=Path.cwd(), zones=zones, monorepo=monorepo)\n```\n\n**Benefits:**\n\n- \u2705 **Type-safe** - Full Pydantic validation\n- \u2705 **Zero boilerplate** - Pre-configured defaults\n- \u2705 **Environment-aware** - Auto-detects paths and settings\n- \u2705 **IDE support** - Autocomplete and error checking\n- \u2705 **Production-ready** - Optimized for client generation\n- \u2705 **Flexible** - Works with or without monorepo\n\n## \ud83d\ude80 5-Minute Setup\n\n### 1. Install\n\n```bash\npip install django-revolution\n```\n\n### 2. Add to Django Settings\n\n```python\n# settings.py\nINSTALLED_APPS = [\n    'drf_spectacular',\n    'django_revolution',  # Add this line\n]\n```\n\n### 3. **Easy Configuration with Ready-to-Use Configs** \ud83c\udfaf\n\nDjango Revolution provides **pre-built Pydantic configurations** that you can import and use directly:\n\n#### **DRF + Spectacular Configuration** (services.py)\n\n```python\n# api/settings/config/services.py\nfrom django_revolution.drf_config import create_drf_config\n\nclass SpectacularConfig(BaseModel):\n    \"\"\"API documentation configuration using django_revolution DRF config.\"\"\"\n\n    title: str = Field(default='API')\n    description: str = Field(default='RESTful API')\n    version: str = Field(default='1.0.0')\n    schema_path_prefix: str = Field(default='/apix/')\n    enable_browsable_api: bool = Field(default=False)\n    enable_throttling: bool = Field(default=False)\n\n    def get_django_settings(self) -> Dict[str, Any]:\n        \"\"\"Get drf-spectacular settings using django_revolution config.\"\"\"\n        # Use django_revolution DRF config - zero boilerplate!\n        drf_config = create_drf_config(\n            title=self.title,\n            description=self.description,\n            version=self.version,\n            schema_path_prefix=self.schema_path_prefix,\n            enable_browsable_api=self.enable_browsable_api,\n            enable_throttling=self.enable_throttling,\n        )\n\n        return drf_config.get_django_settings()\n```\n\n#### **Zone Configuration** (revolution.py)\n\n```python\n# api/settings/config/revolution.py\nfrom django_revolution.app_config import (\n    DjangoRevolutionConfig,\n    ZoneConfig,\n    MonorepoConfig,\n    get_revolution_config\n)\n\ndef create_revolution_config(env) -> Dict[str, Any]:\n    \"\"\"Get Django Revolution configuration as dictionary.\"\"\"\n\n    # Define zones with typed Pydantic models\n    zones = {\n        'public': ZoneConfig(\n            apps=['accounts', 'billing', 'payments', 'support', 'public'],\n            title='Public API',\n            description='API for public client applications',\n            public=True,\n            auth_required=False,\n            version='v1',\n            path_prefix='public'\n        ),\n        'internal': ZoneConfig(\n            apps=['system', 'mailer'],\n            title='Internal API',\n            description='Internal API for backend services',\n            public=False,\n            auth_required=True,\n            version='v1',\n            path_prefix='internal'\n        ),\n        'admin': ZoneConfig(\n            apps=['admin_panel', 'services'],\n            title='Admin API',\n            description='Administrative API endpoints',\n            public=False,\n            auth_required=True,\n            version='v1',\n            path_prefix='admin'\n        )\n    }\n\n    # Option 1: Without monorepo (simplest setup)\n    project_root = env.root_dir\n    return get_revolution_config(project_root=project_root, zones=zones, debug=env.debug)\n\n    # Option 2: With monorepo integration\n    # monorepo = MonorepoConfig(\n    #     enabled=True,\n    #     path=str(env.root_dir.parent / 'monorepo'),\n    #     api_package_path='packages/api/src'\n    # )\n    # return get_revolution_config(project_root=project_root, zones=zones, debug=env.debug, monorepo=monorepo)\n```\n\n### 4. Generate Clients\n\n```bash\n# Generate everything\npython manage.py revolution\n\n# Generate specific zones\npython manage.py revolution --zones client admin\n\n# TypeScript only\npython manage.py revolution --typescript\n\n# Without monorepo sync\npython manage.py revolution --no-monorepo\n```\n\n## \ud83e\uddec What Does It Generate?\n\n| Language       | Location                      | Structure                                                 |\n| -------------- | ----------------------------- | --------------------------------------------------------- |\n| **TypeScript** | `openapi/clients/typescript/` | `public/`, `admin/` \u2192 `index.ts`, `types.ts`, `services/` |\n| **Python**     | `openapi/clients/python/`     | `public/`, `admin/` \u2192 `client.py`, `models/`, `setup.py`  |\n\n\ud83d\udca1 Each zone gets its own NPM/PyPI-style package. Ready to publish or import.\n\n## \u26a1\ufe0f TypeScript Client Auth & Usage\n\nDjango Revolution automatically generates a smart TypeScript API client with built-in authentication and token management:\n\n- **Zone-based organization** - All endpoints grouped by zones (client, admin, internal, etc.)\n- **Authentication ready** - Bearer tokens, refresh tokens, custom headers out of the box\n- **Simple integration** - Works with React, Next.js, Vue, or any frontend framework\n- **Type-safe** - Full TypeScript support with autocomplete\n\n**Example Usage:**\n\n```typescript\nimport API from '@myorg/api-client';\n\nconst api = new API('https://api.example.com');\n\n// Authentication\napi.setToken('your-access-token', 'your-refresh-token');\n\n// Call any endpoint\nconst user = await api.public.getCurrentUser();\nconst products = await api.public.listProducts();\n\n// Check authentication status\nif (api.isAuthenticated()) {\n  // User is logged in\n}\n\n// Change API URL\napi.setApiUrl('https://api.newhost.com');\n```\n\n**Features included:**\n\n- \u2705 Automatic token management (localStorage)\n- \u2705 Custom headers support\n- \u2705 API key authentication\n- \u2705 Zone-based endpoint organization\n- \u2705 TypeScript types for all endpoints\n- \u2705 Error handling and validation\n\n> **No need to write authentication logic - everything is handled automatically!**\n\n## \ud83c\udf10 Auto-Generated URLs\n\nDjango Revolution **automatically generates** all necessary URLs for your API zones:\n\n```python\n# urls.py\nfrom django_revolution import add_revolution_urls\n\nurlpatterns = [\n    # Your existing URLs\n    path('admin/', admin.site.urls),\n]\n\n# Django Revolution automatically adds:\n# - /api/public/schema/ (Swagger UI)\n# - /api/public/schema.yaml (OpenAPI spec)\n# - /api/admin/schema/ (Swagger UI)\n# - /api/admin/schema.yaml (OpenAPI spec)\n# - /openapi/archive/ (Generated clients)\nurlpatterns = add_revolution_urls(urlpatterns)\n```\n\n**Generated URLs:**\n\n- `/api/{zone}/schema/` - Interactive Swagger UI\n- `/api/{zone}/schema.yaml` - OpenAPI specification\n- `/openapi/archive/` - Download generated clients\n\n## \ud83e\uddea CLI Toolbox\n\n### Django Management Commands\n\n```bash\n# Generate all clients\npython manage.py revolution\n\n# Specific zones\npython manage.py revolution --zones public admin\n\n# Generator options\npython manage.py revolution --typescript\npython manage.py revolution --python\npython manage.py revolution --no-archive\n\n# Monorepo options\npython manage.py revolution --no-monorepo\n\n# Utility commands\npython manage.py revolution --status\npython manage.py revolution --list-zones\npython manage.py revolution --validate\npython manage.py revolution --clean\n```\n\n### Standalone CLI (Interactive)\n\n```bash\n# Interactive CLI with rich interface\ndjango-revolution\n\n# Or run directly\npython -m django_revolution.cli\n```\n\nThe standalone CLI provides an interactive interface with:\n\n- \ud83c\udfaf Zone selection with checkboxes\n- \ud83d\udd27 Client type selection (TypeScript/Python)\n- \ud83d\udce6 Archive creation options\n- \ud83d\udcca Real-time progress tracking\n- \u2705 Generation summary with results table\n\n## \ud83e\ude86 Monorepo Integration (Optional)\n\nDjango Revolution **optionally integrates** with your monorepo:\n\n### With Monorepo\n\n```python\n# settings.py - With monorepo integration\nfrom django_revolution.app_config import MonorepoConfig\n\nmonorepo = MonorepoConfig(\n    enabled=True,\n    path=str(BASE_DIR.parent.parent / 'monorepo'),\n    api_package_path='packages/api/src'\n)\n\nDJANGO_REVOLUTION = get_revolution_config(\n    project_root=BASE_DIR,\n    zones=zones,\n    monorepo=monorepo\n)\n```\n\n**Auto-generated monorepo structure:**\n\n```yaml\n# pnpm-workspace.yaml (auto-generated)\npackages:\n  - 'packages/**'\n  - 'packages/api/**' # Added automatically\n```\n\n**Package.json dependencies:**\n\n```json\n{\n  \"dependencies\": {\n    \"@markolofsen/public-api-client\": \"workspace:*\",\n    \"@markolofsen/admin-api-client\": \"workspace:*\"\n  }\n}\n```\n\n### Without Monorepo\n\n```python\n# settings.py - Without monorepo (simplest)\nDJANGO_REVOLUTION = get_revolution_config(\n    project_root=BASE_DIR,\n    zones=zones\n)\n```\n\n**Generated locally:**\n\n- `openapi/clients/typescript/` - TypeScript clients\n- `openapi/clients/python/` - Python clients\n- `openapi/archive/` - Versioned archives\n\n## \ud83d\udd27 Configuration\n\n### **Easy Configuration with Ready-to-Use Configs** \ud83c\udfaf\n\nDjango Revolution provides **pre-built Pydantic configurations** that eliminate manual setup:\n\n#### **1. DRF + Spectacular Configuration**\n\n```python\n# api/settings/config/services.py\nfrom django_revolution.drf_config import create_drf_config\n\n# One function call - everything configured!\ndrf_config = create_drf_config(\n    title=\"My API\",\n    description=\"My awesome API\",\n    version=\"1.0.0\",\n    schema_path_prefix=\"/api/\",\n    enable_browsable_api=False,\n    enable_throttling=True,\n)\n\n# Get Django settings\nsettings = drf_config.get_django_settings()\nREST_FRAMEWORK = settings['REST_FRAMEWORK']\nSPECTACULAR_SETTINGS = settings['SPECTACULAR_SETTINGS']\n```\n\n#### **2. Zone Configuration**\n\n```python\n# api/settings/config/revolution.py\nfrom django_revolution.app_config import ZoneConfig, get_revolution_config\n\n# Typed zone definitions with Pydantic models\nzones = {\n    'public': ZoneConfig(\n        apps=['accounts', 'billing', 'payments'],\n        title='Public API',\n        description='API for public client applications',\n        public=True,\n        auth_required=False,\n        version='v1',\n        path_prefix='public'\n    ),\n    'admin': ZoneConfig(\n        apps=['admin_panel', 'analytics'],\n        title='Admin API',\n        description='Administrative API endpoints',\n        public=False,\n        auth_required=True,\n        version='v1',\n        path_prefix='admin'\n    )\n}\n\n# Option 1: Without monorepo (simplest)\nconfig = get_revolution_config(project_root=Path.cwd(), zones=zones)\n\n# Option 2: With monorepo integration\nfrom django_revolution.app_config import MonorepoConfig\nmonorepo = MonorepoConfig(\n    enabled=True,\n    path=str(Path.cwd().parent / 'monorepo'),\n    api_package_path='packages/api/src'\n)\nconfig = get_revolution_config(project_root=Path.cwd(), zones=zones, monorepo=monorepo)\n```\n\n### **Legacy Configuration** (for backward compatibility)\n\n#### Environment Variables\n\n```bash\nexport DJANGO_REVOLUTION_DEBUG=true\nexport DJANGO_REVOLUTION_API_PREFIX=apix\nexport DJANGO_REVOLUTION_AUTO_INSTALL_DEPS=true\n```\n\n#### Manual Zone Configuration\n\n```python\n'zones': {\n    'zone_name': {\n        'apps': ['app1', 'app2'],           # Required\n        'title': 'Human Readable Title',    # Optional\n        'description': 'Zone description',  # Optional\n        'public': True,                     # Optional\n        'auth_required': False,             # Optional\n        'rate_limit': '1000/hour',          # Optional\n        'permissions': ['perm1', 'perm2'],  # Optional\n        'version': 'v1',                    # Optional\n        'prefix': 'custom_prefix',          # Optional\n        'cors_enabled': False,              # Optional\n    }\n}\n```\n\n## \u2705 When to Use\n\n### \u2705 Perfect For\n\n- **Large Django projects** with multiple API audiences\n- **Monorepo architectures** with frontend/backend separation\n- **Teams** needing consistent API client generation\n- **Projects** requiring zone-based API organization\n- **Automated CI/CD** pipelines\n- **Simple projects** without monorepo (optional integration)\n\n### \u274c Not For\n\n- **Simple single-zone APIs** (overkill)\n- **Non-Django projects** (use Fern.dev instead)\n- **Manual control freaks** (use drf-spectacular + generators)\n\n## \ud83e\udde0 Power Features\n\n### Archive Management\n\n```bash\n# Automatic versioning with timestamped archives\nopenapi/archive/\n\u251c\u2500\u2500 files/\n\u2502   \u251c\u2500\u2500 2024-01-15_14-30-00/\n\u2502   \u2502   \u251c\u2500\u2500 public.zip\n\u2502   \u2502   \u2514\u2500\u2500 admin.zip\n\u2502   \u2514\u2500\u2500 2024-01-15_15-45-00/\n\u2502       \u251c\u2500\u2500 public.zip\n\u2502       \u2514\u2500\u2500 admin.zip\n\u2514\u2500\u2500 latest/\n    \u251c\u2500\u2500 public.zip\n    \u2514\u2500\u2500 admin.zip\n```\n\nEach archive contains both TypeScript and Python clients:\n\n- `typescript/` - Generated TypeScript client\n- `python/` - Generated Python client\n\n### Custom Templates\n\n```python\n'generators': {\n    'typescript': {\n        'custom_templates': './templates/typescript'\n    },\n    'python': {\n        'custom_templates': './templates/python'\n    }\n}\n```\n\n### Programmatic Usage\n\n```python\nfrom django_revolution import OpenAPIGenerator, get_settings\n\nconfig = get_settings()\ngenerator = OpenAPIGenerator(config)\nsummary = generator.generate_all(zones=['public', 'admin'])\n```\n\n## \ud83d\udcca Comparison Table\n\n| Feature                           | Django Revolution  | drf-spectacular + generators | openapi-generator-cli | Fern.dev | Manual Setup |\n| --------------------------------- | ------------------ | ---------------------------- | --------------------- | -------- | ------------ |\n| **Zone-based architecture**       | \u2705 **UNIQUE**      | \u274c                           | \u274c                    | \u2705       | \u274c           |\n| **Automatic URL generation**      | \u2705 **UNIQUE**      | \u274c                           | \u274c                    | \u274c       | \u274c           |\n| **Monorepo integration**          | \u2705 **OPTIONAL**    | \u274c                           | \u274c                    | \u2705       | \u274c           |\n| **Django management commands**    | \u2705 **UNIQUE**      | \u274c                           | \u274c                    | \u274c       | \u274c           |\n| **Archive management**            | \u2705 **UNIQUE**      | \u274c                           | \u274c                    | \u274c       | \u274c           |\n| **TypeScript + Python clients**   | \u2705                 | \u2705                           | \u2705                    | \u2705       | \u2705           |\n| **DRF native integration**        | \u2705 **SEAMLESS**    | \u2705                           | \u26a0\ufe0f (via schema)       | \u274c       | \u2705           |\n| **Ready-to-use Pydantic configs** | \u2705 **UNIQUE**      | \u274c                           | \u274c                    | \u274c       | \u274c           |\n| **Zero configuration**            | \u2705 **UNIQUE**      | \u274c                           | \u274c                    | \u274c       | \u274c           |\n| **Environment variables**         | \u2705 **Pydantic**    | \u274c                           | \u274c                    | \u274c       | \u274c           |\n| **CLI interface**                 | \u2705 **Rich output** | \u274c                           | \u2705                    | \u2705       | \u274c           |\n\n## \ud83d\ude4b FAQ\n\n**Q: Is this production-ready?**  \n\u2705 Yes. Used in monorepos and multi-tenant production apps.\n\n**Q: What if I use DRF with custom auth?**  \nUse `setHeaders()` or `setApiKey()` to inject custom logic.\n\n**Q: Can I use this in non-monorepo setups?**  \nAbsolutely! Monorepo integration is completely optional. Just don't pass the `monorepo` parameter.\n\n**Q: What if I need only TypeScript clients?**  \nUse `--typescript` flag to generate only TS clients.\n\n**Q: Does it support custom OpenAPI decorators?**  \nYes, built on `drf-spectacular` so all extensions apply.\n\n**Q: How do I use the ready-to-use Pydantic configs?**  \nSimply import and use: `from django_revolution.drf_config import create_drf_config` and `from django_revolution.app_config import ZoneConfig, get_revolution_config`.\n\n**Q: Are the Pydantic configs type-safe?**  \nYes! Full Pydantic v2 validation with IDE autocomplete and error checking.\n\n**Q: How do I disable monorepo integration?**  \nEither don't pass the `monorepo` parameter to `get_revolution_config()`, or use the `--no-monorepo` flag when running the command.\n\n## \ud83e\udd1d Contributing\n\n```bash\n# Development setup\ngit clone https://github.com/markolofsen/django-revolution.git\ncd django-revolution\npip install -e \".[dev]\"\n\n# Run tests\npytest\nblack django_revolution/\nisort django_revolution/\n```\n\n## \ud83d\udcde Support\n\n- **Documentation**: [https://markolofsen.github.io/django-revolution/](https://markolofsen.github.io/django-revolution/)\n- **Issues**: [https://github.com/markolofsen/django-revolution/issues](https://github.com/markolofsen/django-revolution/issues)\n- **Discussions**: [https://github.com/markolofsen/django-revolution/discussions](https://github.com/markolofsen/django-revolution/discussions)\n\n## \ud83d\udcdd License\n\nMIT License - see [LICENSE](LICENSE) file for details.\n\n---\n\n**Made with \u2764\ufe0f by the [Unrealos Team](https://unrealos.com)**\n\n**Django Revolution** - The **ONLY** tool that makes Django API client generation **truly automated** and **zone-aware**.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Zone-based API architecture for Django. Install and go.",
    "version": "1.0.8",
    "project_urls": {
        "Documentation": "https://markolofsen.github.io/django-revolution/",
        "Homepage": "https://unrealos.com",
        "Repository": "https://github.com/markolofsen/django-revolution"
    },
    "split_keywords": [
        "django",
        " api",
        " openapi",
        " rest",
        " zones",
        " typescript",
        " python",
        " client",
        " generation"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "8aa87feda9000659137033914ff3f1531038a5c192028c7f49f5dce86ef87f8f",
                "md5": "42a32b0e3e0358ece6ce7c9adbe189e1",
                "sha256": "0420e47a0825ef7ebaa6b60abe6a16b3a66e97e22a315a8f1ccab624fc7e65d0"
            },
            "downloads": -1,
            "filename": "django_revolution-1.0.8-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "42a32b0e3e0358ece6ce7c9adbe189e1",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 56087,
            "upload_time": "2025-07-12T03:04:46",
            "upload_time_iso_8601": "2025-07-12T03:04:46.280563Z",
            "url": "https://files.pythonhosted.org/packages/8a/a8/7feda9000659137033914ff3f1531038a5c192028c7f49f5dce86ef87f8f/django_revolution-1.0.8-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "412cf4d175308919d84434a7404035bdd218ffd8263b771193d27c99c641a51d",
                "md5": "e0b340fd79b80f9d53861e5100421fe0",
                "sha256": "0cd19560e37fef57655b561753593259fb647b1a633f0d0519522583dca122c2"
            },
            "downloads": -1,
            "filename": "django_revolution-1.0.8.tar.gz",
            "has_sig": false,
            "md5_digest": "e0b340fd79b80f9d53861e5100421fe0",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 59420,
            "upload_time": "2025-07-12T03:04:48",
            "upload_time_iso_8601": "2025-07-12T03:04:48.197272Z",
            "url": "https://files.pythonhosted.org/packages/41/2c/f4d175308919d84434a7404035bdd218ffd8263b771193d27c99c641a51d/django_revolution-1.0.8.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-12 03:04:48",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "markolofsen",
    "github_project": "django-revolution",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "django-revolution"
}
        
Elapsed time: 0.41746s