# tkskto/vue-component-analyzer architecture

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

- Interactive diagram: https://gitdiagram.com/tkskto/vue-component-analyzer
- Repository: https://github.com/tkskto/vue-component-analyzer

## Overview

##### Project type and purpose
- This is a developer tool—a CLI‐driven analyzer for Vue.js Single File Components (SFCs) that also spins up a simple server and a browser-based UI for visualizing component dependency trees and props.
- The README describes it as both a command-line utility and an embeddable API/library for building or testing your own tools.

##### File structure
- Top-level:
- bin/analyze.js – the CLI entry point (uses Commander or similar)
- src/server – the core analyzer engine and HTTP server (parses files, builds a model, renders via EJS)
- src/client – the browser app (TypeScript, DOM renderer, view switchers, style)
- views – EJS templates for server-side rendering of HTML pages
- rollup.config.mjs – build/bundle configuration
- package.json, tsconfigs, jest.config.js, eslint.config.js – build/test lint pipelines
- Tests and fixtures under test/ ensure parser correctness and CLI behavior. Types in types/ describe public API.

##### README for additional insights
- CLI options: --dir, --format, --out, --port – point to how the CLI orchestrates analysis and output.
- API export getImportDeclarationTree – shows the analyzer core can be used programmatically.
- Outputs: interactive “browser” UI, JSON, or HTML report.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External
    FileSystem((File System)):::external

    %% CLI Layer
    subgraph "CLI Layer"
        CLI["CLI"]:::backend
        Cmd["Commander"]:::backend
        CLI --> Cmd
    end

    %% Analyzer Engine
    subgraph "Analyzer Engine"
        Index["index.ts"]:::backend
        Analyzer["Analyzer.ts"]:::backend
        Token["tokenProcessor.ts"]:::backend
        FC["FileCounter.ts"]:::backend
        VueComp["VueComponent.ts"]:::backend
        Model["Model.ts"]:::backend
        Utils["utils.ts"]:::backend
        Const["Constant.ts"]:::backend

        Index --> Analyzer
        Analyzer --> Token
        Analyzer --> FC
        Analyzer --> VueComp
        Analyzer --> Model
        Analyzer --> Utils
        Analyzer --> Const
    end

    %% Output Generator
    subgraph "Output Generator"
        Output["Output.ts"]:::backend
    end

    %% HTTP Server
    subgraph "HTTP Server"
        Server["server.ts"]:::backend
        Static["static.ejs"]:::frontend
        Viewer["viewer.ejs"]:::frontend
        Server --> Static
        Server --> Viewer
    end

    %% Browser UI
    subgraph "Browser UI"
        Client["client.ts"]:::frontend
        Renderer["renderer.ts"]:::frontend
        ModelC["model.ts"]:::frontend
        Dispatcher["eventDispatcher.ts"]:::frontend
        Switcher["viewSwitcher.ts"]:::frontend
        ScreenCap["ScreenCapture.ts"]:::frontend
        Visible["VisibleSwitcher.ts"]:::frontend
        Settings["Settings.ts"]:::frontend
        Dialog["dialog/index.ts"]:::frontend
        Common["common.ts"]:::frontend
        StyleMod["style.ts"]:::frontend
        CSS["style.css"]:::frontend
        Icon["icon"]:::frontend

        Client --> Renderer
        Client --> ModelC
        Client --> Dispatcher
        Client --> Switcher
        Client --> ScreenCap
        Client --> Visible
        Client --> Settings
        Client --> Dialog
        Client --> Common
        Client --> StyleMod
        Static --> CSS
        Static --> Icon
    end

    %% Build Config
    subgraph "Build Configuration"
        Rollup["rollup.config.mjs"]:::external
        TSRoot["tsconfig.json"]:::external
        TSClient["src/client/tsconfig.json"]:::external
        TSServer["src/server/tsconfig.json"]:::external
    end

    %% Tests & Fixtures
    subgraph "Tests & Fixtures"
        Specs["test/specs/**/*.ts"]:::external
        Fixture["test/fixture/**"]:::external
        Assets["test/assets/**"]:::external
        Components["test/components/**"]:::external
    end

    %% Public API Types
    subgraph "Public API Types"
        Types1["index.d.ts"]:::external
        Types2["global.d.ts"]:::external
    end

    %% Connections
    CLI -->|"args"| Index
    Cmd -->|"invokes"| Index
    Index -->|"builds model"| Analyzer
    Index --> Output
    Output -->|"writes files"| FileSystem
    Index --> Server
    Server -->|"serves bundle"| Client
    Client -->|"HTTP GET /data"| Server
    FileSystem -->|"reads .vue files"| Analyzer

    %% Click Events
    click CLI "https://github.com/tkskto/vue-component-analyzer/blob/develop/bin/analyze.js"
    click Cmd "https://github.com/tkskto/vue-component-analyzer/blob/develop/src/server/Commander.ts"
    click Index "https://github.com/tkskto/vue-component-analyzer/blob/develop/src/server/index.ts"
    click Analyzer "https://github.com/tkskto/vue-component-analyzer/blob/develop/src/server/Analyzer.ts"
    click Token "https://github.com/tkskto/vue-component-analyzer/blob/develop/src/server/tokenProcessor.ts"
    click FC "https://github.com/tkskto/vue-component-analyzer/blob/develop/src/server/FileCounter.ts"
    click VueComp "https://github.com/tkskto/vue-component-analyzer/blob/develop/src/server/VueComponent.ts"
    click Model "https://github.com/tkskto/vue-component-analyzer/blob/develop/src/server/Model.ts"
    click Utils "https://github.com/tkskto/vue-component-analyzer/blob/develop/src/server/utils.ts"
    click Const "https://github.com/tkskto/vue-component-analyzer/blob/develop/src/server/Constant.ts"
    click Output "https://github.com/tkskto/vue-component-analyzer/blob/develop/src/server/Output.ts"
    click Server "https://github.com/tkskto/vue-component-analyzer/blob/develop/src/server/server.ts"
    click Static "https://github.com/tkskto/vue-component-analyzer/blob/develop/views/static.ejs"
    click Viewer "https://github.com/tkskto/vue-component-analyzer/blob/develop/views/viewer.ejs"
    click Client "https://github.com/tkskto/vue-component-analyzer/blob/develop/src/client/client.ts"
    click Renderer "https://github.com/tkskto/vue-component-analyzer/blob/develop/src/client/renderer.ts"
    click ModelC "https://github.com/tkskto/vue-component-analyzer/blob/develop/src/client/model.ts"
    click Dispatcher "https://github.com/tkskto/vue-component-analyzer/blob/develop/src/client/eventDispatcher.ts"
    click Switcher "https://github.com/tkskto/vue-component-analyzer/blob/develop/src/client/viewSwitcher.ts"
    click ScreenCap "https://github.com/tkskto/vue-component-analyzer/blob/develop/src/client/ScreenCapture.ts"
    click Visible "https://github.com/tkskto/vue-component-analyzer/blob/develop/src/client/VisibleSwitcher.ts"
    click Settings "https://github.com/tkskto/vue-component-analyzer/blob/develop/src/client/Settings.ts"
    click Dialog "https://github.com/tkskto/vue-component-analyzer/blob/develop/src/client/dialog/index.ts"
    click Common "https://github.com/tkskto/vue-component-analyzer/blob/develop/src/client/common.ts"
    click StyleMod "https://github.com/tkskto/vue-component-analyzer/blob/develop/src/client/style.ts"
    click CSS "https://github.com/tkskto/vue-component-analyzer/blob/develop/dist/style.css"
    click Icon "https://github.com/tkskto/vue-component-analyzer/tree/develop/dist/icon"

    %% Styles
    classDef backend fill:#a2f5a2,stroke:#333
    classDef frontend fill:#add8e6,stroke:#333
    classDef external fill:#d3d3d3,stroke:#333
```
