# strawberry-graphql/strawberry-django architecture

> Architecture diagram of the GitHub repository strawberry-graphql/strawberry-django, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/strawberry-graphql/strawberry-django
- Repository: https://github.com/strawberry-graphql/strawberry-django

## Overview

##### Main Components (Top Level)
a) Django Application Layer (Green)
b) Strawberry-Django Integration Layer (Blue)
c) GraphQL API Layer (Purple)

##### Core Components (Integration Layer)

a) Type System (Central):
- Fields Manager
- Type Generators
- Resolvers
- Mutations Handler

b) Query Processing:
- Optimizer
- Filter System
- Pagination
- Ordering

c) Authentication & Authorization:
- Permission Handler
- Auth Mutations
- Guardian Integration

- Client GraphQL Query → GraphQL API Layer
- API Layer → Strawberry-Django Integration
- Integration Layer → Django ORM
- Django ORM → Database

##### Detailed Components

- [GraphQL API Layer]
- ↓
- [Strawberry-Django Integration]
- Type Generation
- Query Resolution
- Mutation Handling
- Relay Support
- Optimization
- ↓
- [Django ORM Layer]

##### Integration Points
Specific integration components:
- Debug Toolbar Integration
- Guardian Permissions
- Cache Extensions
- Custom Field Types

##### Key Features to Emphasize
- CRUD Operations Flow
- Query Optimization Path
- Authentication Flow
- Relay Connection Handling

##### Technical Details
- Async vs Sync Operations
- Extension Points
- Configuration Options
- Type Resolution Flow

Specific Implementation Guidelines:

##### Use standardized symbols
- Rectangles: Core components
- Hexagons: Extension points
- Diamonds: Decision points

- [Client Layer]
- ↓
- [GraphQL API Layer]
- ↓
- [Strawberry-Django Integration]
- ↓
- [Django ORM]
- ↓
- [Database]

##### Special sections
- Configuration Options
- Extension Points
- Security Layer
- Optimization Pipeline

Remember to:
- Code paths for main operations
- Both sync and async flows
- Optimization points
- Error handling paths

This design should reflect the project's core purpose of providing a seamless integration between Django and GraphQL while maintaining high performance through features like query optimization and caching.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        CL[Client Application]
    end

    subgraph "GraphQL API Layer"
        API[GraphQL API Endpoint]:::api
        Schema[Schema Export]:::api
    end

    subgraph "Strawberry-Django Integration"
        subgraph "Type System"
            TS[Type System Core]
            FM[Fields Manager]:::core
            TG[Type Generators]:::core
            RES[Resolvers]:::core
            MH[Mutations Handler]:::core
        end

        subgraph "Query Processing"
            QP[Query Processor]
            OPT[Optimizer]:::core
            FIL[Filter System]:::core
            PAG[Pagination]:::core
            ORD[Ordering]:::core
        end

        subgraph "Authentication & Authorization"
            AUTH[Auth System]
            PH[Permission Handler]:::core
            AM[Auth Mutations]:::core
            GI[Guardian Integration]:::core
        end

        subgraph "Integration Points"
            DTI[Debug Toolbar]:::integration
            CE[Cache Extensions]:::integration
            VC[Validation Cache]:::integration
        end

        subgraph "Core Utilities"
            QU[Query Utils]:::utils
            TU[Type Utils]:::utils
            IU[Inspection Utils]:::utils
        end

        RS[Relay Support]:::core
        SH[Settings Handler]:::core
    end

    subgraph "Django Layer"
        DORM[Django ORM]
        DB[(Database)]
    end

    %% Connections
    CL --> API
    API --> TS
    API --> QP
    TS --> DORM
    QP --> DORM
    AUTH --> DORM
    DORM --> DB

    %% Internal Type System Connections
    TS --> FM
    TS --> TG
    TS --> RES
    TS --> MH

    %% Internal Query Processing Connections
    QP --> OPT
    QP --> FIL
    QP --> PAG
    QP --> ORD

    %% Internal Auth Connections
    AUTH --> PH
    AUTH --> AM
    AUTH --> GI

    %% Integration Connections
    API --> DTI
    API --> CE
    API --> VC

    %% Utility Connections
    TS --> QU
    TS --> TU
    TS --> IU

    %% Click Events
    click FM "https://github.com/strawberry-graphql/strawberry-django/blob/main/strawberry_django/fields/field.py"
    click TG "https://github.com/strawberry-graphql/strawberry-django/blob/main/strawberry_django/type.py"
    click RES "https://github.com/strawberry-graphql/strawberry-django/blob/main/strawberry_django/resolvers.py"
    click MH "https://github.com/strawberry-graphql/strawberry-django/blob/main/strawberry_django/mutations/mutations.py"
    click OPT "https://github.com/strawberry-graphql/strawberry-django/blob/main/strawberry_django/optimizer.py"
    click FIL "https://github.com/strawberry-graphql/strawberry-django/blob/main/strawberry_django/filters.py"
    click PAG "https://github.com/strawberry-graphql/strawberry-django/blob/main/strawberry_django/pagination.py"
    click ORD "https://github.com/strawberry-graphql/strawberry-django/blob/main/strawberry_django/ordering.py"
    click PH "https://github.com/strawberry-graphql/strawberry-django/blob/main/strawberry_django/permissions.py"
    click AM "https://github.com/strawberry-graphql/strawberry-django/blob/main/strawberry_django/auth/mutations.py"
    click GI "https://github.com/strawberry-graphql/strawberry-django/blob/main/strawberry_django/integrations/guardian.py"
    click DTI "https://github.com/strawberry-graphql/strawberry-django/blob/main/strawberry_django/middlewares/debug_toolbar.py"
    click CE "https://github.com/strawberry-graphql/strawberry-django/blob/main/strawberry_django/extensions/django_cache_base.py"
    click VC "https://github.com/strawberry-graphql/strawberry-django/blob/main/strawberry_django/extensions/django_validation_cache.py"
    click RS "https://github.com/strawberry-graphql/strawberry-django/blob/main/strawberry_django/relay.py"
    click QU "https://github.com/strawberry-graphql/strawberry-django/blob/main/strawberry_django/utils/query.py"
    click TU "https://github.com/strawberry-graphql/strawberry-django/blob/main/strawberry_django/utils/typing.py"
    click IU "https://github.com/strawberry-graphql/strawberry-django/blob/main/strawberry_django/utils/inspect.py"
    click SH "https://github.com/strawberry-graphql/strawberry-django/blob/main/strawberry_django/settings.py"
    click Schema "https://github.com/strawberry-graphql/strawberry-django/blob/main/strawberry_django/management/commands/export_schema.py"

    %% Styling
    classDef api fill:#9370DB
    classDef core fill:#4682B4
    classDef integration fill:#FFD700
    classDef utils fill:#98FB98

    %% Legend
    subgraph Legend
        L1[API Components]:::api
        L2[Core Components]:::core
        L3[Integration Points]:::integration
        L4[Utilities]:::utils
    end
```
