# sw-fantastic/desktop-file-server architecture

> Architecture diagram of the GitHub repository sw-fantastic/desktop-file-server, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sw-fantastic/desktop-file-server
- Repository: https://github.com/sw-fantastic/desktop-file-server

## Overview

##### Main Components
a. Desktop Application (single JVM process)
b. JavaFX Client UI
c. Client Protocol Layer (FTP client, WebDAV client)
d. Vert.x Servers
- FTP Server Verticle
- HTTP Server (WebDAV + Web UI) Verticle
e. Business Logic / Service Layer
f. Data Access Layer (Hibernate Repos)
g. Embedded Database (MariaDB)
h. Configuration & Assets
i. Static Web UI (Vue3 + Tailwind)

##### Relationships & Data Flows
- JavaFX UI ↔ Client Protocol Layer: invokes FTP/WebDAV methods
- Client Protocol Layer → Vert.x Servers (over localhost TCP)
- FTP on port configured in assets/server-config.json
- HTTP/WebDAV on port configured in assets/server-config.json
- HTTP Server → Serves both WebDAV API and static Web UI files
- Vert.x Servers → Business Logic / Service classes
- Service classes → Repository layer (ORM entities)
- Repositories ↔ Embedded MariaDB
- On startup: Launcher reads assets/config.json & assets/system.json → RmDiskApplicationConfig
- Logging → logs directory

##### Architectural Patterns & Principles
- Layered Architecture: Presentation (JavaFX & Vue3), Protocol (FTP/WebDAV), Service, Repository, Database
- Vert.x Event-Driven Concurrency: separate verticles for HTTP and FTP handlers
- Repository Pattern via Hibernate (src/main/java/.../core/repo)
- Modular design: core (common types), client (protocols), service (verticles), views (UI)
- Configuration-Driven: all ports, skins, language, DB settings externalized in JSON/properties

##### Technologies & Frameworks
- Vert.x (Verticles, HTTP & Net servers)
- JavaFX (FXML views, Controllers)
- Hibernate / JPA (ORM) + MariaDB-Embedded
- Vue3 + Tailwind CSS (Web UI under src/main/resources/webcontent)
- Password4j, JCIFS, Caffeine, JJWT, Apache-Tika

##### Detailed Capture of Essential Elements
- That the Launcher initializes both JavaFX and Vert.x servers
- That static files (index.html, JS/CSS) are served by HTTP server verticle
- Authentication flow: SecureUtils → Token generation via JJWT → Caffeine cache for sessions
- That FTP handlers use FTPSessionContext and PathAccessor from core/ftp
- ORM entities and Hibernate configuration loaded from src/main/resources/database/hibernate.properties

