# drush-ops/drush architecture

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

- Interactive diagram: https://gitdiagram.com/drush-ops/drush
- Repository: https://github.com/drush-ops/drush

## Overview

##### Main Components

a. Core Components:
- Command System (src/Commands/*)
- Bootstrap System (src/Boot/*)
- Site Alias Manager (src/SiteAlias/*)
- Configuration System (src/Config/*)
- Runtime Environment (src/Runtime/*)
- SQL Handling System (src/Sql/*)

b. Integration Layers:
- Drupal Integration Layer (src/Drupal/*)
- Symfony Integration Layer (src/Symfony/*)
- Composer Integration

c. Extension Systems:
- Command Discovery
- Plugin System
- Generator System (src/Commands/generate/*)

##### Architectural Pattern Representation

- Blue rectangles: Core services
- Green rectangles: Command implementations
- Yellow diamonds: Integration points
- Red octagons: Security boundaries
- Purple circles: Extension points

##### Component Details

Core Services Layer:
**┌─────────────────────────────────────┐**
- Drush Core                │
- ┤
- Bootstrap Manager                 │
- Configuration System              │
- Site Alias Manager               │
- Command Registry                  │
- ┘

Command Layer:
**┌─────────────────────────────────────┐**
- Command System              │
- ┤
- Core Commands                     │
- SQL Commands                      │
- Generate Commands                 │
- Custom Commands                   │
- ┘

Integration Layer:
**┌─────────────────────────────────────┐**
- Integration Interfaces         │
- ┤
- Drupal Bootstrap                  │
- Symfony Console                   │
- Composer Integration              │
- ┘

##### Key Elements to Highlight

- Command Discovery System
- Configuration Hierarchy
- Site Alias Management
- Remote Execution Capability
- Database Handling
- Generator Subsystem

##### Implementation Details

Key aspects:
- Service Container Integration
- Event System
- Plugin Architecture
- Command Registration
- Configuration Loading

##### External Dependencies

Connections to:
- Drupal Core
- Symfony Components
- Composer
- Database Systems

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Legend
        style Legend fill:#f0f0f0,stroke:#333,stroke-width:2px
        L1[Core Services]:::core
        L2[Command Components]:::command
        L3{Integration Points}:::integration
        L4((Extension Points)):::extension
        L5[/Security Boundaries/]:::security
    end

    subgraph EntryPoint
        EP[Entry Point]:::core
    end

    subgraph CoreServices
        BS[Bootstrap Manager]:::core
        CS[Configuration System]:::core
        SAM[Site Alias Manager]:::core
        CR[Command Registry]:::core
        RE[Runtime Environment]:::core
    end

    subgraph CommandSystem
        CMD[Command System]:::command
        CORECMD[Core Commands]:::command
        SQLCMD[SQL Commands]:::command
        GENCMD[Generate Commands]:::command
        CUSTCMD[Custom Commands]:::command
    end

    subgraph IntegrationLayer
        DI{Drupal Integration}:::integration
        SI{Symfony Integration}:::integration
        CI{Composer Integration}:::integration
    end

    subgraph ExtensionSystem
        CD((Command Discovery)):::extension
        PS((Plugin System)):::extension
        GS((Generator System)):::extension
    end

    subgraph SecurityBoundary
        REM[/Remote Execution/]:::security
        DBH[/Database Handling/]:::security
    end

    EP --> BS
    BS --> CS
    BS --> SAM
    BS --> CR
    BS --> RE

    CR --> CMD
    CMD --> CORECMD
    CMD --> SQLCMD
    CMD --> GENCMD
    CMD --> CUSTCMD

    SAM --> REM
    SQLCMD --> DBH

    CMD --> DI
    CMD --> SI
    CMD --> CI

    CMD --> CD
    CMD --> PS
    GENCMD --> GS

    classDef core fill:#a8d1f0,stroke:#333,stroke-width:2px
    classDef command fill:#90EE90,stroke:#333,stroke-width:2px
    classDef integration fill:#FFD700,stroke:#333,stroke-width:2px
    classDef extension fill:#DDA0DD,stroke:#333,stroke-width:2px
    classDef security fill:#FF6B6B,stroke:#333,stroke-width:2px

    click BS "https://github.com/drush-ops/drush/blob/13.x/src/Boot/BootstrapManager.php"
    click CS "https://github.com/drush-ops/drush/blob/13.x/src/Config/DrushConfig.php"
    click SAM "https://github.com/drush-ops/drush/blob/13.x/src/SiteAlias/SiteAliasFileLoader.php"
    click RE "https://github.com/drush-ops/drush/blob/13.x/src/Runtime/Runtime.php"
    click CMD "https://github.com/drush-ops/drush/tree/13.x/src/Commands/"
    click CORECMD "https://github.com/drush-ops/drush/tree/13.x/src/Commands/core/"
    click SQLCMD "https://github.com/drush-ops/drush/tree/13.x/src/Commands/sql/"
    click GENCMD "https://github.com/drush-ops/drush/tree/13.x/src/Commands/generate/"
    click DI "https://github.com/drush-ops/drush/tree/13.x/src/Drupal/"
    click SI "https://github.com/drush-ops/drush/tree/13.x/src/Symfony/"
    click GS "https://github.com/drush-ops/drush/tree/13.x/src/Commands/generate/Generators/"
    click DBH "https://github.com/drush-ops/drush/blob/13.x/src/Sql/SqlBase.php"
```
