# prodigyphp/prodigy architecture

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

- Interactive diagram: https://gitdiagram.com/prodigyphp/prodigy
- Repository: https://github.com/prodigyphp/prodigy

## Overview

##### Main System Components

a) Core Components:
- Page Builder Engine (src/Prodigy.php as the main entry point)
- Block Management System
- Authentication System
- Content Management System
- Asset Management

b) Frontend Components:
- Editor Interface (Livewire components)
- Block Rendering System
- Asset Pipeline (CSS/JS/Images)

##### Architectural Patterns to Highlight

a) MVC Pattern:
- Models (src/Models/)
- Views (resources/views/)
- Controllers (src/Http/Controllers/)

b) Component-Based Architecture:
- Block Components
- Field Components
- Editor Components

##### Specific Implementation Details

**┌─ Client Layer ─────────────────────┐**
- Browser Interface                │
- Livewire Components             │
- Alpine.js                       │
- ┬───────────────────┘
- ↕ HTTP/WebSocket
**┌─ Application Layer ────────────────┐**
- ┌─ Page Builder Core ────────────┐ │
- Block Management            │ │
- Page Management            │ │
- Content Management         │ │
- ┘ │
- ┌─ Services ───────────────────┐   │
- Authentication            │   │
- Asset Management         │   │
- Backup System           │   │
- ┘   │
- ┬───────────────────┘
- ↕
**┌─ Storage Layer ──────────────────┐**
- Database                       │
- File Storage (Media/Assets)    │
- ┘

##### Key Interactions

- User interactions with the editor
- Block rendering flow
- Content saving/loading
- Media upload/management
- Authentication flow

##### Important Technical Elements

- Laravel Framework
- Livewire
- Alpine.js
- CKEditor
- CodeMirror
- Database (MySQL/PostgreSQL)

##### Integration Points

Connections with:
- Laravel's core systems
- External asset delivery
- Database interactions
- File system operations

Remember to:
- Use consistent styling
- Notes for complex interactions
- Both synchronous and asynchronous flows

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        Browser["Browser Interface"]
        LW["Livewire Components"]:::livewire
        ALP["Alpine.js Components"]
        click LW "https://github.com/prodigyphp/prodigy/tree/main/resources/views/livewire/"
    end

    subgraph "Page Builder Core"
        PBE["Page Builder Engine"]:::core
        BMS["Block Management System"]:::core
        CMS["Content Management System"]:::core
        click PBE "https://github.com/prodigyphp/prodigy/blob/main/src/Prodigy.php"
        click BMS "https://github.com/prodigyphp/prodigy/tree/main/src/BlockGroups/"
        click CMS "https://github.com/prodigyphp/prodigy/tree/main/src/Models/"
    end

    subgraph "Component Layer"
        BC["Block Components"]:::component
        FC["Field Components"]:::component
        EC["Editor Components"]:::component
        click BC "https://github.com/prodigyphp/prodigy/tree/main/resources/views/components/blocks/"
        click FC "https://github.com/prodigyphp/prodigy/tree/main/src/FieldTypes/"
        click EC "https://github.com/prodigyphp/prodigy/tree/main/resources/views/components/editor/"
    end

    subgraph Services
        Auth["Authentication System"]:::service
        Asset["Asset Management"]:::service
        Backup["Backup System"]:::service
        click Auth "https://github.com/prodigyphp/prodigy/blob/main/src/Http/Controllers/LoginController.php"
        click Asset "https://github.com/prodigyphp/prodigy/blob/main/public/css/prodigy.css"
        click Backup "https://github.com/prodigyphp/prodigy/blob/main/src/Actions/BackupAction.php"
    end

    subgraph "Data Layer"
        DB[(Database)]:::storage
        FS["File Storage"]:::storage
        click DB "https://github.com/prodigyphp/prodigy/blob/main/database/migrations/2023_03_01_create_prodigy_tables.php.stub"
    end

    subgraph Models
        BM["Block Model"]:::model
        EM["Entry Model"]:::model
        PM["Page Model"]:::model
        UM["User Model"]:::model
        click BM "https://github.com/prodigyphp/prodigy/blob/main/src/Models/Block.php"
        click EM "https://github.com/prodigyphp/prodigy/blob/main/src/Models/Entry.php"
        click PM "https://github.com/prodigyphp/prodigy/blob/main/src/Models/Page.php"
        click UM "https://github.com/prodigyphp/prodigy/blob/main/src/Models/User.php"
    end

    Browser --> LW
    LW --> ALP
    LW --> PBE
    PBE --> BMS
    PBE --> CMS
    BMS --> BC
    CMS --> FC
    EC --> BC
    EC --> FC
    Auth --> UM
    Asset --> FS
    CMS --> Models
    Models --> DB
    Backup --> FS
    Backup --> DB

    classDef core fill:#2563eb,color:white
    classDef component fill:#16a34a,color:white
    classDef service fill:#9333ea,color:white
    classDef storage fill:#ea580c,color:white
    classDef model fill:#0891b2,color:white
    classDef livewire fill:#4f46e5,color:white

    %% Legend
    classDef legend fill:#f1f5f9,stroke:#94a3b8
    subgraph Legend
        L1["Core Components"]:::core
        L2["UI Components"]:::component
        L3["Services"]:::service
        L4["Storage"]:::storage
        L5["Models"]:::model
        L6["Livewire"]:::livewire
    end
```
