# wiinci/vue-charts architecture

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

- Interactive diagram: https://gitdiagram.com/wiinci/vue-charts
- Repository: https://github.com/wiinci/vue-charts

## Overview

##### Project type and purpose
- This is a front-end single-page application (SPA) that provides a reusable collection of interactive, data-driven charts (LineChart, Sankey, etc.).
- Built with Vue 3.5 + Vite, with TypeScript support and D3.js for data visualization.
- Purpose: offer a modular chart library/demo where each chart is a self-contained Vue component.

##### File structure
- Top level:
- index.html – the host page
- package.json, vite.config.ts – build tool and scripts
- tsconfig*.json – TypeScript configuration
- src/
- main.ts / main.js – Vue app bootstrap
- App.vue – root component
- assets/ – static constants and assets
- components/
– LineChart/ (Line.vue, LineChart.vue)
– Sankey/ (Sankey.vue, sub-components Nodes.vue, Links.vue, Labels.vue)
– common-ts/ (reusable chart primitives in TypeScript)
– common/ (JavaScript versions of primitives)
- composables/ – Composition API logic (useCollapsed, useHighlightLinks, useNodesAndLinks)
- hooks/ – analogous JavaScript logic for older paradigms
- utils/ – pure helper functions (formatTime, generateTransition, smartTicks, axis patterns)
- data/ – sample data (CSV, JSON)

##### README for additional insights
- Confirms tech stack: Vue 3.5, Vite 5, D3.js, TypeScript
- Emphasizes modern `<script setup>`, responsive charts, improved Suspense

