# thunderer/shortcode architecture

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

- Interactive diagram: https://gitdiagram.com/thunderer/shortcode
- Repository: https://github.com/thunderer/shortcode

## Overview

##### Main Components

a) Core Processing Pipeline:
- Input Text → Parser → Processor → Handler → Output Text

- Parser System
- RegularParser, RegexParser, and WordpressParser as subcomponents
- To Syntax module
- Handler System
- HandlerContainer and various handlers
- Event System
- EventContainer and event handlers
- Serialization System
- Different serializer implementations (JSON, XML, YAML, Text)

##### Component Relationships

- Interface: ParserInterface
- Implementations: RegularParser, RegexParser, WordpressParser
- Connection to SyntaxInterface for configuration

- HandlerContainer at the center
- Various handlers (EmailHandler, UrlHandler, etc.) connected to it
- Handler registration flow

- EventContainer
- Event types (FilterShortcodesEvent, ReplaceShortcodesEvent)
- Connection points to the main processing pipeline

- A separate module with SerializerInterface

##### Architectural Elements

- Blue: Core processing components
- Green: Handlers and implementations
- Yellow: Interfaces
- Orange: Event system
- Purple: Serialization system

b) Symbols:
- Interfaces: <<interface>> stereotype
- Abstract classes: <<abstract>> stereotype
- Event handlers: Lightning bolt symbol

##### Key Interactions

- How text flows through the system
- How handlers are registered and called
- How events intercept the processing
- How serialization integrates

##### Additional Details

A section showing:
- Configuration options
- Syntax customization
- Handler registration
- Event handling points

##### Notes

Explanatory notes for:
- Processing pipeline stages
- Configuration options
- Extension points
- Common use cases