- How the desktop client UI and the server protocols co-exist in one application
- The flow from user interactions through protocol, business logic, persistence, and back
- The role of external technologies and configuration files

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Side
    subgraph "Client Side" 
        direction TB
        Launcher["Desktop Application Launcher"]:::service
        ConfigReader["RmDiskApplicationConfig"]:::config
        subgraph "JavaFX Client UI" 
            direction TB
            UIControllers["Controllers & Views"]:::ui
            FXMLLayouts["FXML Layouts"]:::ui
        end
        subgraph "Client Protocol Layer"
            direction TB
            FTPClient["FTPClient Module"]:::protocol
            WebDAVClient["WebDAVClient Module"]:::protocol
            ClientDesc["ClientDescriptor"]:::protocol
        end
    end

    %% Server Side
    subgraph "Server Side"
        direction TB
        subgraph "Vert.x Servers"
            direction TB
            FTPVerticle["Vert.x FTP Server Verticle"]:::service
            FTPHandlers["FTP Handlers"]:::service
            HTTPVerticle["Vert.x HTTP/WebDAV Server Verticle"]:::service
            DAVHandlers["WebDAV Handlers"]:::service
            HTTPHandlers["HTTP Handlers"]:::service
            StaticResHandler["Static Resource Handler"]:::service
        end
        subgraph "Business Logic / Service Layer"
            direction TB
            Services["Core Services (DiskFileService, UserManageService)"]:::service
        end
        subgraph "Data Access Layer"
            direction TB
            Entities["ORM Entities"]:::data
            Repos["Repository Interfaces"]:::data
        end
    end

    %% Database & Config
    subgraph "Infrastructure"
        direction TB
        DB["Embedded MariaDB"]:::db
        HibernateProps["Hibernate Properties"]:::config
        JSONConfigs["JSON Configs"]:::config
        UISkins["UI Skins & Styles"]:::config
        subgraph "Static Web UI"
            direction TB
            Index["index.html / Application.js / commons.css"]:::webui
            VueComps["Vue Components & Pages"]:::webui
            VueMods["Supporting Modules"]:::webui
            VueService["Service Scripts"]:::webui
        end
    end

    %% Connections
    Launcher --> ConfigReader
    Launcher --> UIControllers
    Launcher --> FTPVerticle
    Launcher --> HTTPVerticle

    UIControllers --> FTPClient
    UIControllers --> WebDAVClient
    UIControllers --> ClientDesc

    FTPClient -->|TCP localhost| FTPVerticle
    WebDAVClient -->|TCP localhost| HTTPVerticle

    HTTPVerticle --> DAVHandlers
    HTTPVerticle --> HTTPHandlers
    HTTPVerticle --> StaticResHandler

    FTPVerticle --> FTPHandlers

    FTPVerticle --> Services
    HTTPVerticle --> Services
    DAVHandlers --> Services
    HTTPHandlers --> Services

    Services --> Repos
    Repos --> Entities
    Entities --> DB

    ConfigReader --> JSONConfigs
    ConfigReader --> HibernateProps
    JSONConfigs --> Launcher

    StaticResHandler --> Index
    Index --> VueComps
    Index --> VueMods
    Index --> VueService

    %% Click Events
    click Launcher "https://github.com/sw-fantastic/desktop-file-server/blob/master/src/main/java/org/swdc/rmdisk/Launcher.java"
    click ConfigReader "https://github.com/sw-fantastic/desktop-file-server/blob/master/src/main/java/org/swdc/rmdisk/RmDiskApplicationConfig.java"
    click UIControllers "https://github.com/sw-fantastic/desktop-file-server/tree/master/src/main/java/org/swdc/rmdisk/views"
    click FXMLLayouts "https://github.com/sw-fantastic/desktop-file-server/tree/master/src/main/resources/views"
    click FTPClient "https://github.com/sw-fantastic/desktop-file-server/tree/master/src/main/java/org/swdc/rmdisk/client/protocol"
    click WebDAVClient "https://github.com/sw-fantastic/desktop-file-server/tree/master/src/main/java/org/swdc/rmdisk/client/protocol"
    click ClientDesc "https://github.com/sw-fantastic/desktop-file-server/blob/master/src/main/java/org/swdc/rmdisk/client/ClientDescriptor.java"
    click FTPVerticle "https://github.com/sw-fantastic/desktop-file-server/blob/master/src/main/java/org/swdc/rmdisk/service/verticle/VertxFTPVerticle.java"
    click FTPHandlers "https://github.com/sw-fantastic/desktop-file-server/tree/master/src/main/java/org/swdc/rmdisk/service/verticle/ftp"
    click HTTPVerticle "https://github.com/sw-fantastic/desktop-file-server/blob/master/src/main/java/org/swdc/rmdisk/service/verticle/VertxHttpVerticle.java"
    click DAVHandlers "https://github.com/sw-fantastic/desktop-file-server/tree/master/src/main/java/org/swdc/rmdisk/service/verticle/dav"
    click HTTPHandlers "https://github.com/sw-fantastic/desktop-file-server/tree/master/src/main/java/org/swdc/rmdisk/service/verticle/http"
    click StaticResHandler "https://github.com/sw-fantastic/desktop-file-server/blob/master/src/main/java/org/swdc/rmdisk/service/verticle/VertxWebResourceHandler.java"
    click Services "https://github.com/sw-fantastic/desktop-file-server/tree/master/src/main/java/org/swdc/rmdisk/service"
    click Entities "https://github.com/sw-fantastic/desktop-file-server/tree/master/src/main/java/org/swdc/rmdisk/core/entity"
    click Repos "https://github.com/sw-fantastic/desktop-file-server/tree/master/src/main/java/org/swdc/rmdisk/core/repo"
    click HibernateProps "https://github.com/sw-fantastic/desktop-file-server/blob/master/src/main/resources/database/hibernate.properties"
    click JSONConfigs "https://github.com/sw-fantastic/desktop-file-server/blob/master/assets/config.json"
    click UISkins "https://github.com/sw-fantastic/desktop-file-server/tree/master/assets/skin/default"
    click Index "https://github.com/sw-fantastic/desktop-file-server/blob/master/src/main/resources/webcontent/index.html"
    click VueComps "https://github.com/sw-fantastic/desktop-file-server/tree/master/src/main/resources/webcontent/components"
    click VueMods "https://github.com/sw-fantastic/desktop-file-server/tree/master/src/main/resources/webcontent/modules"
    click VueService "https://github.com/sw-fantastic/desktop-file-server/tree/master/src/main/resources/webcontent/service"

    %% Styles
    classDef ui fill:#D0E8FF,stroke:#0366d6,color:#0366d6
    classDef protocol fill:#E6FFDA,stroke:#28a745,color:#28a745
    classDef service fill:#FFF5CC,stroke:#DBAB09,color:#8A6D3B
    classDef data fill:#F0F0F0,stroke:#999999,color:#333333
    classDef db fill:#E0F7FA,stroke:#00796B,color:#004D40
    classDef config fill:#F5F5F5,stroke:#AAAAAA,color:#555555
    classDef webui fill:#F3E5F5,stroke:#7B1FA2,color:#4A148C
```
