# paulaselim/switch-nexus architecture

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

- Interactive diagram: https://gitdiagram.com/paulaselim/switch-nexus
- Repository: https://github.com/paulaselim/switch-nexus

## Overview

##### Main Components
- Frontend: This is located in the “frontend” directory and built using Vue.js. Key files include the App.vue, components (e.g., SwitchListItem, VLANDetails), views, and service files like MySwitchService.js. Also note the vite.config.js and the associated Wails JavaScript directories.
- Backend (Core Application): Written in Go, with the entry point in main.go and configuration in wails.json. The Go code is organized into several folders:
- Internal or core folders that represent the layers of the onion architecture:
– Config (internal/config/env.go) for managing configuration, loaded perhaps via an environment file.
– Interfaces (internal/interfaces, plus wails_interfaces directory) which expose functions to the frontend.
– Utilities (internal/utilities) including SSH (internal/utilities/ssh/ssh.go) and ping modules for network operations.
- Additional components that might be hidden in the README’s suggested “services” or “middleware” (even if not one-to-one with directory names) but are represented conceptually.
- Build and Distribution: The “build” directory contains platform-specific build instructions and resources for macOS (darwin) and Windows (e.g., installer scripts, manifest files).

##### Relationships and Interactions
- User interactions through the Vue.js frontend (login, switch management, command execution) calling backend functions.
- The backend services and interfaces layer (exposed via internal/interfaces) responding to these calls.
- The backend modules should illustrate layered interaction, where higher-level service components call upon lower layers such as configuration, middleware (for logging and error handling), and utilities (for SSH connections and ping operations).
- The build components also play a role in packaging the final application for cross-platform deployment. Represent these as external deployment pipelines or toolchains that wrap the core application.

##### Architectural Concepts and Design Patterns
- Onion Architecture: Represent the concentric layers where:
- The outer layers (interfaces, in this case the Wails and Vue.js interactions) interact with the core business logic.
- The core inner layers (configuration, utilities, and services) encapsulate the business rules and infrastructure interactions.
- Dependency directional flows—e.g., from the configuration layer upward to services, then outward through interfaces to the frontend.

##### Technologies, Frameworks, and Libraries
- Backend:
- Go (primary language).
- The Wails framework—highlight its role in bridging the Go backend with the Vue.js frontend.
- Utilities: SSH libraries and custom ping modules.
- Frontend:
- Vue.js
- Node.js/npm for dependency management and build processes.
- Deployment:
- Build scripts and installers for Darwin (macOS) and Windows using the provided NSIS scripts and manifest files.
- Version control and CI/CD hints can be incorporated (e.g., the .github folder with dependabot).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interaction
    User["User/Operator"]:::user

    %% Frontend (Vue.js) Subgraph
    subgraph "Frontend (Vue.js)"
        FrontendApp["App.vue"]:::frontend
        FrontComponents["Components (SwitchListItem, VLANDetails, etc.)"]:::frontend
        FrontViews["Views"]:::frontend
        FrontService["MySwitchService"]:::frontend
        FrontVite["vite.config.js"]:::frontend
    end

    %% Backend (Go Core Application) Subgraph
    subgraph "Backend (Go Core Application)"
        Back_MA["Main Application (main.go, wails.json)"]:::backend
        Back_Interfaces["Interfaces (internal/interfaces, wails_interfaces)"]:::backend
        Back_BL["Business Logic / Services"]:::backend
        Back_Config["Configuration (env.go)"]:::config
        SSHUtil["SSH Utility (ssh.go)"]:::util
        PingUtil["Ping Utility (ping.go)"]:::util
    end

    %% Build & Deployment Subgraph
    subgraph "Build & Deployment"
        BuildDir["Build Directory (darwin/windows resources)"]:::build
    end

    %% Relationships - Frontend Flow
    User -->|"initiates"| FrontendApp
    FrontendApp -->|"renders"| FrontComponents
    FrontComponents -->|"composes"| FrontViews
    FrontViews -->|"triggers service"| FrontService
    
    %% Frontend to Backend Communication via Wails Bridge
    FrontService -->|"WailsBridge"| Back_Interfaces

    %% Internal Backend Relationships (Onion Architecture)
    Back_MA -->|"exposes APIs to"| Back_Interfaces
    Back_Interfaces -->|"delegates to"| Back_BL
    Back_BL -->|"retrieves config"| Back_Config
    Back_BL -->|"uses"| SSHUtil
    Back_BL -->|"uses"| PingUtil

    %% Build Process
    Back_MA -->|"packaged by"| BuildDir

    %% Click Events
    click FrontendApp "https://github.com/paulaselim/switch-nexus/blob/main/frontend/src/App.vue"
    click FrontComponents "https://github.com/paulaselim/switch-nexus/blob/main/frontend/src/components/SwitchListItem.vue"
    click FrontComponents "https://github.com/paulaselim/switch-nexus/blob/main/frontend/src/components/VLANDetails.vue"
    click FrontService "https://github.com/paulaselim/switch-nexus/blob/main/frontend/src/service/MySwitchService.js"
    click FrontVite "https://github.com/paulaselim/switch-nexus/blob/main/frontend/vite.config.js"
    click Back_MA "https://github.com/paulaselim/switch-nexus/blob/main/main.go"
    click Back_Config "https://github.com/paulaselim/switch-nexus/blob/main/internal/config/env.go"
    click Back_Interfaces "https://github.com/paulaselim/switch-nexus/tree/main/internal/interfaces"
    click SSHUtil "https://github.com/paulaselim/switch-nexus/blob/main/internal/utilities/ssh/ssh.go"
    click PingUtil "https://github.com/paulaselim/switch-nexus/blob/main/internal/utilities/ping/ping.go"
    click BuildDir "https://github.com/paulaselim/switch-nexus/tree/main/build/"

    %% Styles
    classDef frontend fill:#add8e6,stroke:#000,stroke-width:2px;
    classDef backend fill:#90ee90,stroke:#000,stroke-width:2px;
    classDef util fill:#dda0dd,stroke:#000,stroke-width:2px;
    classDef config fill:#ffa500,stroke:#000,stroke-width:2px;
    classDef build fill:#ffebcd,stroke:#000,stroke-width:2px;
    classDef user fill:#ffc0cb,stroke:#000,stroke-width:2px;
```
