# neugrp/vue-tree-chart architecture

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

- Interactive diagram: https://gitdiagram.com/neugrp/vue-tree-chart
- Repository: https://github.com/neugrp/vue-tree-chart

## Overview

##### Project type and purpose
- This is a Vue-based component library (“vue-tree-chart”) that renders interactive tree charts. It ships as a distributable bundle (CommonJS & UMD) and includes a demo/docs site.

##### File structure
- Top-level config files:
- babel.config.js – Babel transpilation rules
- vue.config.js – Vue CLI / Webpack configuration
- .eslintrc.js, .browserslistrc, .gitignore, .npmignore
- src/ – source code (Vue components & assets)
- App.vue – entry component for the demo
- components/TreeChart.vue – the core chart component
- main.js – demo app bootstrap
- assets/ – static assets (images, styles)
- public/ – static HTML for the demo (index.html)
- dist/ – built bundles and a standalone demo page (demo.html)
- docs/ – generated documentation site (HTML/JS bundles)
- package.json – dependencies, scripts (“serve”, “build-bundle”)

##### README for additional insights
- Purpose: provide a `<TreeChart>` Vue component, accept a JSON tree, emit click-node events.
- Build & publish flow: `npm run build-bundle` → dist, then publish to npm.
- Demo run: `npm run serve` launches the example app (src + public) via Vue CLI.

a. Main components:
- Developer’s Source Workspace
- src/components/TreeChart.vue (component logic + template + style)
- src/assets (static resources)
- demo app (src/App.vue + src/main.js + public/index.html)
- Toolchain & Build System
- Babel (transpiles ES/JSX to target JS)
- Webpack (bundles modules into CommonJS & UMD)
- ESLint (code quality)
- Output Artifacts
- dist/TreeChart.common.js (CommonJS)
- dist/TreeChart.umd.js (UMD for direct browser use)
- dist/demo.html (standalone demo)
- Documentation Site
- docs/index.html + docs/js/* (built by a static-site generator or Vue CLI)
- Consumers
- npm registry (package distribution)
- Downstream Vue applications importing `vue-tree-chart`

b. Relationships & interactions:
1. Developer writes/edits `src/components/TreeChart.vue`.
2. On `npm run serve`, Webpack Dev Server compiles demo (src + component) → serves at localhost.
3. On `npm run build-bundle`, build pipeline (Babel → Webpack) outputs dist bundles.
4. dist bundles are published to npm.
5. External Vue apps install via `npm i vue-tree-chart` and import `<TreeChart>`.
6. Props (`json`) flow data into the component; events (`click-node`) flow out to the host app.

c. Key architectural patterns & design principles:
- Component-based design (Vue single-file components)
- Library packaging (CommonJS + UMD) for broad compatibility
- Clear separation between source, build pipeline, and distribution artifacts
- Demo environment isolated from library code

d. Relevant technologies & frameworks:
- Vue.js v2 (component framework)
- Webpack (module bundler)
- Babel (ES6+ transpilation)
- ESLint (linter)
- npm (package manager)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Source Layer
    subgraph "Source Layer"
        direction TB
        CoreComponent["TreeChart.vue"]:::source
        DemoAppEntry["App.vue"]:::source
        DemoBootstrap["main.js"]:::source
        Assets["assets/"]:::source
    end

    %% Build Toolchain
    subgraph "Build Toolchain"
        direction TB
        Babel["Babel"]:::build
        Webpack["Webpack"]:::build
        ESLint["ESLint"]:::build
        DevServer["Webpack Dev Server"]:::build
    end

    %% Distribution Layer
    subgraph "Distribution Layer"
        direction TB
        CommonJS["TreeChart.common.js"]:::dist
        UMD["TreeChart.umd.js"]:::dist
        DemoPage["demo.html"]:::dist
    end

    %% Demo & Docs
    subgraph "Demo / Docs"
        direction TB
        PublicHTML["public/index.html"]:::docs
        DocsHTML["docs/index.html"]:::docs
        DocsJS["docs/js/"]:::docs
    end

    %% External Consumers
    subgraph "Consumers & Registry"
        direction TB
        NpmRegistry["npm registry"]:::external
        ConsumerApp["Vue Application"]:::external
    end

    %% Build Flows
    CoreComponent -->|"lint & check"| ESLint
    CoreComponent -->|"transpile"| Babel
    DemoAppEntry -->|"transpile"| Babel
    DemoBootstrap -->|"transpile"| Babel
    Assets -->|"bundle assets"| Webpack

    ESLint --> Webpack
    Babel --> Webpack
    Webpack --> CommonJS
    Webpack --> UMD
    Webpack --> DemoPage

    DemoAppEntry --> DevServer
    DemoBootstrap --> DevServer
    Assets --> DevServer
    DevServer --> PublicHTML

    %% Docs Generation
    CoreComponent -->|"generate docs"| DocsHTML
    CoreComponent -->|"generate docs"| DocsJS

    %% Distribution to Consumers
    CommonJS -->|"publish"| NpmRegistry
    UMD -->|"publish"| NpmRegistry
    DemoPage -->|"publish"| NpmRegistry
    DocsHTML -->|"publish docs"| NpmRegistry
    DocsJS -->|"publish docs"| NpmRegistry

    NpmRegistry -->|"install & import"| ConsumerApp
    ConsumerApp -->|"use <TreeChart/>"| CoreComponent
    ConsumerApp -->|"props(json) & emit(click-node)"| CoreComponent

    %% Click Events
    click CoreComponent "https://github.com/neugrp/vue-tree-chart/blob/master/src/components/TreeChart.vue"
    click DemoAppEntry "https://github.com/neugrp/vue-tree-chart/blob/master/src/App.vue"
    click DemoBootstrap "https://github.com/neugrp/vue-tree-chart/blob/master/src/main.js"
    click Assets "https://github.com/neugrp/vue-tree-chart/tree/master/src/assets"
    click PublicHTML "https://github.com/neugrp/vue-tree-chart/blob/master/public/index.html"
    click Babel "https://github.com/neugrp/vue-tree-chart/blob/master/babel.config.js"
    click Webpack "https://github.com/neugrp/vue-tree-chart/blob/master/vue.config.js"
    click ESLint "https://github.com/neugrp/vue-tree-chart/blob/master/.eslintrc.js"
    click CommonJS "https://github.com/neugrp/vue-tree-chart/blob/master/dist/TreeChart.common.js"
    click UMD "https://github.com/neugrp/vue-tree-chart/blob/master/dist/TreeChart.umd.js"
    click DemoPage "https://github.com/neugrp/vue-tree-chart/blob/master/dist/demo.html"
    click DocsHTML "https://github.com/neugrp/vue-tree-chart/blob/master/docs/index.html"
    click DocsJS "https://github.com/neugrp/vue-tree-chart/tree/master/docs/js/"
    click NpmRegistry "https://github.com/neugrp/vue-tree-chart/blob/master/package.json"

    %% Styles
    classDef source fill:#cce5ff,stroke:#004085,color:#004085
    classDef build fill:#d4edda,stroke:#155724,color:#155724
    classDef dist fill:#fff3cd,stroke:#856404,color:#856404
    classDef docs fill:#e2e3e5,stroke:#6c757d,color:#6c757d
    classDef external fill:#f8d7da,stroke:#721c24,color:#721c24
```
