# fengtianxi001/mf-stationmonitor architecture

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

- Interactive diagram: https://gitdiagram.com/fengtianxi001/mf-stationmonitor
- Repository: https://github.com/fengtianxi001/mf-stationmonitor

## Overview

##### Project Type & Purpose
- This is a front-end single‐page application (SPA) built with Vue 3 + Vite and TypeScript.
- Its goal is to present a “digital twin” dashboard for a power substation—rendering 3D models (via Three.js + Draco) and real-time charts (via ECharts) on a large screen.

##### File Structure at a Glance
- Top-level config files: `.env*`, `tsconfig*.json`, `vite.config.ts`, linters, formatter.
- `src/`: all application source code
- `main.ts` – bootstraps the Vue app
- `App.vue` – root component, mounts header/footer/panels
- `components/` – UI building blocks (LayoutHeader, LayoutPanel, WidgetPanel01–06, etc.)
- `hooks/` – Composition API hooks (`useThree.ts`, `useEcharts.ts`, `useStation.ts`)
- `docs/`: production output (built site for GitHub Pages).
- `screenshots/`: for README.

##### Key Insights from README
- Minimal text, but confirms it’s a “substation digital twin big-screen case” and is hosted on GitHub Pages under `docs/`.

##### Components
a. Main Components
- Developer Machine: runs Vite dev server (`vite.config.ts`) + HMR + local `.env.development`.
- Build Pipeline: Vite bundles `src/` + static `public/` → output to `docs/`.
- Hosting: GitHub Pages (serving `docs/index.html`, JS bundles, static assets).
- Client (Browser): loads index.html → runs Vue 3 SPA.
- Vue SPA Layers:
- Presentation Layer: LayoutHeader/Footer, WidgetPanels
- Visualization Engines:
– Three.js + Draco WASM (in `useThree.ts`) for 3D models (`.glb`, `.gltf`)
– ECharts (in `useEcharts.ts`) for charts
- Data Layer: `useStation.ts` fetches real-time data from an external Monitoring API (configured in `.env.production`)
- Asset Store: model files, textures, fonts served from `/public/models`, `/public/textures`, `/public/fontawesome`.
- External Services: real-time telemetry API (IoT platform or mock service).

b. Relationships & Data Flows
1. Developer → Vite Dev Server → serves SPA + assets to browser (local `.env`).
2. Vite Build → outputs to `docs/` → GitHub Pages.
3. Browser → fetch `index.html` + JS/CSS bundles + static assets → bootstrap Vue app.
4. Vue app → calls `useStation` → HTTP(s) calls → External Monitoring API → JSON data → updates charts & 3D overlays.
5. Vue components → call `useThree` → load and decode 3D models via Draco WASM → render WebGL scene.
6. Vue components → call `useEcharts` → initialize charts.

c. Architectural Patterns & Principles
- Component‐based (Vue components for UI panels).
- Composition API pattern for encapsulating logic (hooks for 3D, charts, data).
- Clear separation of concerns: UI vs data‐fetching vs rendering engines.
- Static‐site deployment: no backend code in repo, data fetching lives in browser.

