# agritheory/stonecrop architecture

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

- Interactive diagram: https://gitdiagram.com/agritheory/stonecrop
- Repository: https://github.com/agritheory/stonecrop

## Overview

##### Main System Components

a) Frontend Components Layer:
- UI Components (@stonecrop/aform, @stonecrop/atable, @stonecrop/beam)
- Editor Components (@stonecrop/code_editor, @stonecrop/node_editor)
- Desktop Interface (@stonecrop/desktop)
- Theme System (@stonecrop/themes)

b) Core Layer:
- Main Stonecrop Engine (@stonecrop/stonecrop)
- Schema Processing
- Event Handling System

c) Communication Layer:
- GraphQL Client (@stonecrop/graphql_client)
- Server Middleware Integration

##### Component Relationships

Key interactions:
- Schema flow from core to UI components
- Event propagation paths
- Theme application to components
- GraphQL client data flow

##### Architectural Patterns to Highlight

- Schema-driven UI architecture
- Event-driven hooks system
- Component composition model
- Plugin architecture

- Rectangles: Main packages/modules
- Hexagons: Core services
- Rounded rectangles: UI components

- Blue: Frontend components
- Green: Core services
- Orange: Communication layers
- Purple: Utilities and shared services

- Solid: Direct dependencies

##### Key Relationships

**@stonecrop/stonecrop (Core)**
**↓**
**Schema Processing**
**↓**
**UI Components (@stonecrop/aform, @stonecrop/atable, etc.)**
**↔**
**Event System**
**↔**
**GraphQL Client**
**↔**
**Backend Services**

##### Implementation Details

- Schema validation and processing flow
- Component initialization and registration
- Event hook registration and execution paths
- Theme application system
- GraphQL client integration

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Frontend
        UI[UI Components]
        ED[Editor Components]
        DI["Desktop Interface"]:::desktop
        TH["Theme System"]:::theme
    end

    subgraph Core
        CE["Stonecrop Engine"]:::core
        SP["Schema Processing"]:::schema
        EH["Event Handling"]:::event
        SM["State Management"]:::state
        RT["Router System"]:::router
        PA["Plugin Architecture"]:::plugin
    end

    subgraph Communication
        GC["GraphQL Client"]:::graphql
        MI["Server Middleware"]
    end

    subgraph "UI Components Detail"
        UI --> AF["Form Component"]:::ui
        UI --> AT["Table Component"]:::ui
        UI --> BE["Beam Component"]:::ui
    end

    subgraph "Editor Components Detail"
        ED --> CE1["Code Editor"]:::editor
        ED --> NE["Node Editor"]:::editor
    end

    subgraph "Schema Processing Detail"
        SP --> DT["Document Type"]:::schema
        SP --> RG["Registry"]:::schema
    end

    %% Core relationships
    CE --> SP
    CE --> EH
    CE --> SM
    CE --> RT
    CE --> PA

    %% Frontend to Core relationships
    UI --> CE
    ED --> CE
    DI --> CE
    TH --> UI
    TH --> ED
    TH --> DI

    %% Communication relationships
    GC --> CE
    MI --> GC

    %% Component click mappings
    click AF "https://github.com/agritheory/stonecrop/blob/development/aform/src/components/AForm.vue"
    click AT "https://github.com/agritheory/stonecrop/blob/development/atable/src/components/ATable.vue"
    click BE "https://github.com/agritheory/stonecrop/tree/development/beam/src/components"
    click CE1 "https://github.com/agritheory/stonecrop/blob/development/code_editor/src/components/ACodeEditor.vue"
    click NE "https://github.com/agritheory/stonecrop/blob/development/node_editor/src/components/NodeEditor.vue"
    click DI "https://github.com/agritheory/stonecrop/blob/development/desktop/src/components/Desktop.vue"
    click TH "https://github.com/agritheory/stonecrop/tree/development/themes"
    click CE "https://github.com/agritheory/stonecrop/blob/development/stonecrop/src/stonecrop.ts"
    click DT "https://github.com/agritheory/stonecrop/blob/development/stonecrop/src/doctype.ts"
    click RG "https://github.com/agritheory/stonecrop/blob/development/stonecrop/src/registry.ts"
    click EH "https://github.com/agritheory/stonecrop/tree/development/stonecrop/src/stores"
    click GC "https://github.com/agritheory/stonecrop/blob/development/graphql_client/src/index.ts"
    click SM "https://github.com/agritheory/stonecrop/blob/development/stonecrop/src/stores/data.ts"
    click RT "https://github.com/agritheory/stonecrop/blob/development/stonecrop/src/router.ts"
    click PA "https://github.com/agritheory/stonecrop/blob/development/stonecrop/src/plugins/index.ts"

    %% Styling
    classDef ui fill:#3498db,stroke:#2980b9,color:white
    classDef editor fill:#9b59b6,stroke:#8e44ad,color:white
    classDef desktop fill:#2ecc71,stroke:#27ae60,color:white
    classDef theme fill:#f1c40f,stroke:#f39c12,color:white
    classDef core fill:#e74c3c,stroke:#c0392b,color:white
    classDef schema fill:#1abc9c,stroke:#16a085,color:white
    classDef event fill:#34495e,stroke:#2c3e50,color:white
    classDef state fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef router fill:#d35400,stroke:#a04000,color:white
    classDef plugin fill:#8e44ad,stroke:#703688,color:white
    classDef graphql fill:#e67e22,stroke:#d35400,color:white

    %% Legend
    subgraph Legend
        L1["UI Component"]:::ui
        L2["Editor Component"]:::editor
        L3["Desktop Interface"]:::desktop
        L4["Theme System"]:::theme
        L5["Core Engine"]:::core
        L6["Schema Processing"]:::schema
        L7["Event Handling"]:::event
        L8["State Management"]:::state
        L9["Router System"]:::router
        L10["Plugin System"]:::plugin
        L11["GraphQL"]:::graphql
    end
```