##### Be comprehensive but structured
- Two parallel sets of logic code (TypeScript composables vs JavaScript hooks)
- That both sets ultimately feed data to the Vue components
- Call out that Vite’s config (vite.config.ts) sits at the root of the build layer

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Build & Dev Toolchain
    subgraph "Build & Dev Toolchain"
        direction TB
        pkg["package.json"]:::build
        vitecfg["vite.config.ts"]:::build
        codeql[".github/workflows/codeql-analysis.yml"]:::build
    end

    %% Entry Point
    subgraph "Entry Point"
        direction TB
        html["index.html"]:::entry
        mainTs["src/main.ts"]:::entry
    end

    %% Runtime Layer
    subgraph "Runtime Layer"
        direction TB

        %% App Shell
        subgraph "App Shell"
            direction TB
            app["src/App.vue"]:::ui
        end

        %% Chart Components
        subgraph "Chart Components" 
            direction TB
            lineComp["LineChart\n( LineChart.vue\n Line.vue )"]:::ui
            sankeyComp["Sankey\n( Sankey.vue\n Nodes.vue\n Links.vue\n Labels.vue )"]:::ui
        end

        %% Shared Primitives - TypeScript
        subgraph "Shared Primitives (TS)"
            direction TB
            tsChart["Chart.vue"]:::ui
            tsAxis["Axis.vue"]:::ui
            tsGradient["LineGradient.vue"]:::ui
            tsTooltip["Tooltip.vue"]:::ui
            tsVoronoi["Voronoi.vue"]:::ui
        end

        %% Shared Primitives - JS
        subgraph "Shared Primitives (JS)"
            direction TB
            jsChart["Chart.vue"]:::ui
            jsVoronoi["Voronoi.vue"]:::ui
        end

        %% State & Logic - Composables
        subgraph "Composables (TS)"
            direction TB
            useCollapsedTs["useCollapsed.ts"]:::logic
            useHighlightTs["useHighlightLinks.ts"]:::logic
            useNodesLinksTs["useNodesAndLinks.ts"]:::logic
        end

        %% State & Logic - Hooks
        subgraph "Hooks (JS)"
            direction TB
            useCollapsedJs["useCollapsed.js"]:::logic
            useNodesLinksJs["useNodesAndLinks.js"]:::logic
        end

        %% Utility Layer
        subgraph "Utils"
            direction TB
            fmtTime["formatTime.ts"]:::util
            genTrans["generateTransition.ts"]:::util
            hlLinks["highlightLinks.js"]:::util
            smartTicks["smartTicks.ts"]:::util
            xAxis["xAxisPatterns.ts"]:::util
            yAxis["yAxisPatterns.ts"]:::util
            utilsIndex["index.ts"]:::util
        end

        %% Data Sources
        subgraph "Data Sources"
            direction TB
            dataCsv["aapl.csv"]:::data
            edges1["edges.json"]:::data
            edges2["edges2.json"]:::data
        end

        %% External Library
        subgraph "External"
            direction TB
            d3["D3.js"]:::external
        end
    end

    %% Build to Entry
    pkg -->|builds via Vite| html
    vitecfg --> html
    codeql --- vitecfg

    %% Entry Flow
    html -->|"loads bundle"| mainTs
    mainTs -->|"mounts"| app

    %% App to Components
    app -->|"renders"| lineComp
    app -->|"renders"| sankeyComp

    %% Components dependencies
    lineComp -->|"uses"| d3
    sankeyComp -->|"uses"| d3
    lineComp -->|"imports"| useCollapsedTs
    lineComp -->|"imports"| useHighlightTs
    sankeyComp -->|"imports"| useNodesLinksTs
    sankeyComp -->|"imports"| useNodesLinksJs
    lineComp -->|"imports utils"| fmtTime
    sankeyComp -->|"imports utils"| genTrans
    sankeyComp -->|"imports utils"| smartTicks

    %% Shared primitives usage
    lineComp -->|"shares"| tsChart
    lineComp --> tsAxis
    sankeyComp --> tsGradient
    sankeyComp --> tsTooltip

    %% Logic layers to data
    useCollapsedTs -->|"reads"| dataCsv
    useHighlightTs --> dataCsv
    useNodesLinksTs --> edges1
    useNodesLinksJs --> edges2

    %% Utils usage
    fmtTime --> utilsIndex
    genTrans --> utilsIndex
    hlLinks --> utilsIndex

    %% Click Events
    click pkg "https://github.com/wiinci/vue-charts/blob/main/package.json"
    click vitecfg "https://github.com/wiinci/vue-charts/blob/main/vite.config.ts"
    click codeql "https://github.com/wiinci/vue-charts/blob/main/.github/workflows/codeql-analysis.yml"
    click html "https://github.com/wiinci/vue-charts/blob/main/index.html"
    click mainTs "https://github.com/wiinci/vue-charts/blob/main/src/main.ts"
    click app "https://github.com/wiinci/vue-charts/blob/main/src/App.vue"
    click lineComp "https://github.com/wiinci/vue-charts/blob/main/src/components/LineChart/LineChart.vue"
    click lineComp "https://github.com/wiinci/vue-charts/blob/main/src/components/LineChart/Line.vue"
    click sankeyComp "https://github.com/wiinci/vue-charts/blob/main/src/components/Sankey/Sankey.vue"
    click sankeyComp "https://github.com/wiinci/vue-charts/blob/main/src/components/Sankey/Nodes.vue"
    click sankeyComp "https://github.com/wiinci/vue-charts/blob/main/src/components/Sankey/Links.vue"
    click sankeyComp "https://github.com/wiinci/vue-charts/blob/main/src/components/Sankey/Labels.vue"
    click tsChart "https://github.com/wiinci/vue-charts/blob/main/src/components/common-ts/Chart.vue"
    click tsAxis "https://github.com/wiinci/vue-charts/blob/main/src/components/common-ts/Axis.vue"
    click tsGradient "https://github.com/wiinci/vue-charts/blob/main/src/components/common-ts/LineGradient.vue"
    click tsTooltip "https://github.com/wiinci/vue-charts/blob/main/src/components/common-ts/Tooltip.vue"
    click tsVoronoi "https://github.com/wiinci/vue-charts/blob/main/src/components/common-ts/Voronoi.vue"
    click jsChart "https://github.com/wiinci/vue-charts/blob/main/src/components/common/Chart.vue"
    click jsVoronoi "https://github.com/wiinci/vue-charts/blob/main/src/components/common/Voronoi.vue"
    click useCollapsedTs "https://github.com/wiinci/vue-charts/blob/main/src/composables/useCollapsed.ts"
    click useHighlightTs "https://github.com/wiinci/vue-charts/blob/main/src/composables/useHighlightLinks.ts"
    click useNodesLinksTs "https://github.com/wiinci/vue-charts/blob/main/src/composables/useNodesAndLinks.ts"
    click useCollapsedJs "https://github.com/wiinci/vue-charts/blob/main/src/hooks/useCollapsed.js"
    click useNodesLinksJs "https://github.com/wiinci/vue-charts/blob/main/src/hooks/useNodesAndLinks.js"
    click fmtTime "https://github.com/wiinci/vue-charts/blob/main/src/utils/formatTime.ts"
    click genTrans "https://github.com/wiinci/vue-charts/blob/main/src/utils/generateTransition.ts"
    click hlLinks "https://github.com/wiinci/vue-charts/blob/main/src/utils/highlightLinks.js"
    click smartTicks "https://github.com/wiinci/vue-charts/blob/main/src/utils/smartTicks.ts"
    click xAxis "https://github.com/wiinci/vue-charts/blob/main/src/utils/xAxisPatterns.ts"
    click yAxis "https://github.com/wiinci/vue-charts/blob/main/src/utils/yAxisPatterns.ts"
    click utilsIndex "https://github.com/wiinci/vue-charts/blob/main/src/utils/index.ts"
    click dataCsv "https://github.com/wiinci/vue-charts/blob/main/src/data/aapl.csv"
    click edges1 "https://github.com/wiinci/vue-charts/blob/main/src/data/edges.json"
    click edges2 "https://github.com/wiinci/vue-charts/blob/main/src/data/edges2.json"

    %% Styles
    classDef ui fill:#cce5ff,stroke:#004085,color:#000
    classDef logic fill:#d4edda,stroke:#155724,color:#000
    classDef util fill:#fff3cd,stroke:#856404,color:#000
    classDef data fill:#e2e3e5,stroke:#6c757d,color:#000
    classDef external fill:#f5c6cb,stroke:#721c24,color:#000
    classDef build fill:#d6d8d9,stroke:#343a40,color:#000
    classDef entry fill:#bee5eb,stroke:#0c5460,color:#000
```
