# alibaba/formily architecture

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

- Interactive diagram: https://gitdiagram.com/alibaba/formily
- Repository: https://github.com/alibaba/formily

## Overview

##### Project type and purpose
- This is a large monorepo for Formily (https://formilyjs.org), an open-source framework for building high-performance, JSON-schema-driven forms in JavaScript/TypeScript.
- Components range from core state management to language-agnostic reactive engines, React/Vue bindings, form validators, JSON schema compiler, UI component packages (Ant Design, Element, Next UI), documentation, benchmarks, and Chrome DevTools extensions.

##### File structure
- Top-level:
- configuration files (.eslintrc, tsconfig.json, lerna.json, scripts/)
- devtools/ (Chrome extension source and build configs)
- docs/ (dumi-style documentation, guides, site code)
- packages/ (~20 sub-packages, each with src/, tests/, package.json, build configs)
- scripts/ (shared build and style pipelines)
- Key patterns:
- Monorepo managed by Lerna and Yarn workspaces
- Each package is self-contained: source, tests, rollup or webpack config, tsconfig
- Shared conventions: build-style.ts, create-style.ts in UI packages
- CI/CD: GitHub Actions workflows, Netlify deployment

##### README for additional insights
- Core selling points: independent field state management, JSON Schema integration, top-level UI wrappers
- Mentions form builder (external service), integrated Ant Design/Alibaba Fusion themes

##### Detailed elements
- External systems: GitHub Actions, Netlify, NPM registry

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Monorepo Configuration and Orchestration
    subgraph "Monorepo Orchestrator & Build"
        direction TB
        Orchestrator["Lerna/Yarn Workspaces"]:::tool
        Scripts["Build & Style Pipelines"]:::tool
        Orchestrator -->|manages| Scripts
    end
    click Orchestrator "https://github.com/alibaba/formily/blob/formily_next/lerna.json"
    click Scripts "https://github.com/alibaba/formily/tree/formily_next/scripts/"

    %% CI/CD
    CICD["CI/CD Workflows"]:::tool
    click CICD "https://github.com/alibaba/formily/tree/formily_next/.github/workflows/"

    CICD -->|triggers| Orchestrator

    %% Utility Layer
    subgraph "Utility Layer" 
        direction TB
        Shared["shared\n(Utils, Middleware, Types)"]:::util
        Path["path\n(Path Parser Utility)"]:::util
    end
    click Shared "https://github.com/alibaba/formily/tree/formily_next/packages/shared/"
    click Path "https://github.com/alibaba/formily/tree/formily_next/packages/path/"

    Shared --> Path

    %% Reactive Core
    subgraph "Reactive Core" 
        direction TB
        Reactive["reactive\n(JS Reactivity Engine)"]:::core
    end
    click Reactive "https://github.com/alibaba/formily/tree/formily_next/packages/reactive/"

    Shared --> Reactive

    %% Form Core Layer
    subgraph "Form Core & Subsystems"
        direction TB
        Core["core\n(Form Models, State, MVVM)"]:::core
        JsonSchema["json-schema\n(Schema Compiler)"]:::core
        Validator["validator\n(Validation Engine)"]:::core
        Grid["grid\n(Layout Logic)"]:::core
    end
    click Core "https://github.com/alibaba/formily/tree/formily_next/packages/core/"
    click JsonSchema "https://github.com/alibaba/formily/tree/formily_next/packages/json-schema/"
    click Validator "https://github.com/alibaba/formily/tree/formily_next/packages/validator/"
    click Grid "https://github.com/alibaba/formily/tree/formily_next/packages/grid/"

    Shared --> JsonSchema
    Shared --> Validator
    Shared --> Grid
    Reactive --> Core
    Core --> JsonSchema
    Core --> Validator
    Core --> Grid
    Path --> Core

    %% Framework Adapters
    subgraph "Framework Adapters"
        direction TB
        ReactiveReact["reactive-react\n(React Adapter)"]:::adapter
        ReactiveVue["reactive-vue\n(Vue Adapter)"]:::adapter
    end
    click ReactiveReact "https://github.com/alibaba/formily/tree/formily_next/packages/reactive-react/"
    click ReactiveVue "https://github.com/alibaba/formily/tree/formily_next/packages/reactive-vue/"

    Reactive --> ReactiveReact
    Reactive --> ReactiveVue

    %% Binding Components
    subgraph "Binding Components"
        direction TB
        ReactBind["react\n(React Binding Components)"]:::adapter
        VueBind["vue\n(Vue Binding Components)"]:::adapter
    end
    click ReactBind "https://github.com/alibaba/formily/tree/formily_next/packages/react/"
    click VueBind "https://github.com/alibaba/formily/tree/formily_next/packages/vue/"

    ReactiveReact --> ReactBind
    ReactiveVue --> VueBind

    %% UI Component Libraries
    subgraph "UI Component Libraries"
        direction TB
        Antd["antd\n(Ant Design UI)"]:::ui
        Element["element\n(Element UI)"]:::ui
        NextUI["next\n(Next UI)"]:::ui
    end
    click Antd "https://github.com/alibaba/formily/tree/formily_next/packages/antd/"
    click Element "https://github.com/alibaba/formily/tree/formily_next/packages/element/"
    click NextUI "https://github.com/alibaba/formily/tree/formily_next/packages/next/"

    ReactBind --> Antd
    ReactBind --> NextUI
    VueBind --> Element

    %% Tooling & Documentation
    subgraph "Tooling & Documentation"
        direction TB
        Devtools["Chrome Extension"]:::tool
        Docs["Documentation Site"]:::doc
        Benchmark["Benchmark Suite"]:::tool
        TestCases["Reactive Test Cases"]:::tool
    end
    click Devtools "https://github.com/alibaba/formily/tree/formily_next/devtools/chrome-extension/"
    click Docs "https://github.com/alibaba/formily/tree/formily_next/docs/site/"
    click Benchmark "https://github.com/alibaba/formily/tree/formily_next/packages/benchmark/"
    click TestCases "https://github.com/alibaba/formily/tree/formily_next/packages/reactive-test-cases-for-react18/"

    Core -->|runtime injection| Devtools
    Core --> Docs
    Antd --> Docs
    Element --> Docs
    NextUI --> Docs

    %% Publish Flow
    Orchestrator -->|build/publish| npm["NPM Registry"]:::external

    %% Styles
    classDef util fill:#a8e6cf,stroke:#2d6a4f,color:#045a32;
    classDef core fill:#cfe0e8,stroke:#1b365d,color:#1b365d;
    classDef adapter fill:#ffd3b6,stroke:#d35400,color:#922b21;
    classDef ui fill:#e0bbff,stroke:#6a0dad,color:#4b0082;
    classDef tool fill:#f0f0f0,stroke:#555555,color:#333333;
    classDef doc fill:#dddddd,stroke:#444444,color:#222222;
    classDef external fill:#ffffff,stroke:#888888,color:#000000;
```
