# hacdias/webdav architecture

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

- Interactive diagram: https://gitdiagram.com/hacdias/webdav
- Repository: https://github.com/hacdias/webdav

## Overview

##### Main Components
- Configuration Manager: The “lib/config.go” (and its test counterpart) along with examples in the README show that a configuration module is responsible for parsing configuration files (YAML/JSON/TOML) and applying settings such as port, TLS, debug mode, etc.
- Request & Handler Logic: The “lib/handler.go” (and its tests) encapsulate the heart of request processing and translating them to file system operations via WebDAV. This module communicates with both the configuration and the authentication modules.
- CI/CD and Deployment: The presence of the “.github/workflows” directory, Dockerfile, and a GoReleaser configuration indicates automated testing, building, and containerization. Although not part of the runtime architecture, include a separate “Deployment & CI/CD” cluster that shows how the project is built and deployed (Docker images, GitHub Actions, etc.).

##### Out Relationships and Interactions
- “WebDAV Server” to the “Configuration Manager” to show that server startup depends on loading settings.
- The “Handler Logic” block should also be connected to the “File System Access” component to reflect file operations.
- A side note block for “Containerization & CI/CD” that links to the deployment steps provided by Dockerfile and GitHub workflows.

##### Architectural Patterns and Design Principles
- Separation of Concerns: The project cleanly separates the responsibilities among startup/CLI commands (cmd/), configuration (lib/config), request handling (lib/handler), and user management (lib/user, lib/permissions).
- Configuration as a Service: The configuration component is central and configurable, as is evident from the README examples.
- Extensibility: User rules and permissions are designed to be extended via YAML configuration, making the architecture flexible.

##### Technologies and Frameworks
- Golang: The primary language for the development of the server.
- Docker: Used to containerize the application (note the Dockerfile and usage examples in the README).
- GitHub Actions: For CI/CD pipelines (present in the .github/workflows folder).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Startup / Bootstrap Components
    subgraph "Startup"
        mainExe("Main Executable"):::runtime
        cmdDir("CLI Commands"):::runtime
    end

    %% Core Service Components
    subgraph "Core Service"
        webdavServ("WebDAV Server"):::server
        configMgr("Configuration Manager"):::config
        configTest("Config Tests"):::test
        authUser("User Module"):::auth
        authPerm("Permissions Module"):::auth
        reqHandler("Request Handler"):::handler
        handlerTest("Handler Tests"):::test
        reqModule("Request Module"):::handler
        fsAccess("File System Access"):::files
    end

    %% External Interface
    revProxy("Reverse Proxy"):::external

    %% Deployment & CI/CD Components
    subgraph "Deployment & CI/CD"
        ciCd("CI/CD Workflows"):::deploy
        dockerF("Dockerfile"):::deploy
        goRel("GoReleaser"):::deploy
    end

    %% Flow Connections
    mainExe -->|"initializes"| webdavServ
    cmdDir -->|"triggers"| mainExe

    webdavServ -->|"loads|config"| configMgr
    configMgr -.->|"tested by"| configTest

    webdavServ -->|"authenticates"| authUser
    webdavServ -->|"authenticates"| authPerm

    webdavServ -->|"handles"| reqHandler
    reqHandler -->|"calls"| reqModule
    reqHandler -->|"accesses"| fsAccess
    reqHandler -.->|"tested by"| handlerTest

    revProxy -->|"routes to"| webdavServ

    dockerF -->|"containers"| webdavServ

    %% Click Event Mappings
    click mainExe "https://github.com/hacdias/webdav/blob/main/main.go"
    click cmdDir "https://github.com/hacdias/webdav/tree/main/cmd/"
    click webdavServ "https://github.com/hacdias/webdav/blob/main/main.go"
    click configMgr "https://github.com/hacdias/webdav/blob/main/lib/config.go"
    click configTest "https://github.com/hacdias/webdav/blob/main/lib/config_test.go"
    click authUser "https://github.com/hacdias/webdav/blob/main/lib/user.go"
    click authPerm "https://github.com/hacdias/webdav/blob/main/lib/permissions.go"
    click reqHandler "https://github.com/hacdias/webdav/blob/main/lib/handler.go"
    click handlerTest "https://github.com/hacdias/webdav/blob/main/lib/handler_test.go"
    click reqModule "https://github.com/hacdias/webdav/blob/main/lib/request.go"
    click fsAccess "https://github.com/hacdias/webdav/blob/main/lib/files.go"
    click ciCd "https://github.com/hacdias/webdav/tree/main/.github/workflows/"
    click dockerF "https://github.com/hacdias/webdav/tree/main/Dockerfile"
    click goRel "https://github.com/hacdias/webdav/blob/main/.goreleaser.yml"

    %% Styles
    classDef runtime fill:#f0e68c,stroke:#333,stroke-width:2px;
    classDef server fill:#add8e6,stroke:#333,stroke-width:2px;
    classDef config fill:#98fb98,stroke:#333,stroke-width:2px;
    classDef test fill:#d3d3d3,stroke:#333,stroke-dasharray: 5, 5;
    classDef auth fill:#ffd700,stroke:#333,stroke-width:2px;
    classDef handler fill:#ffb6c1,stroke:#333,stroke-width:2px;
    classDef files fill:#afeeee,stroke:#333,stroke-width:2px;
    classDef external fill:#dcdcdc,stroke:#333,stroke-width:2px;
    classDef deploy fill:#e0ffe0,stroke:#333,stroke-width:2px;
```