Remember to highlight the facade pattern implementation (ShortcodeFacade) as it provides a simplified interface to the entire system.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Legend
        A[Component]:::component --> B[Dependency]
        C[(Database)]:::database
        D{Decision}:::decision
        E([API/Interface]):::api
        style Legend fill:#f0f0f0,stroke:#333
    end

    subgraph Core["Core Processing Pipeline"]
        Input[Input Text]:::data
        Output[Output Text]:::data
        Facade["ShortcodeFacade"]:::core
        click Facade "https://github.com/thunderer/Shortcode/blob/master/src/ShortcodeFacade.php"
        Processor["Processor"]:::core
        click Processor "https://github.com/thunderer/Shortcode/blob/master/src/Processor/Processor.php"
    end

    subgraph ParserSystem["Parser System"]
        ParserInterface([ParserInterface]):::interface
        click ParserInterface "https://github.com/thunderer/Shortcode/blob/master/src/Parser/ParserInterface.php"
        RegularParser["RegularParser"]:::parser
        click RegularParser "https://github.com/thunderer/Shortcode/blob/master/src/Parser/RegularParser.php"
        RegexParser["RegexParser"]:::parser
        click RegexParser "https://github.com/thunderer/Shortcode/blob/master/src/Parser/RegexParser.php"
        WordpressParser["WordpressParser"]:::parser
        click WordpressParser "https://github.com/thunderer/Shortcode/blob/master/src/Parser/WordpressParser.php"
    end

    subgraph HandlerSystem["Handler System"]
        HandlerContainer["HandlerContainer"]:::handler
        click HandlerContainer "https://github.com/thunderer/Shortcode/blob/master/src/HandlerContainer/HandlerContainer.php"
        EmailHandler["EmailHandler"]:::handler
        click EmailHandler "https://github.com/thunderer/Shortcode/blob/master/src/Handler/EmailHandler.php"
        UrlHandler["UrlHandler"]:::handler
        click UrlHandler "https://github.com/thunderer/Shortcode/blob/master/src/Handler/UrlHandler.php"
        ContentHandler["ContentHandler"]:::handler
        click ContentHandler "https://github.com/thunderer/Shortcode/blob/master/src/Handler/ContentHandler.php"
        SerializerHandler["SerializerHandler"]:::handler
        click SerializerHandler "https://github.com/thunderer/Shortcode/blob/master/src/Handler/SerializerHandler.php"
    end

    subgraph EventSystem["Event System"]
        EventContainer["EventContainer"]:::event
        click EventContainer "https://github.com/thunderer/Shortcode/blob/master/src/EventContainer/EventContainer.php"
        FilterEvent["FilterShortcodesEvent"]:::event
        click FilterEvent "https://github.com/thunderer/Shortcode/blob/master/src/Event/FilterShortcodesEvent.php"
        ReplaceEvent["ReplaceShortcodesEvent"]:::event
        click ReplaceEvent "https://github.com/thunderer/Shortcode/blob/master/src/Event/ReplaceShortcodesEvent.php"
    end

    subgraph SerializationSystem["Serialization System"]
        SerializerInterface([SerializerInterface]):::interface
        click SerializerInterface "https://github.com/thunderer/Shortcode/blob/master/src/Serializer/SerializerInterface.php"
        JsonSerializer["JsonSerializer"]:::serializer
        click JsonSerializer "https://github.com/thunderer/Shortcode/blob/master/src/Serializer/JsonSerializer.php"
        XmlSerializer["XmlSerializer"]:::serializer
        click XmlSerializer "https://github.com/thunderer/Shortcode/blob/master/src/Serializer/XmlSerializer.php"
        YamlSerializer["YamlSerializer"]:::serializer
        click YamlSerializer "https://github.com/thunderer/Shortcode/blob/master/src/Serializer/YamlSerializer.php"
        TextSerializer["TextSerializer"]:::serializer
        click TextSerializer "https://github.com/thunderer/Shortcode/blob/master/src/Serializer/TextSerializer.php"
    end

    subgraph SyntaxSystem["Syntax System"]
        SyntaxInterface([SyntaxInterface]):::interface
        click SyntaxInterface "https://github.com/thunderer/Shortcode/blob/master/src/Syntax/SyntaxInterface.php"
        CommonSyntax["CommonSyntax"]:::syntax
        click CommonSyntax "https://github.com/thunderer/Shortcode/blob/master/src/Syntax/CommonSyntax.php"
        SyntaxBuilder["SyntaxBuilder"]:::syntax
        click SyntaxBuilder "https://github.com/thunderer/Shortcode/blob/master/src/Syntax/SyntaxBuilder.php"
    end

    %% Relationships
    Input --> Facade
    Facade --> ParserInterface
    ParserInterface --> |implements| RegularParser
    ParserInterface --> |implements| RegexParser
    ParserInterface --> |implements| WordpressParser
    Facade --> Processor
    Processor --> HandlerContainer
    HandlerContainer --> EmailHandler
    HandlerContainer --> UrlHandler
    HandlerContainer --> ContentHandler
    HandlerContainer --> SerializerHandler
    SerializerHandler --> SerializerInterface
    SerializerInterface --> |implements| JsonSerializer
    SerializerInterface --> |implements| XmlSerializer
    SerializerInterface --> |implements| YamlSerializer
    SerializerInterface --> |implements| TextSerializer
    EventContainer --> FilterEvent
    EventContainer --> ReplaceEvent
    Processor --> EventContainer
    SyntaxInterface --> |implements| CommonSyntax
    SyntaxInterface --> |implements| SyntaxBuilder
    ParserInterface --> SyntaxInterface
    HandlerContainer --> Output

    %% Styles
    classDef core fill:#b3e0ff,stroke:#333
    classDef interface fill:#ffe6cc,stroke:#333
    classDef parser fill:#d9f2d9,stroke:#333
    classDef handler fill:#ffcccc,stroke:#333
    classDef event fill:#ffe6b3,stroke:#333
    classDef serializer fill:#e6ccff,stroke:#333
    classDef syntax fill:#ffccff,stroke:#333
    classDef data fill:#f2f2f2,stroke:#333
    classDef component fill:#fff,stroke:#333
    classDef database fill:#f9f,stroke:#333
    classDef decision fill:#ffd,stroke:#333
    classDef api fill:#eff,stroke:#333
```
