Skip to the content.

Architecture

Understanding Django Revolution’s zone-based architecture.

Overview

Django Revolution introduces a zone-based architecture that organizes your Django API into logical, isolated sections. Each zone represents a different context or access level for your API endpoints.

Zone-Based Architecture

What are Zones?

Zones are logical groupings of API endpoints that share common characteristics:

Zone Types

Public Zone

Private Zone

Internal Zone

Admin Zone

Architecture Components

1. Zone Configuration

# settings.py
DJANGO_REVOLUTION = {
    'zones': {
        'public': {
            'apps': ['accounts', 'products'],
            'title': 'Public API',
            'description': 'Public endpoints',
            'public': True,
            'auth_required': False,
            'version': 'v1',
            'path_prefix': 'public'
        },
        'private': {
            'apps': ['orders', 'profile'],
            'title': 'Private API',
            'description': 'Authenticated endpoints',
            'public': False,
            'auth_required': True,
            'version': 'v1',
            'path_prefix': 'private'
        }
    }
}

2. URL Structure

Django Revolution automatically creates a structured URL hierarchy:

/api/
├── public/
│   ├── schema/          # Swagger UI
│   ├── schema.yaml      # OpenAPI spec
│   └── v1/              # API endpoints
├── private/
│   ├── schema/
│   ├── schema.yaml
│   └── v1/
└── admin/
    ├── schema/
    ├── schema.yaml
    └── v1/

3. Client Generation

Each zone generates its own client:

clients/
├── typescript/
│   ├── public/
│   │   ├── index.ts
│   │   └── types.ts
│   ├── private/
│   │   ├── index.ts
│   │   └── types.ts
│   └── index.ts         # Main client
└── python/
    ├── public/
    │   ├── __init__.py
    │   └── client.py
    ├── private/
    │   ├── __init__.py
    │   └── client.py
    └── __init__.py      # Main client

Data Flow

1. Request Flow

Client Request
    ↓
Zone Router (Django Revolution)
    ↓
Zone-specific Middleware
    ↓
Authentication Check
    ↓
Rate Limiting
    ↓
Django View
    ↓
Response

2. Client Generation Flow

Django Models & Views
    ↓
Zone Detection
    ↓
OpenAPI Schema Generation
    ↓
Client Template Rendering
    ↓
Generated Clients
    ↓
Monorepo Sync (optional)

Benefits

1. Security

2. Maintainability

3. Client Experience

4. Development

Best Practices

1. Zone Design

2. Security

3. Performance

4. Documentation

Migration Strategy

From Monolithic API

  1. Identify Zones: Analyze existing endpoints
  2. Create Zones: Define zone boundaries
  3. Move Endpoints: Gradually move endpoints to zones
  4. Update Clients: Update client code to use zones
  5. Test: Comprehensive testing of each zone

From Microservices

  1. Consolidate: Group related services into zones
  2. Standardize: Use consistent patterns across zones
  3. Optimize: Remove redundant code and configurations
  4. Document: Create comprehensive documentation

← Back to API Reference Next: Troubleshooting →