# anestlarry/simserver architecture

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

- Interactive diagram: https://gitdiagram.com/anestlarry/simserver
- Repository: https://github.com/anestlarry/simserver

## Overview

##### Project Identity and Purpose
- Project Type: A file server that enables transferring files, viewing directories, uploading files, and even supporting a chat board mode. It is built using Go (with Gin under the hood) and has a Svelte-based panel for a frontend interface.
- Key Use Cases: File download (with options like zip and secure extensions), file upload (with extra upload text support), viewing files and folders, and a chat board for interaction. Command line flags (such as -upload, -view, -chatBoard, etc.) indicate various modes of operation.

##### Main Components
- Backend Core:
- Source Code written in Go (e.g., ftpserve.go, Libs/Libs.go).
- Modules organized into directories:
▸ Libs: Core backend libraries.
▸ downloadGroup: Handles download logic.
▸ uploadGroup: Implements upload functionality.
▸ viewGroup: Contains view-related functionalities (like chatBoard and file viewing).
▸ config: Contains configuration logic (e.g., argsConfig.go).
- Command line interface configuration (flags and settings detailed in the README).
- Frontend Component:
- Svelte-based panel (under the “svelte” directory):
▸ Contains pages, components (like FileCardList, Toggleable), and configuration files for Tailwind, Vite, etc.
▸ Serves as a user interface panel to interact with the backend through file management and view modes.
- Additional Views:
- “view” directory: Provides an alternative view interface via plain HTML/CSS/JavaScript.
- External Resources and Deployment:
- Dockerfile: Indicates containerization for deployment.
- Pipeline definitions (e.g., pipelines/azure.yaml) to indicate CI/CD configuration.

##### Architectural Relationships and Data Flow
- The backend (Go) is the main server process listening on a configured IP and port.
- Incoming HTTP requests (for file downloads, uploads, and view mode) are managed by Gin routes.
- The backend modules (downloadGroup, uploadGroup, viewGroup) are encapsulated to handle specific methods and endpoints.
- Configuration settings from the “config” directory or via command-line flags are fed into the server application, determining operational modes (e.g., enabling chatBoard or secure file naming techniques).
- There is also some integration with external systems (e.g., secure HTTPS certificates, logging, and basic auth for resource protection).

##### Architectural Patterns & Design Principles
- Separation of Concerns: The project is clearly divided into backend logic (several specialized modules) and a frontend user interface (Svelte).
- Modular Design: Each folder like downloadGroup, uploadGroup, and viewGroup handles discrete functionality.
- Config-driven Behavior: The server relies on runtime configuration (through command-line flags and JSON config files) to toggle features on and off.
- Containerization and CI/CD integration: Indicated by the presence of Dockerfile and pipeline definition files.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Backend Server"
        direction TB
        coreService["Core Service (ftpserve.go)"]:::backend
        configManager["Configuration Manager (argsConfig.go)"]:::config
        libsNode["Core Libraries (Libs/Libs.go)"]:::backend
        downloadNode["Download Module (downloadGroup)"]:::module
        uploadNode["Upload Module (uploadGroup)"]:::module
        subgraph "View/Chat Module"
            direction TB
            viewChat["ChatBoard Module (viewGroup/chatBoard.go)"]:::module
            viewView["View Module (viewGroup/viewGroup.go)"]:::module
        end
        coreService --> libsNode
        coreService --> configManager
        coreService --> downloadNode
        coreService --> uploadNode
        coreService --> viewChat
        coreService --> viewView
    end

    subgraph "Frontend Panel"
        direction TB
        sveltePanel["Svelte Panel UI (svelte/panel)"]:::frontend
    end

    subgraph "Alternate View"
        direction TB
        altView["Alternate View UI (view)"]:::altview
    end

    subgraph "Deployment & CI/CD"
        direction TB
        dockerNode["Docker Deployment (Dockerfile)"]:::deployment
        pipelineNode["CI/CD Pipeline (pipelines/azure.yaml)"]:::deployment
    end

    sveltePanel -->|"HTTP_Request"| coreService
    altView -->|"HTTP_Request"| coreService
    configManager -->|"Config_Input"| coreService

    click coreService "https://github.com/anestlarry/simserver/blob/master/ftpserve.go"
    click libsNode "https://github.com/anestlarry/simserver/blob/master/Libs/Libs.go"
    click downloadNode "https://github.com/anestlarry/simserver/blob/master/downloadGroup/downloadGroup.go"
    click uploadNode "https://github.com/anestlarry/simserver/blob/master/uploadGroup/uploadGroup.go"
    click viewChat "https://github.com/anestlarry/simserver/blob/master/viewGroup/chatBoard.go"
    click viewView "https://github.com/anestlarry/simserver/blob/master/viewGroup/viewGroup.go"
    click configManager "https://github.com/anestlarry/simserver/blob/master/config/argsConfig.go"
    click sveltePanel "https://github.com/anestlarry/simserver/tree/master/svelte/panel"
    click altView "https://github.com/anestlarry/simserver/tree/master/view"
    click dockerNode "https://github.com/anestlarry/simserver/tree/master/Dockerfile"
    click pipelineNode "https://github.com/anestlarry/simserver/blob/master/pipelines/azure.yaml"

    classDef backend fill:#f9f,stroke:#333,stroke-width:2px;
    classDef module fill:#bbf,stroke:#333,stroke-width:2px;
    classDef config fill:#ff9,stroke:#333,stroke-width:2px;
    classDef frontend fill:#9f9,stroke:#333,stroke-width:2px;
    classDef altview fill:#fcf,stroke:#333,stroke-width:2px;
    classDef deployment fill:#cff,stroke:#333,stroke-width:2px;

    class coreService,libsNode backend;
    class downloadNode,uploadNode,viewChat,viewView module;
    class configManager config;
    class sveltePanel frontend;
    class altView altview;
    class dockerNode,pipelineNode deployment;
```
