How syncthing/syncthing works
Syncthing is a continuous file-synchronization program. Its principal workflow is to discover peer devices, establish secure connections, exchange folder indexes, scan and compare files, and transfer updates while maintaining local index state. The graph also preserves configuration/API and GUI, discovery and connection infrastructure, and the independent discovery and relay services. Edges reflect explicit README statements or source-index references; where runtime wiring is not shown, relationships are omitted rather than inferred.
Main entry points: walk.go File scanner · indexhandler.go Index exchange · protocol.go Sync protocol · service.go Connection manager
Components 19
Synchronization engine
- Syncthing CLI
cmd/syncthing/main.go - Application runtime
lib/syncthing/syncthing.go - Folder model
lib/model/model.go - Index exchange
lib/model/indexhandler.go - File scanner
lib/scanner/walk.go
Peer networking
- Sync protocol
lib/protocol/protocol.go - Connection manager
lib/connections/service.go - Device discovery
lib/discover/manager.go
Configuration and interface
- Configuration
lib/config/config.go - HTTP API
lib/api/api.go - Web GUI
gui/default/syncthing/core/syncthingController.js
Network services
- Global discovery server
cmd/stdiscosrv/main.go - Discovery database
cmd/stdiscosrv/database.go - Relay server
cmd/strelaysrv/main.go - Relay pool server
cmd/infra/strelaypoolsrv/main.go
Persistence and files
- Index database
internal/db/sqlite/db_service.go - Filesystem layer
lib/fs/filesystem.go - Ignore rules
lib/ignore/ignore.go
Other components
- User
Connections 13
- User → Syncthing CLI: starts
cmd/syncthing/main.go - Syncthing CLI → Application runtime: starts runtime
cmd/syncthing/main.go - Folder model → Index exchange: handles indexes
- Index exchange → Index database: reads and writes
lib/model/indexhandler.go - Index exchange → Sync protocol: exchanges indexes
lib/model/indexhandler.go - File scanner → Filesystem layer: walks files
lib/scanner/walk.go - File scanner → Ignore rules: checks exclusions
lib/scanner/walk.go - File scanner → Sync protocol: creates file data
lib/scanner/walk.go - Connection manager → Device discovery: resolves peers
lib/connections/service.go - Connection manager → Sync protocol: connects devices
- Global discovery server → Discovery database: starts database
cmd/stdiscosrv/main.go - Web GUI → HTTP API: uses API
- User → Web GUI: manages