# ctrlv-git/lcaas-form architecture

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

- Interactive diagram: https://gitdiagram.com/ctrlv-git/lcaas-form
- Repository: https://github.com/ctrlv-git/lcaas-form

## Overview

##### Project type and purpose
- This is a front-end monorepo (pnpm workspace) for a low-code form engine built on Vue 3 + Vite + Naive UI.
- It contains two packages:
- form-editor: a visual form designer SPA
- form-render: a form renderer library (Vue component) for consumer apps
- Purpose: allow developers to design JSON-based forms in a GUI, then render those forms in any Vue 3 application.

##### File structure
- Root
- pnpm-workspace.yaml, package.json, tsconfig.node.json
- workspace packages/
- packages/form-editor (Designer)
- Vite config, env files, package.json
- public/ + index.html → static assets
- src/
– components/ (drag/drop, panels, toolbar, widget settings)
– config/ (field definitions, default values, render presets)
– hooks/ (useDesigner, useEventBus)
– plugins/ (global components, directives, SVGO, Naive UI)
– router/ (route modules, guards, generator)
– store/ (Vuex-style modules)
– utils/ (operations, generic utilities)
– views/ (Editor.vue, Preview.vue, 404)
– main.ts, App.vue, theme, styles, types
- packages/form-render (Renderer)
- Vite config, package.json
- src/
– components/ (slot wrappers)
– form-item/ (core form field abstraction + slot implementations)
– utils/ (data transformations)
– main entry (render.vue)
– types
- www/ folder: compiled, gzipped assets of form-editor SPA

