# acquia/cohesion architecture

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

- Interactive diagram: https://gitdiagram.com/acquia/cohesion
- Repository: https://github.com/acquia/cohesion

## Overview

##### Main Components

a. Core Module Components:
- API Management System
- Entity Management
- Template System
- Style Management
- Layout Canvas

- Base Styles
- Custom Styles
- Elements
- Style Helpers
- Templates
- Website Settings
- Page Builder
- Sync System
- Data Transformers

##### Integration Points

a. External Services:
- Google Maps API integration (optional)
- Media Management Systems

b. Drupal Core Integration:
- Connections to:
- Drupal Config System
- Entity API
- Field System
- Views System
- Media System

##### Data Flow Architecture

**Frontend Request → Drupal → Site Studio Template System → Layout Canvas → Rendered Output**
**Config Changes → Sync System → Package Management → File/Database Storage**
**Style Updates → Style API → CSS Generation → File System**

##### Key Subsystems

a. Template Management:
- Content Templates
- Master Templates
- Menu Templates
- View Templates

b. Style System:
- Base Styles
- Custom Styles
- Style Helpers
- Website Settings

c. Component System:
- Custom Components
- Element Management
- Layout Builder Integration

##### Storage Systems

Connections to:
- Database (config entities)
- File System (assets, generated CSS)
- Key-Value Storage (temporary data)
- Sync Directory (package management)

##### Development Tools

Include:
- Drush Integration
- API Endpoints
- Development Tools
- Testing Framework

##### Specific Implementation Details

Specialized components:
- Custom Element System
- Style Guide Management
- Governance Controls
- Data Transformation Pipeline

##### Event System

Event dispatch system:
- PreRebuildEvent
- PostRebuildEvent
- Custom Event Subscribers

##### Security Layer

Include:
- XSS Protection
- API Key Management
- Permission System
- Access Control

- Modular architecture
- Clear separation of concerns
- Integration points with Drupal core
- External service dependencies
- Data flow patterns
- Event-driven architecture

Remember to include version control integration points and deployment considerations in the overall architecture visualization.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Core["Site Studio Core"]
        API[API Management System]
        EM[Entity Management]
        TS[Template System]
        SM[Style Management]
        LC[Layout Canvas]
    end

    subgraph Modules["Sub-modules"]
        BS[Base Styles]
        CS[Custom Styles]
        EL[Elements]
        SH[Style Helpers]
        TP[Templates]
        WS[Website Settings]
        PB[Page Builder]
        SY[Sync System]
        DT[Data Transformers]
    end

    subgraph External["External Services"]
        SAPI[Site Studio API]
        GAPI[Google Maps API]
        MMS[Media Management]
    end

    subgraph Drupal["Drupal Integration"]
        DC[Config System]
        EA[Entity API]
        FS[Field System]
        VS[Views System]
        MS[Media System]
    end

    subgraph Storage["Storage Systems"]
        DB[(Database)]
        FILES[File System]
        KV[Key-Value Store]
        SD[Sync Directory]
    end

    subgraph Security["Security Layer"]
        XSS[XSS Protection]
        AKM[API Key Management]
        PS[Permission System]
        AC[Access Control]
    end

    subgraph Events["Event System"]
        PRE[PreRebuildEvent]
        POST[PostRebuildEvent]
        ES[Event Subscribers]
    end

    %% Core connections
    API --> EM
    EM --> TS
    TS --> LC
    SM --> LC

    %% Module connections
    BS --> SM
    CS --> SM
    EL --> LC
    SH --> SM
    TP --> TS
    WS --> SM
    PB --> LC
    SY --> DB
    DT --> TS

    %% External connections
    SAPI --> API
    GAPI --> API
    MMS --> MS

    %% Storage connections
    EM --> DB
    TS --> FILES
    SM --> FILES
    SY --> SD

    %% Security connections
    XSS --> API
    AKM --> API
    PS --> AC
    AC --> API

    %% Event system connections
    PRE --> TS
    POST --> TS
    ES --> TS

    %% Click events
    click API "https://github.com/acquia/cohesion/blob/8.0.x/src/ApiPluginBase.php"
    click EM "https://github.com/acquia/cohesion/blob/8.0.x/src/Entity/CohesionConfigEntityBase.php"
    click TS "https://github.com/acquia/cohesion/tree/8.0.x/modules/cohesion_templates"
    click SM "https://github.com/acquia/cohesion/tree/8.0.x/modules/cohesion_base_styles"
    click LC "https://github.com/acquia/cohesion/blob/8.0.x/src/LayoutCanvas/LayoutCanvas.php"
    click BS "https://github.com/acquia/cohesion/tree/8.0.x/modules/cohesion_base_styles"
    click CS "https://github.com/acquia/cohesion/tree/8.0.x/modules/cohesion_custom_styles"
    click EL "https://github.com/acquia/cohesion/tree/8.0.x/modules/cohesion_elements"
    click SH "https://github.com/acquia/cohesion/tree/8.0.x/modules/cohesion_style_helpers"
    click WS "https://github.com/acquia/cohesion/tree/8.0.x/modules/cohesion_website_settings"
    click PB "https://github.com/acquia/cohesion/tree/8.0.x/modules/sitestudio_page_builder"
    click SY "https://github.com/acquia/cohesion/tree/8.0.x/modules/cohesion_sync"
    click DT "https://github.com/acquia/cohesion/tree/8.0.x/modules/sitestudio_data_transformers"
    click XSS "https://github.com/acquia/cohesion/blob/8.0.x/src/Plugin/Filter/BlackListHTMLTags.php"
    click ES "https://github.com/acquia/cohesion/tree/8.0.x/src/Event"

    classDef core fill:#2374ab
    classDef module fill:#ff8c42
    classDef external fill:#45b7d1
    classDef storage fill:#f4d03f
    classDef security fill:#e74c3c
    classDef event fill:#8e44ad

    class API,EM,TS,SM,LC core
    class BS,CS,EL,SH,TP,WS,PB,SY,DT module
    class SAPI,GAPI,MMS external
    class DB,FILES,KV,SD storage
    class XSS,AKM,PS,AC security
    class PRE,POST,ES event
```
