pSync guide

The full reference. For an overview, see the README. Peer-to-peer file sync between your own devices on the local network: no cloud, no server, no accounts. Android first, with a Windows app to follow; both in Kotlin.

No libraries. The app uses only the Kotlin stdlib plus the JDK / Android framework: no AndroidX, Compose, coroutines or kotlinx-serialization. The tests use a tiny built-in harness instead of JUnit. The release APK is ~110 KB.

Modules

ModuleWhatDepends on
coreSync engine: index, versioning, merge, rules, crypto, protocol, discoveryKotlin stdlib + JDK
androidAndroid app: SAF storage, foreground service, framework UIcore + Android framework
windows (next)Desktop app reusing core as-iscore + JDK

How sync works

Index and versions. Each device keeps an index per folder with a SHA-256 hash and a version vector for every file (deletions are kept as tombstones). A scan finds changes cheaply by size and mtime, and only hashes files that changed. Files modified in the last 2 s are skipped until they settle.

Sessions. Two devices open one encrypted TCP connection, exchange their folder lists, and then each side pulls what it's missing. The protocol is symmetric, so both sides run the same code.

Deciding what to do with each remote entry, by comparing version vectors:

Resolution is deterministic, so both devices reach the same content and the same version without another round of conflicts.

Safety nets

Rules per folder

Security

Network

PortUse
UDP 47430discovery beacons (broadcast)
TCP 47431sync connections (falls back to a random port if busy)

If discovery is blocked (guest Wi-Fi, client isolation, VPN), use Connect by address in the app.

Android notes

Build

Open the project in Android Studio, or:

./gradlew :core:runTests          # core tests (built-in harness, no JUnit)
./gradlew :android:assembleDebug  # APK in android/build/outputs/apk/debug/

Requires JDK 17+ and Android SDK 35.

Known limitations / roadmap