Essay

What if social worked like email?

So where am I at? My friends still don't use it eheh.. Many asked me for a native mobile app. A web app in a browser is different, and "convincing" people who already don't want to move away from social is absolutely impossible without a mobile app. Also I thought: I'm studying and preparing for job interviews and I want to use Kotlin Multiplatform, so which better occasion than this?

So native apps then! On Android, iOS and Desktop too.

Now the problem. Apparently when you build something like Nearstream you fall into the category of "social network". You need to start thinking about what people post, what's allowed and what's not. Moderation, legal stuff, all of it. On the web nobody checks this before you go live, but on the App Store and Google Play it's another story. If your app shows content from other users, Apple and Google want you to be the moderator: filter content, let people report and block, act on reports. And the law (the Online Safety Act here in the UK, the DSA in Europe) points at whoever hosts the content.

So I thought: this is not happening. I don't want to be a social network that moderates and hosts stuff from everyone. Even Mastodon has this problem: every server keeps a copy of every post its users follow, so every admin ends up moderating people they've never met.

Then I thought about emails.. So welcome to Nearstream Protocol v0.1 :)

So how does it work in short? Well, it's complicated, but the idea is this. If I make this app only for my friends, they could stay under nearstream.app/theirname and I could trust that nobody would post anything illegal.. but if I open Nearstream to everyone, Google and Apple require me to be the "moderator" of everyone. But here is the idea. What if people could host their own Nearstream? A friend of a friend of a friend (I don't know them directly) who is a nerd and wants to host a server for their circle of friends. It's a bit like what the email protocol does: Gmail is one host, but anyone can run their own mail server, and any app can read your mail.

Now the challenge. How can Alice and Bob talk to each other and add each other as friends if they are on different servers? Here's the protocol:

Describe the image

A bit more technical

One rule above everything: your posts live only on your own server. Nothing is ever copied anywhere else. Your friends' servers come and read them, they don't keep them. This means a server only hosts its own people. If Bob is on another server, his posts are never on mine, so I'm never the host of strangers.

Every address (like alessandroborelli.it or nearstream.app/bob) has a small public card at /.well-known/nearstream with your name, your public feed and your "doorbell".

When Alice wants to share with Bob:

  1. Her server makes a key for Bob, a private feed URL that only exists for him.
  2. Her server rings Bob's doorbell with that key. The doorbell stores nothing, it just rings. No inbox, no messages piling up.
  3. Bob's server checks that the key really lives on Alice's domain and actually works. Only then does Bob see "Alice wants to share with you". He can accept or ignore.
  4. Alice posts something friends-only. It stays on her server. She rings "new", Bob's server fetches her feed with his key, and his phone says "Alice posted". Photos and voice notes go through the key too, so they can't leak around it.
  5. If Alice stops sharing, the key dies. The server answers "410 Gone" and she disappears from Bob's reader. Delete means gone.

Sharing is one-way. If Bob wants Alice to see his stuff, he does the same thing the other way.

It's all built on RSS, so your public posts already work in any RSS reader in the world. I have two real servers running on my laptop and a test that plays the whole story (sharing, friends-only posts, a fake share, revoking) and checks every step.

It's not perfect, and that's on purpose. A friend can forward their key, like forwarding an email. The trust is friendship, not cryptography: you see which key is used, you revoke it. If your server is down, nobody sees your new posts. And there are no likes, comments or follower counts. Not missing, left out.

What's next

The app! Kotlin Multiplatform: Android first, then iOS and desktop. The server side for the app is already there, so the app can talk to any Nearstream server, the same way a mail app works with any mail provider.