d. Key Technologies & Libraries
- Vue 3 (Single File Components)
- Vite (ESM dev server, build bundler)
- TypeScript
- Three.js + Draco (3D engine + model compression)
- ECharts (charting)
- GitHub Pages for static hosting

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Infrastructure Layer
    subgraph "Development Environment"
        direction TB
        DevMachine["Developer Machine"]:::infra
        EnvDev[".env.development"]:::infra
        ViteDev["Vite Dev Server"]:::infra
    end
    subgraph "Build & Hosting"
        direction TB
        EnvProd[".env.production"]:::infra
        BuildPipeline["Vite Build Pipeline"]:::infra
        DocsSite["GitHub Pages"]:::infra
    end

    %% Client Layer
    Browser["Browser (Client)"]:::frontend

    %% Application Initialization
    ClientHTML["index.html"]:::infra
    VueBootstrap["Vue App Bootstrap<br>(src/main.ts)"]:::frontend
    VueRoot["Vue Root Component<br>(src/App.vue)"]:::frontend

    %% Presentation Layer
    subgraph "Presentation Layer" 
        direction TB
        Header["LayoutHeader.vue"]:::frontend
        Footer["LayoutFooter.vue"]:::frontend
        Panel["LayoutPanel.vue"]:::frontend
        Loading["LayoutLoading.vue"]:::frontend
        subgraph "Widgets"
            direction TB
            WP1["WidgetPanel01.vue"]:::frontend
            WP2["WidgetPanel02.vue"]:::frontend
            WP3["WidgetPanel03.vue"]:::frontend
            WP4["WidgetPanel04.vue"]:::frontend
            WP5["WidgetPanel05.vue"]:::frontend
            WP6["WidgetPanel06.vue"]:::frontend
            WPLabel["WidgetLabel.vue"]:::frontend
        end
    end

    %% Hooks & Engines
    subgraph "Composition API Hooks & Engines"
        direction TB
        DataHook["useStation.ts"]:::frontend
        subgraph "Visualization Engines"
            direction TB
            ThreeHook["useThree.ts"]:::engine
            EchartsHook["useEcharts.ts"]:::engine
        end
    end

    %% External Services & Assets
    subgraph "External Services & Asset Store"
        direction TB
        ExternalAPI["External Monitoring API"]:::external
        subgraph "Public Assets"
            direction TB
            Models["public/models/"]:::storage
            Textures["public/textures/"]:::storage
            FontAwesome["public/fontawesome/"]:::storage
            DracoWASM["public/js/draco/"]:::storage
        end
    end

    %% Production Assets
    subgraph "Production Static Assets"
        direction TB
        ProdDraco["docs/js/draco/"]:::storage
        VendorJS["docs/js/vendor-*.js"]:::storage
        DocStyles["docs/styles/"]:::storage
        DocFonts["docs/fonts/"]:::storage
        DocFA["docs/fontawesome/"]:::storage
    end

    %% Connections
    DevMachine -->|runs| ViteDev
    EnvDev -->|config| ViteDev
    ViteDev -->|dev serve| Browser
    ViteDev -->|build| BuildPipeline
    EnvProd -->|config| BuildPipeline
    BuildPipeline -->|deploy| DocsSite

    DocsSite -->|serves| Browser
    Browser -->|GET| ClientHTML
    ClientHTML -->|loads| VueBootstrap
    VueBootstrap -->|mounts| VueRoot

    VueRoot -->|renders| Header
    VueRoot -->|renders| Footer
    VueRoot -->|renders| Panel
    VueRoot -->|renders| Loading
    VueRoot -->|renders| WP1
    VueRoot -->|renders| WP2
    VueRoot -->|renders| WP3
    VueRoot -->|renders| WP4
    VueRoot -->|renders| WP5
    VueRoot -->|renders| WP6
    VueRoot -->|renders| WPLabel

    VueRoot -->|calls| DataHook
    VueRoot -->|calls| ThreeHook
    VueRoot -->|calls| EchartsHook

    DataHook -->|HTTP GET /stations| ExternalAPI
    ThreeHook -->|3D Model Load| Models
    ThreeHook -->|decode via Draco| DracoWASM
    EchartsHook -->|init charts| Textures

    Browser -->|fetch assets| Models
    Browser -->|fetch assets| Textures
    Browser -->|fetch assets| FontAwesome

    DocsSite -->|hosts| ProdDraco
    DocsSite -->|hosts| VendorJS
    DocsSite -->|hosts| DocStyles
    DocsSite -->|hosts| DocFonts
    DocsSite -->|hosts| DocFA

    %% Click Events
    click ViteDev "https://github.com/fengtianxi001/mf-stationmonitor/blob/main/vite.config.ts"
    click EnvDev "https://github.com/fengtianxi001/mf-stationmonitor/blob/main/.env.development"
    click EnvProd "https://github.com/fengtianxi001/mf-stationmonitor/blob/main/.env.production"
    click BuildPipeline "https://github.com/fengtianxi001/mf-stationmonitor/tree/main/docs/"
    click DocsSite "https://github.com/fengtianxi001/mf-stationmonitor/blob/main/docs/index.html"
    click ClientHTML "https://github.com/fengtianxi001/mf-stationmonitor/blob/main/index.html"
    click VueBootstrap "https://github.com/fengtianxi001/mf-stationmonitor/blob/main/src/main.ts"
    click VueRoot "https://github.com/fengtianxi001/mf-stationmonitor/blob/main/src/App.vue"
    click Header "https://github.com/fengtianxi001/mf-stationmonitor/blob/main/src/components/LayoutHeader.vue"
    click Footer "https://github.com/fengtianxi001/mf-stationmonitor/blob/main/src/components/LayoutFooter.vue"
    click Panel "https://github.com/fengtianxi001/mf-stationmonitor/blob/main/src/components/LayoutPanel.vue"
    click Loading "https://github.com/fengtianxi001/mf-stationmonitor/blob/main/src/components/LayoutLoading.vue"
    click WP1 "https://github.com/fengtianxi001/mf-stationmonitor/blob/main/src/components/WidgetPanel01.vue"
    click WP2 "https://github.com/fengtianxi001/mf-stationmonitor/blob/main/src/components/WidgetPanel02.vue"
    click WP3 "https://github.com/fengtianxi001/mf-stationmonitor/blob/main/src/components/WidgetPanel03.vue"
    click WP4 "https://github.com/fengtianxi001/mf-stationmonitor/blob/main/src/components/WidgetPanel04.vue"
    click WP5 "https://github.com/fengtianxi001/mf-stationmonitor/blob/main/src/components/WidgetPanel05.vue"
    click WP6 "https://github.com/fengtianxi001/mf-stationmonitor/blob/main/src/components/WidgetPanel06.vue"
    click WPLabel "https://github.com/fengtianxi001/mf-stationmonitor/blob/main/src/components/WidgetLabel.vue"
    click DataHook "https://github.com/fengtianxi001/mf-stationmonitor/blob/main/src/hooks/useStation.ts"
    click ThreeHook "https://github.com/fengtianxi001/mf-stationmonitor/blob/main/src/hooks/useThree.ts"
    click EchartsHook "https://github.com/fengtianxi001/mf-stationmonitor/blob/main/src/hooks/useEcharts.ts"
    click Models "https://github.com/fengtianxi001/mf-stationmonitor/tree/main/public/models/"
    click Textures "https://github.com/fengtianxi001/mf-stationmonitor/tree/main/public/textures/"
    click FontAwesome "https://github.com/fengtianxi001/mf-stationmonitor/tree/main/public/fontawesome/"
    click DracoWASM "https://github.com/fengtianxi001/mf-stationmonitor/tree/main/public/js/draco/"
    click ProdDraco "https://github.com/fengtianxi001/mf-stationmonitor/tree/main/docs/js/draco/"
    click VendorJS "https://github.com/fengtianxi001/mf-stationmonitor/blob/main/docs/js/vendor-*.js"
    click DocStyles "https://github.com/fengtianxi001/mf-stationmonitor/tree/main/docs/styles/"
    click DocFonts "https://github.com/fengtianxi001/mf-stationmonitor/tree/main/docs/fonts/"
    click DocFA "https://github.com/fengtianxi001/mf-stationmonitor/tree/main/docs/fontawesome/"

    %% Styles
    classDef infra fill:#e0e0e0,stroke:#666,stroke-width:1px
    classDef frontend fill:#cfe2ff,stroke:#084298,stroke-width:1px
    classDef engine fill:#fff4cc,stroke:#664d03,stroke-width:1px
    classDef external fill:#d1e7dd,stroke:#0f5132,stroke-width:1px
    classDef storage fill:#f8f9fa,stroke:#6c757d,stroke-width:1px
```
