# rapidez/statamic architecture

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

- Interactive diagram: https://gitdiagram.com/rapidez/statamic
- Repository: https://github.com/rapidez/statamic

## Overview

##### Main Components
- Configuration & Setup: Represent the configuration files (found under the “config/rapidez” directory) that initialize Statamic-specific settings (including builder configuration).
- Resources & Templating: Include the various resources such as blueprints, fieldsets, JS assets (including Vue components), and Blade templates in the “resources” folder. This component deals with the frontend presentation and content structure.
- Core Business Logic: The “src” directory is the core of the package. It includes:
- Actions (business logic like sitemap generation and brand imports),
- Collections (managing data collections such as Brands, Categories, and Products),
- Commands (CLI commands for installation, importing, and cache invalidation),
- Controllers and HTTP logic (handling requests for imports and view composition),
- Jobs and Listeners (handling asynchronous tasks and event-driven actions),
- Models and Observers (providing data representation for brands, products, etc.).
- Extension & Integration Layers: This includes Facades, Service Providers (like RapidezStatamicServiceProvider.php) and custom Tags that expose the package’s extended functionality to both Rapidez and Statamic.
- Development Infrastructure: Don’t forget the developer-oriented components such as GitHub workflows, changelog automation, and composer.json for dependency management.

##### Component Interactions and Relationships
- A web request handled by a controller may trigger an Action (e.g., generating a sitemap) that is processed by a queued Job.
- A user action in the frontend (using JS components) might lead to an API call that is routed through HTTP controllers.
- Integration Points: Highlight how the Configuration layer feeds into the Core Business Logic (for example, pulling settings from “config/rapidez/statamic”) and how the Service Provider and Facade allow the package to hook into Rapidez and Statamic’s ecosystems.
- Asynchronous / Event-Driven Elements: Illustrate event listeners (e.g., ClearNavTreeCache, SetCollectionsForNav) reacting to changes (possibly from Commands or from Model Observers).

##### Architectural Patterns
- Separation of Concerns: The project clearly separates configuration, resource management (views, blueprints), and business logic.
- Modular Design: The “src” directory demonstrates a modular approach by splitting functionality into distinct folders (Actions, Commands, Collections) which is ideal for extendable integration.
- MVC-Inspired Structure: Even if not a full MVC application, there’s a mix of Controllers, Models, and Views (Blade templates) that follows MVC principles, particularly in the integration with Statamic.

##### Specific Technologies, Frameworks, or Libraries
- PHP with Composer for dependency management.
- Statamic as the integrated CMS.
- Vue.js in the “resources/js” folder for UI components.
- Blade templating engine indicated by the .blade.php files.
- GitHub Actions for CI/CD processes based on the workflows files.

## Diagram (Mermaid)

```mermaid
flowchart TD

    %% Configuration & Setup
    subgraph "Configuration & Setup"
        A1("Rapidez Config"):::config
        A2("Statamic Config"):::config
        A3("Builder Config"):::config
    end

    %% Resources & Templating
    subgraph "Resources & Templating"
        B1("Blueprints"):::resources
        B2("Blade Templates"):::resources
        B3("Vue Components"):::resources
    end

    %% Core Business Logic
    subgraph "Core Business Logic"
        C1("HTTP Controllers"):::core
        C2("Actions"):::core
        C3("Jobs"):::core
        C4("Commands"):::core
        C5("Collections"):::core
        C6("Models & Observers"):::core
        C7("Listeners"):::core
    end

    %% Extension & Integration Layers
    subgraph "Extension & Integration Layers"
        D1("Service Provider"):::extension
        D2("Facades"):::extension
        D3("Extend"):::extension
        D4("Tags"):::extension
    end

    %% Development Infrastructure
    subgraph "Development Infrastructure"
        E1("CI Workflows"):::dev
        E2("Composer & Changelog"):::dev
    end

    %% Data Flow Connections
    B2 -->|"handles_request"| C1
    B3 -->|"initiates_API_call"| C1
    C1 -->|"triggers_action"| C2
    C2 -->|"queues_job"| C3
    C2 -->|"fires_event"| C7
    C4 -->|"invokes_action"| C2
    C5 -->|"structures_data"| C6

    %% Configuration influences
    A1 -->|"provides_config"| C1
    A2 -->|"configures_behavior"| C2

    %% Integration Points
    D1 -->|"integrates_CMS"| C1
    D2 -->|"exposes_features"| C2
    D3 -->|"extends_functionality"| D2

    %% Resources Details
    B1 -->|"defines_structure"| B2

    %% Styles
    classDef config fill:#f9e79f,stroke:#B9770E,stroke-width:2px;
    classDef resources fill:#aed6f1,stroke:#1f618d,stroke-width:2px;
    classDef core fill:#d5f5e3,stroke:#27ae60,stroke-width:2px;
    classDef extension fill:#f5b7b1,stroke:#c0392b,stroke-width:2px;
    classDef dev fill:#fadbd8,stroke:#922b21,stroke-width:2px;

    %% Click Events for Configuration & Setup
    click A1 "https://github.com/rapidez/statamic/tree/master/config/rapidez"
    click A2 "https://github.com/rapidez/statamic/blob/master/config/rapidez/statamic.php"
    click A3 "https://github.com/rapidez/statamic/blob/master/config/rapidez/statamic/builder.php"

    %% Click Events for Resources & Templating
    click B1 "https://github.com/rapidez/statamic/tree/master/resources/blueprints"
    click B2 "https://github.com/rapidez/statamic/tree/master/resources/views"
    click B3 "https://github.com/rapidez/statamic/blob/master/resources/js/components/FormConditions.vue"

    %% Click Events for Core Business Logic
    click C1 "https://github.com/rapidez/statamic/tree/master/src/Http/Controllers"
    click C2 "https://github.com/rapidez/statamic/tree/master/src/Actions"
    click C3 "https://github.com/rapidez/statamic/tree/master/src/Jobs"
    click C4 "https://github.com/rapidez/statamic/tree/master/src/Commands"
    click C5 "https://github.com/rapidez/statamic/tree/master/src/Collections"
    click C6 "https://github.com/rapidez/statamic/tree/master/src/Models"
    click C7 "https://github.com/rapidez/statamic/tree/master/src/Listeners"

    %% Click Events for Extension & Integration Layers
    click D1 "https://github.com/rapidez/statamic/blob/master/src/RapidezStatamicServiceProvider.php"
    click D2 "https://github.com/rapidez/statamic/blob/master/src/Facades/RapidezStatamic.php"
    click D3 "https://github.com/rapidez/statamic/blob/master/src/Extend/SitesLinkedToMagentoStores.php"
    click D4 "https://github.com/rapidez/statamic/tree/master/src/Tags"

    %% Click Events for Development Infrastructure
    click E1 "https://github.com/rapidez/statamic/blob/master/.github"
    click E2 "https://github.com/rapidez/statamic/blob/master/composer.json"
```
