# opentiny/tiny-engine architecture

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

- Interactive diagram: https://gitdiagram.com/opentiny/tiny-engine
- Repository: https://github.com/opentiny/tiny-engine

## Overview

##### Main System Components
- Designer UI Client: This is the front-end “designer” application. Look at directories like “designer-demo” and packages such as “packages/design-core” and “packages/canvas”. These contain the canvas, components for layout, configurators, and the real-time preview.
- Plugin Ecosystem: Under “packages/plugins” you have many subpackages (block, bridge, datasource, help, i18n, materials, page, robot, state, tree, script, etc.). These represent independent plug-in modules that add extensibility and customized functionalities.
- Built-in Components & Configurators: Highlight “packages/builtinComponent” and “packages/configurator” which offer core UI components (like CanvasRow, CanvasCol, etc.) and configuration panels for low-code development.
- Engine CLI: The “packages/engine-cli” serves as a command-line tool to scaffold projects, generate configuration files, and bundle code for deployment.
- Supporting Services: Although the main focus is on the front-end and design frameworks, note the “mockServer” directory which simulates back-end APIs and data. Also, reference in the README the connection to external projects “tiny-engine-webservice” and “tiny-engine-data-center” for production integration.

##### How Components Interact
- The Designer UI interacts with users (developers) via a browser with a design canvas, configurable panels, and a real-time preview. It communicates with the back-end (or a mock server during local development) for fetching/saving application data.
- The Plugin modules are loosely coupled with the Designer. They extend functionality (e.g., block creation, advanced UI controls, material management) and interact with core components through well-defined APIs and extension hooks.
- The Engine CLI acts as a development tool to generate deployable source code based on the current design and configuration. It interacts with the core design system to output customized code.
- Built-in components (including canvas and layout modules) render the view and support real-time editing, while configurators provide property and event editing capabilities.

##### Architectural Patterns and Technologies
- Modular / Plugin Architecture: The repository is organized as a monorepo with many independent packages, enabling flexible extension and maintenance.
- Component-Based Front-End: Built primarily with Vue (as evidenced by *.vue files) and managed via Vite as the build tool.
- CLI & Code Generation: A dedicated CLI package for generating configuration and scaffolding output, which is critical for both high-code and low-code integration.
- Environment-Specific Configuration: Different parts (like “designer-demo”, “mockServer”, and multiple Vite config files) indicate support for development vs. production environments with live-reload and mock data features.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Front-End / Designer Layer
    subgraph "Front-End / Designer"
        DesignerDemo["Designer Demo (designer-demo)"]:::frontend
        DesignCore["Design Core (packages/design-core)"]:::frontend
        DesignCanvas["Design Canvas (packages/canvas)"]:::frontend
        Configurator["Configurator Panels (packages/configurator)"]:::frontend
        BuiltInComponents["Built-in Components (packages/builtinComponent)"]:::frontend
    end

    %% Other Layers and Components
    PluginEcosystem["Plugin Ecosystem (packages/plugins)"]:::plugin
    EngineCLI["Engine CLI (packages/engine-cli)"]:::cli
    MockServer["Mock Server (mockServer)"]:::backend
    Webservice["Tiny Engine Webservice"]:::external
    DataCenter["Tiny Engine Data Center"]:::external

    %% Internal Connections in Front-End / Designer
    DesignerDemo -->|"init"| DesignCore
    DesignCore -->|"renders"| DesignCanvas
    DesignCore -->|"configures"| Configurator
    DesignCore -->|"includes"| BuiltInComponents

    %% Plugin integration
    PluginEcosystem -->|"extends"| DesignCore

    %% CLI Code Generation
    EngineCLI -->|"generates-code"| DesignCore

    %% Communication with Backend / Services
    DesignCore -->|"fetch/save"| MockServer
    DesignCore -->|"integrates"| Webservice
    DesignCore -->|"integrates"| DataCenter

    %% Click Events
    click DesignerDemo "https://github.com/opentiny/tiny-engine/blob/develop/designer-demo/index.html"
    click DesignCore "https://github.com/opentiny/tiny-engine/tree/develop/packages/design-core/src"
    click DesignCanvas "https://github.com/opentiny/tiny-engine/tree/develop/packages/canvas/DesignCanvas"
    click Configurator "https://github.com/opentiny/tiny-engine/tree/develop/packages/configurator/src"
    click BuiltInComponents "https://github.com/opentiny/tiny-engine/tree/develop/packages/builtinComponent/src/components"
    click PluginEcosystem "https://github.com/opentiny/tiny-engine/tree/develop/packages/plugins"
    click EngineCLI "https://github.com/opentiny/tiny-engine/tree/develop/packages/engine-cli/src"
    click MockServer "https://github.com/opentiny/tiny-engine/blob/develop/mockServer/src/app.js"

    %% Styles
    classDef frontend fill:#f9d5e5,stroke:#333,stroke-width:2px;
    classDef plugin fill:#cfe2f3,stroke:#333,stroke-width:2px;
    classDef cli fill:#d9ead3,stroke:#333,stroke-width:2px;
    classDef backend fill:#ead1dc,stroke:#333,stroke-width:2px;
    classDef external fill:#fff2cc,stroke:#333,stroke-width:2px;
```
