# sigoden/dufs architecture

> Architecture diagram of the GitHub repository sigoden/dufs, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sigoden/dufs
- Repository: https://github.com/sigoden/dufs

## Overview

##### Main Components

a) Core Server Components:
- HTTP Server (based on src/server.rs)
- Authentication System (src/auth.rs)
- File System Interface
- WebDAV Interface
- HTTP Logger (src/http_logger.rs)

b) Frontend Components:
- Static Asset Server
- Web UI (assets/index.html, assets/index.js, assets/index.css)

c) External Interfaces:
- REST API Endpoints
- WebDAV Protocol Support
- File System Access

**┌─────────────────────────────────────────────┐**
- Client Layer                │
- (Web Browsers, cURL, WebDAV Clients)      │
- ┘
- ↕ HTTP/HTTPS
**┌─────────────────────────────────────────────┐**
- Transport Layer                │
- (TLS, CORS, Authentication, Logging)       │
- ┘
- ↕
**┌─────────────────────────────────────────────┐**
- Server Core                   │
- ┬─────────────┬────────────────┤
- Static     │   WebDAV    │  File System   │
- Server     │   Handler   │  Operations    │
- ┴─────────────┴────────────────┘
- ↕
**┌─────────────────────────────────────────────┐**
- Storage Layer                    │
- (Local File System, Symlinks)             │
- ┘

##### Key Interactions to Highlight

a) Authentication Flow:
- How auth rules (user:pass@/dir:rw) are processed
- Both Basic and Digest auth support

b) File Operations:
- Upload/Download paths
- Directory listing
- Search functionality
- ZIP archive creation

c) WebDAV Integration:
- MOVE, MKCOL, DELETE operations
- WebDAV client connections

##### Special Features

- Path prefix handling
- Hidden file filtering
- Compression options
- Custom asset serving
- Health check endpoint

##### Configuration Elements

Configuration sources:
- CLI arguments
- Environment variables
- YAML config file
- Default settings

##### Specific Implementation Details

- The modular Rust implementation (show main module relationships)
- The separation between core server logic and protocol handlers
- The extensible nature of the authentication system
- The flexible logging system

## Diagram (Mermaid)

```mermaid
graph TB
    %% Client Layer
    subgraph Clients
        Browser["Web Browser"]:::client
        WebDAVClient["WebDAV Client"]:::client
        CLIClient["CLI Client"]:::client
    end

    %% Transport Layer
    subgraph Transport
        TLS["TLS/Security"]:::security
        CORS["CORS Handler"]:::security
        Auth["Authentication System"]:::security
        Logger["HTTP Logger"]:::utility
    end

    %% Server Core
    subgraph Core
        HTTPServer["HTTP Server"]:::core
        WebDAV["WebDAV Handler"]:::core
        StaticServer["Static Asset Server"]:::core
        FSOperations["File System Operations"]:::core
        Config["Configuration Handler"]:::core
        Utils["Utility Functions"]:::utility
    end

    %% Frontend Layer
    subgraph Frontend
        WebUI["Web UI"]:::frontend
        Assets["Static Assets"]:::frontend
    end

    %% Storage Layer
    subgraph Storage
        LocalFS["Local File System"]:::storage
        Symlinks["Symlinks"]:::storage
    end

    %% Connections
    Browser --> TLS
    WebDAVClient --> TLS
    CLIClient --> TLS
    
    TLS --> Auth
    Auth --> HTTPServer
    CORS --> HTTPServer
    
    HTTPServer --> Logger
    HTTPServer --> WebDAV
    HTTPServer --> StaticServer
    HTTPServer --> FSOperations
    
    WebDAV --> FSOperations
    StaticServer --> Assets
    StaticServer --> WebUI
    
    FSOperations --> LocalFS
    FSOperations --> Symlinks
    
    Config --> HTTPServer
    Utils --> HTTPServer
    Utils --> FSOperations

    %% Click Events
    click HTTPServer "https://github.com/sigoden/dufs/blob/main/src/server.rs"
    click Auth "https://github.com/sigoden/dufs/blob/main/src/auth.rs"
    click Logger "https://github.com/sigoden/dufs/blob/main/src/http_logger.rs"
    click Utils "https://github.com/sigoden/dufs/blob/main/src/utils.rs"
    click Config "https://github.com/sigoden/dufs/blob/main/src/args.rs"
    click WebUI "https://github.com/sigoden/dufs/blob/main/assets/index.html"
    click TLS "https://github.com/sigoden/dufs/blob/main/tests/data/cert.pem"
    click Config "https://github.com/sigoden/dufs/blob/main/tests/data/config.yaml"

    %% Styles
    classDef client fill:#2374ab
    classDef security fill:#ffb347
    classDef core fill:#48a14d
    classDef frontend fill:#4a90e2
    classDef storage fill:#95a5a6
    classDef utility fill:#b19cd9

    %% Legend
    subgraph Legend
        Client["Client Component"]:::client
        SecurityComp["Security Component"]:::security
        CoreComp["Core Component"]:::core
        FrontendComp["Frontend Component"]:::frontend
        StorageComp["Storage Component"]:::storage
        UtilityComp["Utility Component"]:::utility
    end
```
