# winfsp/sshfs-win architecture

> Architecture diagram of the GitHub repository winfsp/sshfs-win, 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/winfsp/sshfs-win
- Repository: https://github.com/winfsp/sshfs-win

## Overview

##### Main Components
- Windows Shell/Explorer & Networking: Represent how the user or the “net use” command interacts with the mapped network drive.
- SSHFS-Win Wrapper: The sshfs-win.c file is the main entry point; it acts as a wrapper to translate Windows drive mapping requests into calls to SSHFS.
- Upstream SSHFS Submodule: Highlight that the project includes the full SSHFS code (patched by files in the “patches” directory) to do the heavy lifting.
- Cygwin Environment: Illustrate that a POSIX-like environment (provided by Cygwin) is required to run the SSHFS binary.
- WinFsp (and its related components): Indicate that WinFsp provides the FUSE (Filesystem in Userspace) functionality on Windows so that the mounted filesystem appears native.
- Build and Installer Components: Include the Makefile, Wix installer file (sshfs-win.wxs), and additional tools (such as registry patch files in “etc” and “patches”) as part of the build/packaging process.

##### Relationships and Data Flow
- That the SSHFS process communicates with the remote SSHFS host over SSH (including options for tunneling or key-based authentication as explained in the README).
- Interaction with WinFsp: after the SSHFS/Cygwin layer decodes the network drive operations, WinFsp translates them into Windows file system calls.
- Optionally, add the build and installer components on the side. Show that the build process (driven by the Makefile and patches incorporated from “patches”, “art”, and “etc”) packages everything into an MSI installer via the Wix configuration.

##### Architectural Patterns
- Layered architecture: Windows front end (user interactions) → Wrapper & integration layer → POSIX SSHFS engine (with patches) → WinFsp file system integration.
- That the project uses external dependencies (Cygwin for POSIX, WinFsp for FUSE) and patches over upstream SSHFS to meet Windows-specific requirements.
- The separation of concerns is clear—the wrapper handles Windows connectivity logic and the SSHFS submodule handles remote filesystem semantics.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Windows Interaction Layer
    WinExplorer["Windows Explorer/Net Use"]:::windows
    SSHFSWrapper["SSHFS-Win Wrapper (sshfs-win.c)"]:::windows

    %% POSIX Integration Layer
    subgraph "POSIX Layer"
        Cygwin["Cygwin Environment"]:::posix
        SSHFSEngine["Patched SSHFS Engine (Submodule+Patches)"]:::posix
        Cygwin -->|"runs"| SSHFSEngine
    end

    %% External and Windows Filesystem Integration
    RemoteSSH["Remote SSH Host (SSH)"]:::posix
    WinFsp["WinFsp (FUSE for Windows)"]:::windows

    %% Build & Deployment Layer
    subgraph "Build & Deployment"
        BuildProcess["Build Process (Makefile)"]:::build
        InstallerConfig["Installer Configuration (sshfs-win.wxs)"]:::build
        PatchIntegration["Patch Integration (patches)"]:::build
        ArtResources["Art Resources (art)"]:::build
        EtcFiles["Configuration Files (etc)"]:::build
    end

    %% Flow of operations
    WinExplorer -->|"initiates"| SSHFSWrapper
    SSHFSWrapper -->|"calls"| Cygwin
    SSHFSEngine -->|"sends_ops"| WinFsp
    SSHFSEngine -->|"communicates"| RemoteSSH
    WinFsp -->|"mounts_drive"| WinExplorer

    %% Build Process Flow
    BuildProcess -->|"packages_into"| InstallerConfig
    PatchIntegration -->|"integrated_into"| InstallerConfig
    ArtResources -->|"integrated_into"| InstallerConfig
    EtcFiles -->|"integrated_into"| InstallerConfig
    InstallerConfig -->|"deploys"| SSHFSWrapper

    %% Click Events
    click SSHFSWrapper "https://github.com/winfsp/sshfs-win/blob/master/sshfs-win.c"
    click SSHFSEngine "https://github.com/winfsp/sshfs-win/tree/master/sshfs"
    click PatchIntegration "https://github.com/winfsp/sshfs-win/tree/master/patches"
    click BuildProcess "https://github.com/winfsp/sshfs-win/tree/master/Makefile"
    click InstallerConfig "https://github.com/winfsp/sshfs-win/blob/master/sshfs-win.wxs"
    click ArtResources "https://github.com/winfsp/sshfs-win/tree/master/art"
    click EtcFiles "https://github.com/winfsp/sshfs-win/tree/master/etc"

    %% Styles
    classDef windows fill:#ADD8E6,stroke:#000,stroke-width:1px;
    classDef posix fill:#90EE90,stroke:#000,stroke-width:1px;
    classDef build fill:#FFA07A,stroke:#000,stroke-width:1px;
```
