# nhat-tien/graph-theory architecture

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

- Interactive diagram: https://gitdiagram.com/nhat-tien/graph-theory
- Repository: https://github.com/nhat-tien/graph-theory

## Overview

##### Project type and purpose
- This is a hybrid desktop application built on Tauri.
- The UI is a Vue 3/Vite single-page app (SPA) for visualizing graph theory algorithms (Prim, Kruskal).
- The backend is a Rust binary (via Tauri) implementing graph data structures, algorithms, and file I/O commands.

##### File structure
Top‐level:
- index.html, package.json, src/… → Vue/Vite front-end
- public/ → static assets (fonts, images)
- src-tauri/ → Rust/Tauri backend
- .github/workflows → CI pipeline
- config files: vite.config.ts, tsconfig.json, tauri.conf.json

Frontend details (src/):
- App.vue, main.ts → entry point
- components/ → Vue components (Graph.vue, AlgorithmPage, UI controls)
- composables/ → Composition API hooks for graph state and animations
- stores/ → Pinia stores for global state (graph data, modes, timers)
- assets/styles → global SCSS, variables
- directives, global.scss → utility code

Backend details (src-tauri/):
- main.rs → Tauri command registration, app bootstrap
- edge.rs, graph.rs → core graph data structures
- prim.rs, kruskal.rs → algorithm implementations
- file_command.rs → file read/write logic
- tauri.conf.json, build.rs → build & config

