# dromara/go-view architecture

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

- Interactive diagram: https://gitdiagram.com/dromara/go-view
- Repository: https://github.com/dromara/go-view

## Overview

##### A high-level layered view
- Entry Point Layer: Show the index.html that loads the main.ts entry script. This bootstraps the root App.vue.
– Layout components (src/layout) that structure the overall page (header, sidebar, footer, transitions).
– Page-specific components (src/views/chart, src/views/edit, src/views/preview, etc.).
– Rich, domain-specific chart configuration modules (all the chart component folders in src/packages/components/Charts).
- State Management Layer: Highlight the Pinia-based store (located in src/store and its modules) that manages application state such as chart editing, theme settings, language preferences, and system configuration.
- API/Data Interaction Layer: Show the API modules (src/api) wrapping axios (with configuration and mock data) that serve to communicate with the backend (or serve mock data) – this includes HTTP setup, REST endpoint paths, and mocks.
- Plugins and Utilities: Include the custom plugins (src/plugins) and utility modules (src/utils, src/hooks, src/directives) that add cross-cutting support such as theme management, storage, file handling, and encryption.

##### Main components and interactions
- UI Components – the presentation layer is highly modular. Layers of reusable components (e.g., GoAppProvider, GoLoading, chart components in packages) are used throughout the project.
- Routing – the router modules dynamically load views based on navigation and use router guards (src/router/router-guards.ts) to control permissions and flow.
- Data Flow – UI components interact with the global state via the Pinia stores so that user interactions (in pages like ContentEdit, ContentConfigurations, etc.) trigger updates. These stores, in turn, use API services in src/api (configured with axios) for fetching data or persisting changes.

##### Architectural patterns/design principles
- Modular and Component-Based Architecture: The clear separation of views, components, and packages indicates a design that endorses reuse and loose coupling.
- Separation of Concerns: Data interactions (API layer), state management (store), configuration (settings), presentation (components/views) are all partitioned clearly.
- Composition API and Hooks Pattern: The src/hooks directory along with the expansive use of TS and custom directives shows a design that aims for reusability and clarity.

- “Entry Point (index.html, main.ts, App.vue)”
- “Router” (with modules like chart.route, edit.route, preview.route, project.router)
- “Views & Layouts” (for all page-level components)
- “State Management (Pinia Stores)” (listing modules such as chartEditStore, designStore, langStore, etc.)
- “API Module” (with axios configuration, mock endpoints, and paths)
- “Plugins & Utilities” (custom plugins, hooks, directives, and utils)
- “Settings/Configuration” (chart themes, design settings, HTTP settings)
- The initialization process (index.html → main.ts → App.vue).
- Data flow from API calls → Store updates → UI re-render.
- Navigation flow via Router leading to components within Views.
- Optionally, add a “Build & Deployment” section that shows how files like vite.config.ts, Makefile, and the CI/CD pipelines (.workflow, .husky) interact with the source-code repository.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Entry Point Layer
    subgraph "Entry Point Layer"
        EP1["index.html"]:::entry
        EP2["main.ts"]:::entry
        EP3["App.vue"]:::entry
        EP1 --> EP2
        EP2 --> EP3
    end

    %% Presentation/UI Layer
    subgraph "Presentation/UI Layer"
        PUI1["Layout Components"]:::ui
        PUI2["Page-specific Components"]:::ui
        PUI3["Reusable UI Components"]:::ui
        PUI4["Chart Packages"]:::ui
    end

    %% Router Layer
    subgraph "Router Layer"
        RT1["Vue Router Modules"]:::router
    end

    %% State Management Layer
    subgraph "State Management Layer"
        SM1["Pinia Stores"]:::state
    end

    %% API/Data Interaction Layer
    subgraph "API/Data Interaction Layer"
        API1["API Modules (axios & mocks)"]:::api
    end

    %% Plugins and Utilities
    subgraph "Plugins and Utilities"
        PU1["Custom Plugins"]:::plugin
        PU2["Utility Modules"]:::plugin
        PU3["Hooks"]:::plugin
    end

    %% Configuration/Settings Layer
    subgraph "Configuration/Settings Layer"
        CFG1["Configuration Settings"]:::config
        CFG2["Build & Deployment Configurations"]:::config
    end

    %% Relationships and Data Flow
    EP3 -->|"bootstraps"| PUI1
    EP3 -->|"bootstraps"| RT1
    RT1 -->|"loads"| PUI2

    PUI2 -->|"reads_state"| SM1
    PUI3 -->|"reads_state"| SM1

    SM1 -->|"fetches/upd"| API1
    API1 -->|"updates"| SM1
    SM1 -->|"renders_update"| PUI2

    PUI3 -->|"uses"| PU1
    PUI3 -->|"utilizes"| PU2
    PUI3 -->|"utilizes"| PU3

    CFG1 -->|"configures"| SM1
    CFG2 -->|"build_output"| EP1

    %% Styles
    classDef entry fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef ui fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef router fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef state fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef api fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;
    classDef plugin fill:#e2e3e5,stroke:#41464b,stroke-width:2px;
    classDef config fill:#fefefe,stroke:#6c757d,stroke-width:2px;

    %% Click Events
    click EP1 "https://github.com/dromara/go-view/blob/master//index.html"
    click EP2 "https://github.com/dromara/go-view/blob/master//src/main.ts"
    click EP3 "https://github.com/dromara/go-view/blob/master//src/App.vue"
    click PUI1 "https://github.com/dromara/go-view/tree/master//src/layout"
    click PUI2 "https://github.com/dromara/go-view/tree/master//src/views"
    click PUI3 "https://github.com/dromara/go-view/tree/master//src/components"
    click PUI4 "https://github.com/dromara/go-view/tree/master//src/packages/components/Charts"
    click RT1 "https://github.com/dromara/go-view/tree/master//src/router"
    click SM1 "https://github.com/dromara/go-view/tree/master//src/store"
    click API1 "https://github.com/dromara/go-view/tree/master//src/api"
    click PU1 "https://github.com/dromara/go-view/tree/master//src/plugins"
    click PU2 "https://github.com/dromara/go-view/tree/master//src/utils"
    click PU3 "https://github.com/dromara/go-view/tree/master//src/hooks"
    click CFG1 "https://github.com/dromara/go-view/tree/master//src/settings"
    click CFG2 "https://github.com/dromara/go-view/tree/master/build"
```
