# plone/plone.app.theming architecture

> Architecture diagram of the GitHub repository plone/plone.app.theming, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/plone/plone.app.theming
- Repository: https://github.com/plone/plone.app.theming

## Overview

##### Core Components
- Theme Engine (Diazo Integration)
- Control Panel Interface
- Theme Transform Pipeline
- Theme Resources Manager
- Plugin System

##### Main Architectural Layers

a) Presentation Layer:
- Control Panel UI (controlpanel.pt)
- Theme Error Handling (theme-error.pt)

b) Business Logic Layer:
- Theme Transform Engine (transform.py)
- Theme Policy Manager (policy.py)
- Plugin System (plugins directory)
- Events Handler (events.py)

c) Integration Layer:
- Export/Import Handlers (exportimport directory)
- Traversal System (traversal.py)
- ZMI Integration (zmi.py)

##### Resource Management
- Theme Resources
- Rules Processing
- Custom CSS Handling
- Static Resources

- [Plone Frontend] ←→ [Theme Control Panel]
- ↓
- [Theme Transform Pipeline]
- ↓
- [Diazo Engine Integration]
- ↓
- [Theme Resources & Rules]

##### Connection Types
- Double lines: Data transformation flows

##### Component Interactions
- How plugins hook into the main system
- Theme resource loading paths

##### Integration Points
- Plone integration points
- Diazo engine connection
- ZMI integration

Key Elements to Emphasize:

##### Theme Processing Pipeline
- [Request] → [Transform Middleware] → [Rules Processing] → [Theme Application] → [Response]

##### Configuration Flow
- [manifest.cfg] → [Theme Registry] → [Policy Manager] → [Transform Engine]

##### Plugin Architecture
- [Core Engine] ← [Plugin Registry] → [Custom Plugins]

Remember to:
- Clear boundaries between components
- Notes for critical processes
- Version-specific features separately

## Diagram (Mermaid)

```mermaid
graph TB
    %% Main Components
    Browser["Browser"]:::external
    Plone["Plone CMS"]:::external
    Diazo["Diazo Engine"]:::external

    subgraph Presentation
        ControlPanel["Control Panel UI"]:::ui
        ErrorHandler["Theme Error Handler"]:::ui
        CustomCSS["Custom CSS Handler"]:::ui
    end

    subgraph Core
        ThemeEngine["Theme Engine Core"]:::core
        TransformPipeline["Theme Transform Pipeline"]:::core
        PolicyManager["Theme Policy Manager"]:::core
        EventsHandler["Events Handler"]:::core
    end

    subgraph Integration
        ExportImport["Export/Import System"]:::integration
        Traversal["Traversal System"]:::integration
        ZMI["ZMI Integration"]:::integration
    end

    subgraph Resources
        ThemeResources["Theme Resources"]:::resource
        RulesProcessor["Rules Processor"]:::resource
        StaticResources["Static Resources"]:::resource
    end

    subgraph Plugins
        PluginSystem["Plugin System"]:::plugin
        CustomPlugins["Custom Plugins"]:::plugin
    end

    %% Relationships
    Browser --> ControlPanel
    Browser --> ErrorHandler
    ControlPanel --> ThemeEngine
    ThemeEngine --> TransformPipeline
    TransformPipeline --> Diazo
    ThemeEngine --> PolicyManager
    PolicyManager --> ThemeResources
    ThemeEngine --> EventsHandler
    ThemeEngine --> PluginSystem
    PluginSystem --> CustomPlugins
    ThemeEngine --> ExportImport
    ThemeEngine --> Traversal
    ThemeEngine --> ZMI
    CustomCSS --> ThemeResources
    ThemeResources --> RulesProcessor
    ThemeResources --> StaticResources
    Plone --> ThemeEngine

    %% Click Events
    click TransformPipeline "https://github.com/plone/plone.app.theming/blob/master/src/plone/app/theming/transform.py"
    click ControlPanel "https://github.com/plone/plone.app.theming/blob/master/src/plone/app/theming/browser/controlpanel.pt"
    click ErrorHandler "https://github.com/plone/plone.app.theming/blob/master/src/plone/app/theming/browser/theme-error.pt"
    click PolicyManager "https://github.com/plone/plone.app.theming/blob/master/src/plone/app/theming/policy.py"
    click PluginSystem "https://github.com/plone/plone.app.theming/tree/master/src/plone/app/theming/plugins/"
    click EventsHandler "https://github.com/plone/plone.app.theming/blob/master/src/plone/app/theming/events.py"
    click ExportImport "https://github.com/plone/plone.app.theming/tree/master/src/plone/app/theming/exportimport/"
    click Traversal "https://github.com/plone/plone.app.theming/blob/master/src/plone/app/theming/traversal.py"
    click ZMI "https://github.com/plone/plone.app.theming/blob/master/src/plone/app/theming/zmi.py"
    click ThemeResources "https://github.com/plone/plone.app.theming/tree/master/resources/theme/"
    click CustomCSS "https://github.com/plone/plone.app.theming/blob/master/src/plone/app/theming/browser/custom_css.py"
    click ThemeEngine "https://github.com/plone/plone.app.theming/blob/master/src/plone/app/theming/theme.py"

    %% Styles
    classDef external fill:#gray,stroke:#333,stroke-width:2px
    classDef ui fill:#3498db,stroke:#2980b9,color:white
    classDef core fill:#2ecc71,stroke:#27ae60,color:white
    classDef integration fill:#e74c3c,stroke:#c0392b,color:white
    classDef resource fill:#f1c40f,stroke:#f39c12
    classDef plugin fill:#9b59b6,stroke:#8e44ad,color:white

    %% Legend
    subgraph Legend
        L1["External Systems"]:::external
        L2["User Interface"]:::ui
        L3["Core Components"]:::core
        L4["Integration Layer"]:::integration
        L5["Resources"]:::resource
        L6["Plugin System"]:::plugin
    end
```