##### README
- Short description: “Graph Theory Visualization built based on Tauri”
- Screenshots only; no explicit architecture section

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Renderer (Vue/Vite SPA)"
        direction TB
        MainTS["main.ts"]:::frontend
        AppVue["App.vue"]:::frontend
        IndexHTML["index.html"]:::frontend
        ViteConfig["vite.config.ts"]:::frontend
    end

    subgraph "Visualization Layer"
        direction TB
        GraphVue["Graph.vue"]:::frontend
        PrimVue["Prim.vue"]:::frontend
        KruskalVue["Kruskal.vue"]:::frontend
    end

    subgraph "State Management (Pinia Stores)"
        direction TB
        AddEdge["addEdgeStore.ts"]:::frontend
        AppMode["appMode.ts"]:::frontend
        EditMode["editModeStore.ts"]:::frontend
        GraphMode["graphModeStore.ts"]:::frontend
        MainGraph["mainGraphStore.ts"]:::frontend
        OpenAbout["openAboutStore.ts"]:::frontend
        PresentGraph["presentGraphStore.ts"]:::frontend
    end

    subgraph "Composables"
        direction TB
        UseGraph["useGraph.ts"]:::frontend
        UsePrimAnim["usePrimAnimation.ts"]:::frontend
        UseKruskalAnim["useKruskalAnimation.ts"]:::frontend
        UseTimer["useTimer.ts"]:::frontend
    end

    subgraph "Global Styles & Assets"
        direction TB
        GlobalScss["global.scss"]:::frontend
        MainScss["_main.scss"]:::frontend
        VarsScss["_variables.scss"]:::frontend
    end

    subgraph "Tauri IPC Layer"
        direction TB
        MainRS["main.rs"]:::backend
        TauriConf["tauri.conf.json"]:::backend
        BuildRS["build.rs"]:::backend
    end

    subgraph "Rust Core - Graph Data Structures"
        direction TB
        GraphRS["graph.rs"]:::backend
        EdgeRS["edge.rs"]:::backend
    end

    subgraph "Rust Core - Algorithm Implementations"
        direction TB
        PrimRS["prim.rs"]:::backend
        KruskalRS["kruskal.rs"]:::backend
    end

    subgraph "Rust Core - File I/O Commands"
        direction TB
        FileCmd["file_command.rs"]:::backend
    end

    OSFS["OS / FileSystem"]:::external

    %% Data and Control Flows
    GraphVue -->|uses| AddEdge
    GraphVue -->|uses| UseGraph
    PrimVue -->|uses| UsePrimAnim
    KruskalVue -->|uses| UseKruskalAnim

    GraphVue -->|invoke IPC| MainRS
    PrimVue -->|invoke IPC| MainRS
    KruskalVue -->|invoke IPC| MainRS

    MainRS -->|calls| GraphRS
    MainRS -->|calls| EdgeRS
    MainRS -->|executes| PrimRS
    MainRS -->|executes| KruskalRS
    MainRS -->|executes| FileCmd

    FileCmd -->|read/write| OSFS

    MainRS -->|returns result| GraphVue

    %% Click Events
    click MainTS "https://github.com/nhat-tien/graph-theory/blob/main/src/main.ts"
    click AppVue "https://github.com/nhat-tien/graph-theory/blob/main/src/App.vue"
    click IndexHTML "https://github.com/nhat-tien/graph-theory/blob/main/index.html"
    click ViteConfig "https://github.com/nhat-tien/graph-theory/blob/main/vite.config.ts"
    click GraphVue "https://github.com/nhat-tien/graph-theory/blob/main/src/components/Graph.vue"
    click PrimVue "https://github.com/nhat-tien/graph-theory/blob/main/src/components/AlgorithmPage/Prim.vue"
    click KruskalVue "https://github.com/nhat-tien/graph-theory/blob/main/src/components/AlgorithmPage/Kruskal.vue"
    click AddEdge "https://github.com/nhat-tien/graph-theory/blob/main/src/stores/addEdgeStore.ts"
    click AppMode "https://github.com/nhat-tien/graph-theory/blob/main/src/stores/appMode.ts"
    click EditMode "https://github.com/nhat-tien/graph-theory/blob/main/src/stores/editModeStore.ts"
    click GraphMode "https://github.com/nhat-tien/graph-theory/blob/main/src/stores/graphModeStore.ts"
    click MainGraph "https://github.com/nhat-tien/graph-theory/blob/main/src/stores/mainGraphStore.ts"
    click OpenAbout "https://github.com/nhat-tien/graph-theory/blob/main/src/stores/openAboutStore.ts"
    click PresentGraph "https://github.com/nhat-tien/graph-theory/blob/main/src/stores/presentGraphStore.ts"
    click UseGraph "https://github.com/nhat-tien/graph-theory/blob/main/src/composables/useGraph.ts"
    click UsePrimAnim "https://github.com/nhat-tien/graph-theory/blob/main/src/composables/usePrimAnimation.ts"
    click UseKruskalAnim "https://github.com/nhat-tien/graph-theory/blob/main/src/composables/useKruskalAnimation.ts"
    click UseTimer "https://github.com/nhat-tien/graph-theory/blob/main/src/composables/useTimer.ts"
    click GlobalScss "https://github.com/nhat-tien/graph-theory/blob/main/src/global.scss"
    click MainScss "https://github.com/nhat-tien/graph-theory/blob/main/src/assets/styles/_main.scss"
    click VarsScss "https://github.com/nhat-tien/graph-theory/blob/main/src/assets/styles/_variables.scss"
    click MainRS "https://github.com/nhat-tien/graph-theory/blob/main/src-tauri/src/main.rs"
    click TauriConf "https://github.com/nhat-tien/graph-theory/blob/main/src-tauri/tauri.conf.json"
    click BuildRS "https://github.com/nhat-tien/graph-theory/blob/main/src-tauri/build.rs"
    click GraphRS "https://github.com/nhat-tien/graph-theory/blob/main/src-tauri/src/graph.rs"
    click EdgeRS "https://github.com/nhat-tien/graph-theory/blob/main/src-tauri/src/edge.rs"
    click PrimRS "https://github.com/nhat-tien/graph-theory/blob/main/src-tauri/src/prim.rs"
    click KruskalRS "https://github.com/nhat-tien/graph-theory/blob/main/src-tauri/src/kruskal.rs"
    click FileCmd "https://github.com/nhat-tien/graph-theory/blob/main/src-tauri/src/file_command.rs"

    %% Styles
    classDef frontend fill:#E0F7FA,stroke:#006064,color:#004D40
    classDef backend fill:#E8F5E9,stroke:#1B5E20,color:#2E7D32
    classDef external fill:#F5F5F5,stroke:#9E9E9E,color:#616161
```
