# symfony/ux architecture

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

- Interactive diagram: https://gitdiagram.com/symfony/ux
- Repository: https://github.com/symfony/ux

## Overview

##### Main Components

a. Core Infrastructure:
- StimulusBundle (central bundle for JavaScript handling)
- Asset Management System (supports both AssetMapper and Webpack Encore)
- Bundle Registry/Management System

b. UX Package Components (organize as modules):
- Live Components (Real-time updates)
- Form-related Components (Autocomplete, Dropzone, etc.)
- Visualization Components (Chartjs, LazyImage)
- Framework Integrations (React, Vue, Svelte)
- UI Enhancement Components (Notify, TogglePassword)
- Navigation Components (Turbo, Swup)

##### Integration Layers
- Stimulus Bridge (JavaScript integration layer)
- Asset Compilation Layer
- Bundle Configuration Layer
- Translation System
- Template Engine Integration

##### Relationships

- Data flow between components
- Dependency relationships
- Integration points with external systems
- Bundle registration flow
- Asset compilation pipeline

##### Component Details

For each major component, include:
- Input/Output interfaces
- Configuration requirements
- Dependencies on other components
- Integration points

##### Key Architectural Patterns to Highlight

- Plugin Architecture (for UX packages)
- Bridge Pattern (for framework integrations)
- Factory Pattern (for component creation)
- Observer Pattern (for live updates)

##### Technical Details

For each component:
- Configuration requirements
- Service definitions
- Asset requirements
- Framework dependencies

##### The relationship with Symfony's core components

- How components interact
- Where to add new features
- How data flows through the system
- Integration points for new UX packages
- The build and deployment process

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "HTTP Layer"
        Client(("HTTP Client"))
        Client --> PHPController
    end

    subgraph "PHP Controller Layer"
        PHPController["PHP Controllers"]:::php
        click PHPController "https://github.com/symfony/ux/tree/2.x/src/*/src/Controller/"
    end

    subgraph "Bundle System Layer"
        AutoBundle["AutocompleteBundle"]:::bundle
        ChartBundle["ChartjsBundle"]:::bundle
        LiveBundle["LiveComponentBundle"]:::bundle
        TwigBundle["TwigComponentBundle"]:::bundle

        click AutoBundle "https://github.com/symfony/ux/blob/2.x/src/Autocomplete/src/AutocompleteBundle.php"
        click ChartBundle "https://github.com/symfony/ux/blob/2.x/src/Chartjs/src/ChartjsBundle.php"
        click LiveBundle "https://github.com/symfony/ux/blob/2.x/src/LiveComponent/src/LiveComponentBundle.php"
        click TwigBundle "https://github.com/symfony/ux/blob/2.x/src/TwigComponent/src/TwigComponentBundle.php"
    end

    subgraph "Service Layer"
        DI["Dependency Injection"]:::php
        EntityMgmt["Entity Management"]:::php
        ServiceClasses["Service Classes"]:::php

        click DI "https://github.com/symfony/ux/tree/2.x/src/*/src/DependencyInjection/"
        click EntityMgmt "https://github.com/symfony/ux/tree/2.x/src/LiveComponent/src/Entity/"
        click ServiceClasses "https://github.com/symfony/ux/tree/2.x/src/*/src/Service/"
    end

    subgraph "Component Layer"
        PHPClasses["PHP Component Classes"]:::php
        TwigTemplates["Twig Templates"]:::template
        CompLogic["Component Logic"]:::php

        click PHPClasses "https://github.com/symfony/ux/tree/2.x/src/TwigComponent/src/"
        click TwigTemplates "https://github.com/symfony/ux/tree/2.x/src/*/templates/"
        click CompLogic "https://github.com/symfony/ux/tree/2.x/src/*/src/Component/"
    end

    subgraph "Integration Layer"
        ServiceContainer["Service Container"]:::php
        EventSystem["Event Dispatchers"]:::php
        AssetMgmt["Asset Management"]:::bridge

        click ServiceContainer "https://github.com/symfony/ux/tree/2.x/src/*/src/DependencyInjection/"
        click EventSystem "https://github.com/symfony/ux/tree/2.x/src/*/src/EventListener/"
        click AssetMgmt "https://github.com/symfony/ux/tree/2.x/src/*/assets/"
    end

    subgraph "Bridge Layer"
        AssetCompilation["Asset Compilation"]:::bridge
        JSIntegration["JavaScript Integration"]:::bridge
        StimulusInteg["Stimulus Integration"]:::bridge

        click AssetCompilation "https://github.com/symfony/ux/tree/2.x/src/StimulusBundle/src/AssetMapper/"
        click JSIntegration "https://github.com/symfony/ux/tree/2.x/src/*/assets/src/"
        click StimulusInteg "https://github.com/symfony/ux/tree/2.x/src/StimulusBundle/src/"
    end

    %% Connections
    Client --> PHPController
    PHPController --> AutoBundle & ChartBundle & LiveBundle & TwigBundle
    AutoBundle & ChartBundle & LiveBundle & TwigBundle --> DI
    DI --> EntityMgmt
    DI --> ServiceClasses
    ServiceClasses --> PHPClasses
    PHPClasses --> TwigTemplates
    PHPClasses --> CompLogic
    CompLogic --> ServiceContainer
    ServiceContainer --> EventSystem
    EventSystem --> AssetMgmt
    AssetMgmt --> AssetCompilation
    AssetCompilation --> JSIntegration
    JSIntegration --> StimulusInteg

    %% Styles
    classDef php fill:#4F5D95,color:white
    classDef bundle fill:#2E5B88,color:white
    classDef template fill:#5B4282,color:white
    classDef bridge fill:#F0DB4F,color:black

    %% Legend
    subgraph Legend
        PHP["PHP Components"]:::php
        Bundle["Symfony Bundles"]:::bundle
        Template["Templates"]:::template
        Bridge["Bridge Components"]:::bridge
    end
```
