# drakkan/sftpgo architecture

> Architecture diagram of the GitHub repository drakkan/sftpgo, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/drakkan/sftpgo
- Repository: https://github.com/drakkan/sftpgo
- Video tour (about a minute): https://gitdiagram.com/drakkan/sftpgo/video

## Overview

SFTPGo is an event-driven file-transfer server supporting SFTP, HTTP/S, FTP/S, and WebDAV, with local, encrypted, and cloud/remote storage backends. The main workflow is a client connecting through a protocol server, authenticating against configured account data, and transferring files through a virtual filesystem to its storage backend. The tree and README establish the major protocol, UI/API, storage, and automation capabilities; sampled server excerpts confirm some server startup and authentication paths, but not every protocol-to-storage call, so uncertain wiring is omitted.

Main entry points: [`internal/httpd/server.go`](https://github.com/drakkan/sftpgo/blob/main/internal/httpd/server.go) (HTTP/S server), [`internal/vfs/vfs.go`](https://github.com/drakkan/sftpgo/blob/main/internal/vfs/vfs.go) (Virtual filesystem), [`internal/service/service.go`](https://github.com/drakkan/sftpgo/blob/main/internal/service/service.go) (Service lifecycle), [`internal/dataprovider/dataprovider.go`](https://github.com/drakkan/sftpgo/blob/main/internal/dataprovider/dataprovider.go) (Data provider)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime"]
  node_service["Service lifecycle<br/>[service.go]"]
  node_telemetry["Telemetry<br/>[router.go]"]
end

subgraph group_protocols["Transfer protocols"]
  node_sftp["SFTP server<br/>[server.go]"]
  node_ftp["FTP/S server<br/>[server.go]"]
  node_http["HTTP/S server<br/>[server.go]"]
  node_webdav["WebDAV server<br/>[server.go]"]
  node_adminui["WebAdmin UI<br/>[webadmin.go]"]
  node_clientui["WebClient UI<br/>[webclient.go]"]
  node_restapi["REST API<br/>[api_user.go]"]
  node_shares["Public sharing<br/>[api_shares.go]"]
end

subgraph group_identity["Identity and control"]
  node_accounts["Accounts and policy<br/>[user.go]"]
  node_provider["Data provider<br/>[dataprovider.go]"]
  node_auth["Authentication<br/>[auth_utils.go]"]
  node_events["Event automation<br/>[eventmanager.go]"]
  node_mfa["Multi-factor auth<br/>[mfa.go]"]
end

subgraph group_storage["Storage"]
  node_vfs["Virtual filesystem<br/>[vfs.go]"]
  node_local["Local storage<br/>[osfs.go]"]
  node_encrypted["Encrypted storage<br/>[cryptfs.go]"]
  node_cloud["Cloud storage<br/>[s3fs.go]"]
  node_remote["Remote SFTP<br/>[sftpfs.go]"]
end

node_operator(("Operator"))
node_client(("Transfer client"))

node_operator -->|"starts and configures"| node_service
node_service -->|"starts"| node_sftp
node_service -->|"starts"| node_ftp
node_service -->|"starts"| node_http
node_service -->|"starts"| node_webdav
node_service -->|"starts"| node_telemetry
node_client -->|"connects"| node_sftp
node_client -->|"connects"| node_ftp
node_client -->|"connects"| node_http
node_client -->|"connects"| node_webdav
node_http -->|"serves UI"| node_adminui
node_http -->|"serves UI"| node_clientui
node_http -->|"routes API"| node_restapi
node_http -->|"routes sharing"| node_shares
node_sftp -->|"validates credentials"| node_provider
node_ftp -->|"authenticates users"| node_provider
node_webdav -->|"authenticates users"| node_provider
node_http -->|"checks accounts"| node_provider
node_provider -->|"loads account data"| node_accounts
node_http -->|"uses auth helpers"| node_auth
node_auth -->|"supports MFA"| node_mfa
node_provider -->|"event rules"| node_events
node_sftp -->|"file operations"| node_vfs
node_ftp -->|"file operations"| node_vfs
node_http -->|"file operations"| node_vfs
node_webdav -->|"file operations"| node_vfs
node_vfs -->|"accesses"| node_local
node_vfs -->|"accesses"| node_encrypted
node_vfs -->|"accesses"| node_cloud
node_vfs -->|"accesses"| node_remote
node_client -.->|"manages server"| node_adminui
node_client -.->|"browses files"| node_clientui

click node_service "https://github.com/drakkan/sftpgo/blob/main/internal/service/service.go"
click node_sftp "https://github.com/drakkan/sftpgo/blob/main/internal/sftpd/server.go"
click node_ftp "https://github.com/drakkan/sftpgo/blob/main/internal/ftpd/server.go"
click node_http "https://github.com/drakkan/sftpgo/blob/main/internal/httpd/server.go"
click node_webdav "https://github.com/drakkan/sftpgo/blob/main/internal/webdavd/server.go"
click node_adminui "https://github.com/drakkan/sftpgo/blob/main/internal/httpd/webadmin.go"
click node_clientui "https://github.com/drakkan/sftpgo/blob/main/internal/httpd/webclient.go"
click node_restapi "https://github.com/drakkan/sftpgo/blob/main/internal/httpd/api_user.go"
click node_shares "https://github.com/drakkan/sftpgo/blob/main/internal/httpd/api_shares.go"
click node_accounts "https://github.com/drakkan/sftpgo/blob/main/internal/dataprovider/user.go"
click node_provider "https://github.com/drakkan/sftpgo/blob/main/internal/dataprovider/dataprovider.go"
click node_auth "https://github.com/drakkan/sftpgo/blob/main/internal/httpd/auth_utils.go"
click node_events "https://github.com/drakkan/sftpgo/blob/main/internal/common/eventmanager.go"
click node_mfa "https://github.com/drakkan/sftpgo/blob/main/internal/mfa/mfa.go"
click node_vfs "https://github.com/drakkan/sftpgo/blob/main/internal/vfs/vfs.go"
click node_local "https://github.com/drakkan/sftpgo/blob/main/internal/vfs/osfs.go"
click node_encrypted "https://github.com/drakkan/sftpgo/blob/main/internal/vfs/cryptfs.go"
click node_cloud "https://github.com/drakkan/sftpgo/blob/main/internal/vfs/s3fs.go"
click node_remote "https://github.com/drakkan/sftpgo/blob/main/internal/vfs/sftpfs.go"
click node_telemetry "https://github.com/drakkan/sftpgo/blob/main/internal/telemetry/router.go"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_service,node_telemetry,node_client toneBlue
class node_sftp,node_ftp,node_http,node_webdav,node_adminui,node_clientui,node_restapi,node_shares toneAmber
class node_accounts,node_provider,node_auth,node_events,node_mfa toneMint
class node_vfs,node_local,node_encrypted,node_cloud,node_remote toneRose
class node_operator toneIndigo
```

## Components

### Runtime

- [Service lifecycle](https://github.com/drakkan/sftpgo/blob/main/internal/service/service.go): `internal/service/service.go`
- [Telemetry](https://github.com/drakkan/sftpgo/blob/main/internal/telemetry/router.go): `internal/telemetry/router.go`

### Transfer protocols

- [SFTP server](https://github.com/drakkan/sftpgo/blob/main/internal/sftpd/server.go): `internal/sftpd/server.go`
- [FTP/S server](https://github.com/drakkan/sftpgo/blob/main/internal/ftpd/server.go): `internal/ftpd/server.go`
- [HTTP/S server](https://github.com/drakkan/sftpgo/blob/main/internal/httpd/server.go): `internal/httpd/server.go`
- [WebDAV server](https://github.com/drakkan/sftpgo/blob/main/internal/webdavd/server.go): `internal/webdavd/server.go`
- [WebAdmin UI](https://github.com/drakkan/sftpgo/blob/main/internal/httpd/webadmin.go): `internal/httpd/webadmin.go`
- [WebClient UI](https://github.com/drakkan/sftpgo/blob/main/internal/httpd/webclient.go): `internal/httpd/webclient.go`
- [REST API](https://github.com/drakkan/sftpgo/blob/main/internal/httpd/api_user.go): `internal/httpd/api_user.go`
- [Public sharing](https://github.com/drakkan/sftpgo/blob/main/internal/httpd/api_shares.go): `internal/httpd/api_shares.go`

### Identity and control

- [Accounts and policy](https://github.com/drakkan/sftpgo/blob/main/internal/dataprovider/user.go): `internal/dataprovider/user.go`
- [Data provider](https://github.com/drakkan/sftpgo/blob/main/internal/dataprovider/dataprovider.go): `internal/dataprovider/dataprovider.go`
- [Authentication](https://github.com/drakkan/sftpgo/blob/main/internal/httpd/auth_utils.go): `internal/httpd/auth_utils.go`
- [Event automation](https://github.com/drakkan/sftpgo/blob/main/internal/common/eventmanager.go): `internal/common/eventmanager.go`
- [Multi-factor auth](https://github.com/drakkan/sftpgo/blob/main/internal/mfa/mfa.go): `internal/mfa/mfa.go`

### Storage

- [Virtual filesystem](https://github.com/drakkan/sftpgo/blob/main/internal/vfs/vfs.go): `internal/vfs/vfs.go`
- [Local storage](https://github.com/drakkan/sftpgo/blob/main/internal/vfs/osfs.go): `internal/vfs/osfs.go`
- [Encrypted storage](https://github.com/drakkan/sftpgo/blob/main/internal/vfs/cryptfs.go): `internal/vfs/cryptfs.go`
- [Cloud storage](https://github.com/drakkan/sftpgo/blob/main/internal/vfs/s3fs.go): `internal/vfs/s3fs.go`
- [Remote SFTP](https://github.com/drakkan/sftpgo/blob/main/internal/vfs/sftpfs.go): `internal/vfs/sftpfs.go`

### Other components

- **Operator**
- **Transfer client**

## Connections

- Operator → Service lifecycle: starts and configures
- Service lifecycle → SFTP server: starts
- Service lifecycle → FTP/S server: starts
- Service lifecycle → HTTP/S server: starts
- Service lifecycle → WebDAV server: starts
- Service lifecycle → Telemetry: starts
- Transfer client → SFTP server: connects
- Transfer client → FTP/S server: connects
- Transfer client → HTTP/S server: connects
- Transfer client → WebDAV server: connects
- HTTP/S server → WebAdmin UI: serves UI
- HTTP/S server → WebClient UI: serves UI
- HTTP/S server → REST API: routes API
- HTTP/S server → Public sharing: routes sharing
- SFTP server → Data provider: validates credentials
- FTP/S server → Data provider: authenticates users
- WebDAV server → Data provider: authenticates users
- HTTP/S server → Data provider: checks accounts
- Data provider → Accounts and policy: loads account data
- HTTP/S server → Authentication: uses auth helpers
- Authentication → Multi-factor auth: supports MFA
- Data provider → Event automation: event rules
- SFTP server → Virtual filesystem: file operations
- FTP/S server → Virtual filesystem: file operations
- HTTP/S server → Virtual filesystem: file operations
- WebDAV server → Virtual filesystem: file operations
- Virtual filesystem → Local storage: accesses
- Virtual filesystem → Encrypted storage: accesses
- Virtual filesystem → Cloud storage: accesses
- Virtual filesystem → Remote SFTP: accesses
- Transfer client → WebAdmin UI: manages server
- Transfer client → WebClient UI: browses files