##### README for additional insights
- Confirms separation of designer and renderer to minimize bundle size.
- Renderer is published as @lcaas/form-render on npm.
- Designer is built via `pnpm build` → static SPA deployed to GitHub Pages (www).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Monorepo Root
    subgraph "Monorepo Root"
        direction TB
        MonoConfig1["pnpm-workspace.yaml"]:::internal
        MonoConfig2["tsconfig.node.json"]:::internal
    end

    %% Designer SPA
    subgraph "Designer SPA (form-editor)" 
        direction TB
        DE_Vite["vite.config.ts"]:::internal
        DE_Env1[".env"]:::internal
        DE_Env2[".env.development"]:::internal
        DE_Public["public (static assets)"]:::internal
        DE_HTML["index.html"]:::internal
        DE_Main["src/main.ts"]:::internal
        DE_App["src/App.vue"]:::internal
        DE_Components["src/components"]:::internal
        DE_Config["src/config"]:::internal
        DE_Hooks["src/hooks"]:::internal
        DE_Plugins["src/plugins"]:::internal
        DE_Router["src/router"]:::internal
        DE_Store["src/store"]:::internal
        DE_Utils["src/utils"]:::internal
        DE_Views["src/views"]:::internal
        DE_Types["types"]:::internal
    end

    %% Renderer Library
    subgraph "Renderer Library (form-render)"
        direction TB
        RE_Vite["vite.config.ts"]:::internal
        RE_Entry["src/main.ts"]:::internal
        RE_Render["src/render.vue"]:::internal
        RE_Comp["src/components"]:::internal
        RE_FormItem["src/form-item"]:::internal
        RE_Utils["src/utils"]:::internal
        RE_Types["types"]:::internal
    end

    %% Build Pipelines
    subgraph "Build & Publish" 
        direction TB
        DevServe["Vite Dev Server"]:::build
        DesignerBuild["Designer Build → www/"]:::build
        RendererBuild["Renderer Build → npm package"]:::build
        DeploymentHost["GitHub Pages Host"]:::external
        NpmRegistry["NPM Registry (@lcaas/form-render)"]:::external
    end

    %% External Consumer
    Consumer["External Consumer App"]:::external

    %% Relationships
    Developer["Developer"]:::external
    Developer -->|"edit source"| DE_Main
    Developer -->|"edit source"| RE_Entry

    DE_Vite -->|"serves"| DevServe
    DevServe -->|"runs SPA in Browser"| Browser["Browser"]:::external

    DesignerBuild --> DE_Public
    DesignerBuild --> DE_HTML
    DesignerBuild --> DeploymentHost

    DE_Main -->|"exports JSON schema"| Schema["JSON Schema"]:::build
    Schema -->|"import and render"| Consumer

    RE_Entry --> RendererBuild
    RendererBuild --> NpmRegistry
    Consumer -->|"npm install @lcaas/form-render"| NpmRegistry
    Consumer -->|"uses <lc-form :conf/>"| RE_Render

    %% Click events
    click MonoConfig1 "https://github.com/ctrlv-git/lcaas-form/blob/main/pnpm-workspace.yaml"
    click MonoConfig2 "https://github.com/ctrlv-git/lcaas-form/blob/main/tsconfig.node.json"
    click DE_Vite "https://github.com/ctrlv-git/lcaas-form/blob/main/packages/form-editor/vite.config.ts"
    click DE_Env1 "https://github.com/ctrlv-git/lcaas-form/blob/main/packages/form-editor/.env"
    click DE_Env2 "https://github.com/ctrlv-git/lcaas-form/blob/main/packages/form-editor/.env.development"
    click DE_Public "https://github.com/ctrlv-git/lcaas-form/tree/main/packages/form-editor/public"
    click DE_HTML "https://github.com/ctrlv-git/lcaas-form/blob/main/packages/form-editor/index.html"
    click DE_Main "https://github.com/ctrlv-git/lcaas-form/blob/main/packages/form-editor/src/main.ts"
    click DE_App "https://github.com/ctrlv-git/lcaas-form/blob/main/packages/form-editor/src/App.vue"
    click DE_Components "https://github.com/ctrlv-git/lcaas-form/tree/main/packages/form-editor/src/components"
    click DE_Config "https://github.com/ctrlv-git/lcaas-form/tree/main/packages/form-editor/src/config"
    click DE_Hooks "https://github.com/ctrlv-git/lcaas-form/tree/main/packages/form-editor/src/hooks"
    click DE_Plugins "https://github.com/ctrlv-git/lcaas-form/tree/main/packages/form-editor/src/plugins"
    click DE_Router "https://github.com/ctrlv-git/lcaas-form/tree/main/packages/form-editor/src/router"
    click DE_Store "https://github.com/ctrlv-git/lcaas-form/tree/main/packages/form-editor/src/store"
    click DE_Utils "https://github.com/ctrlv-git/lcaas-form/tree/main/packages/form-editor/src/utils"
    click DE_Views "https://github.com/ctrlv-git/lcaas-form/tree/main/packages/form-editor/src/views"
    click DE_Types "https://github.com/ctrlv-git/lcaas-form/tree/main/packages/form-editor/types"
    click RE_Vite "https://github.com/ctrlv-git/lcaas-form/blob/main/packages/form-render/vite.config.ts"
    click RE_Entry "https://github.com/ctrlv-git/lcaas-form/blob/main/packages/form-render/src/main.ts"
    click RE_Render "https://github.com/ctrlv-git/lcaas-form/blob/main/packages/form-render/src/render.vue"
    click RE_Comp "https://github.com/ctrlv-git/lcaas-form/tree/main/packages/form-render/src/components"
    click RE_FormItem "https://github.com/ctrlv-git/lcaas-form/tree/main/packages/form-render/src/form-item"
    click RE_Utils "https://github.com/ctrlv-git/lcaas-form/tree/main/packages/form-render/src/utils"
    click RE_Types "https://github.com/ctrlv-git/lcaas-form/tree/main/packages/form-render/types"

    %% Styles
    classDef internal fill:#D0E8FF,stroke:#0366d6
    classDef build fill:#D0FFD0,stroke:#2e7d32
    classDef external fill:#FFE0B2,stroke:#e65100
```
