Uplink Developer docs Get Uplink
The source

How the app is built

The major parts of Uplink, where each lives in the source, and what it talks to.

Uplink is one Flutter app for Android, iPhone, Mac, Windows, Linux and the browser, a small relay server, and a few helper programs. This page is a map of the source for someone about to read or change it: what each part is for, where it lives, and what it talks to. Paths are from the repository's root (github.com/InfamousVague/ghost-messaging).

Where things are

FolderWhat it holds
lib/The app, in Dart, for every platform. lib/web is its start in a browser.
web/The page the browser build is loaded by: index.html with its policy, the loader, and argon2id.js, the one piece of JavaScript it carries.
android/The Android half, in Kotlin: SMS and MMS, notifications, encryption keys, the link to paired computers, the Google Messages bridge, bubbles, a friend's call ringing, the updater.
ios/, macos/, windows/, linux/Each platform's runner, with the native pieces the app calls: call recording, captions, transcripts, voice messages, sounds, updates, deep links. Windows' are C++ files in windows/runner (call_recorder.cpp, speech.cpp, desk_sound.cpp, ducking.cpp).
native/voicefxThe microphone's noise removal, gain and live voice effects, in C (RNNoise, DeepFilterNet where built in, and Signalsmith Stretch behind stretch.cpp), shared by every platform.
native/p2pThe direct route's core, in Rust on iroh: a node that opens framed streams to another node by its id. It carries bytes and decides nothing; every rule is Dart.
native/link-checkA Rust program that starts or dials a link helper and links two nodes through it, to prove one works.
packages/glacierGlacier, the UI kit the screens are drawn with. A copy; it is changed in its own repository.
relay/The relay server: a Dart program with no dependencies beyond Dart's own library. relay/deploy holds what running one needs: a compose file for relay/Dockerfile, sample web server blocks, service files and relay.env.example.
sidecar/Go programs the app runs beside itself, one for each network that needs one: Google Messages, Signal, WhatsApp, Matrix, Messenger, Instagram, Discord, X and Slack. (sidecar/linkedin is in the tree; the app doesn't offer LinkedIn.)
discord/A Node program: the bot that shows a Discord server's voice channels and bridges one into a space. Not the helper for Discord's own chats, which is sidecar/discord.
extension/The browser extension, in TypeScript: it reads the sign-in cookies of the networks signed in to in the browser and keeps them, sealed, for the account's devices.
tool/Build, release and deploy scripts, asset generators, the browser build's own checks (tool/web), and tests that run against a live relay (tool/net).
site/, docs-src/gogho.st and these docs. docs-src is the source; tool/build-docs.mjs writes site/docs.
docs/Maintainers' notes, one per large feature: the network (network.md), direct links, relays that talk and the browser (OPEN_NETWORK.md), forward secrecy (FORWARD_SECRECY.md), running a relay (SELF_HOSTING.md), the desktop link, friends, groups, the Marketplace.
examples/pluginsExample plugins in the ghost-plugin/1 format.
test/, integration_test/The app's tests, and the pictures its screen tests are held to (test/shots).

One app, several ways of running

Every screen asks for what it needs through one object, Sms.instance (lib/sms.dart): the conversations, a thread's messages, sending, the settings. Sms passes each call by name to whatever is set as Sms.calls, and which object that is decides how the app runs. The screens are the same in every case.

Answered byWhereUsed when
The platform channel ghost_messaging/smslib/sms.dart, android/…/MainActivity.ktAn Android phone. Kotlin reads and writes Android's own SMS and MMS database.
OverlayCallslib/standalone/overlay.dartAndroid, wrapped round the channel: conversations with @username friends are answered in Dart, the rest passed on.
StandaloneCallslib/standalone/standalone.dartAn iPhone, a computer with no phone linked, or a browser: the app's own network and nothing from a phone. What it keeps is behind StandaloneStore (lib/standalone/store.dart): a folder and the Keychain (StandaloneFiles), or in a browser sealed records in IndexedDB (WebStandaloneStore, lib/web/store.dart).
LinkCallslib/desktop/remote.dartA computer paired with an Android phone: each call becomes a sealed request to the phone.
DeskOwnCallslib/desktop/own_calls.dartA paired computer the phone has handed its identity to: friends and circles run on the computer itself, texts still come from the phone.

lib/main.dart chooses: a computer goes to desktopMain() (lib/desktop/main.dart), an iPhone starts on its own, and Android starts on the channel. A browser's build has its own entry, lib/web/main.dart, which goes to lib/web/app.dart. From there both paths load the person's choices (AppState, lib/app_state.dart), the plugins, the API, and then the network through startPeople (lib/people.dart), which starts the routes, friends, what checks the relay, groups, spaces and circles in that order.

Texts on Android

The app keeps no copy of your texts: they live in Android's SMS and MMS database, which is why changing texting apps loses nothing. The Kotlin side is in android/app/src/main/kotlin/com/infamousvague/ghostmessaging.

FileWhat it does
MainActivity.ktAnswers the channel's calls and sends events back (ghost_messaging/events): a conversation changed, something to open.
Store.ktReads and writes Android's database: the list, threads, messages, contacts.
Messaging.ktSending (Sender) and the receivers for texts arriving, MMS arriving, and sent and delivered reports.
Pdu.ktThe MMS wire format, written and read by hand.
Notifier.kt, NotifyHush.kt, MarkdownPlain.ktNotifications, with Reply and Mark as read. None is shown for a text the list hides: the plugins' rules are written down for Kotlin by lib/plugins/notify_hush.dart, since the app may be closed when a text arrives. A preview's formatting markers are taken out.
Bubbles.kt, BubbleActivity.ktA conversation as a bubble at the side of the screen, in a Flutter engine of its own started at bubbleMain (lib/main.dart, lib/bubble.dart).
IncomingCall.ktA friend's call as a phone shows one: Answer and Decline, full screen while the phone is locked.
E2e.kt, E2eCrypto.ktEncrypted texts with one person, and the phone's key pair, held under the Android Keystore.
GmBridge.kt, GmWeb.ktRunning beside Google Messages: reading its notifications, or its web connection through sidecar/gmessages.
Desk.kt, DeskSession.kt, DeskCrypto.kt, DeskService.ktThe phone's half of the link to paired computers.

Routes: how apps reach each other

Everything between two Uplink apps (a friend's message, a call's setup, a space's chat) goes through lib/net. Its idea is the route: one way of getting bytes to another install, behind an interface (Carrier, lib/net/carrier.dart) so a new one can be added without the app above knowing.

PartWhereWhat it does
Envelope and packetlib/net/packet.dartAn envelope is a small JSON message with a kind (text, call, room, hello…). A packet is an envelope as a route carries it: a byte of version and flags, the sender's 16-byte name, then the envelope, sealed. The flags say whether it is sealed, a part, sealed for forward secrecy, or passed on unopened by another device of the account. Long ones cross a short route in parts.
The switchboardlib/net/switchboard.dartChooses a route for each thing sent, falls back to the next, seals and opens, joins parts, drops second copies, and answers what asks for an answer.
The hub routelib/net/hub_carrier.dart, hub_link.dartA connection to the relay server's hub. Also where presence and rooms come from. Its protocol. What carries the connection is behind HubLink: dart:io's WebSocket on a phone or a computer (hub_link_io.dart), the browser's own in a page (hub_link_web.dart).
The direct routelib/net/p2p, native/p2pPackets straight between devices, with no server between. Below.
The SMS routelib/net/sms_carrier.dart, android/…/NetSms.ktPackets as data texts: 133 bytes each, six at most, costing a text each, and able to wake a closed app.
Keys and sealinglib/net/crypto.dart, fast_gcm.dart, android/…/Net.ktP-256 key agreement, HKDF-SHA256 and AES-256-GCM. Kotlin and Dart are held to the same bytes by tests on both sides. fast_gcm.dart has two halves that give the same bytes: one for 64-bit integers, one for a browser's.
Forward secrecylib/net/forward_secrecy.dartPrekeys each device makes and deletes, and the sealing under a one-off key for each packet. Below.
Where people livelib/net/home_record.dart, homes.dart, relay_ask.dart, relay_choice.dartThe signed record of which relay an account uses, looking a username up on another relay, and moving to a relay of one's own. Below.
Checking the relaylib/net/ledger.dart, name_watch.dartWhat the relay says, compared with what friends' devices say. Below.
The app's hold on it alllib/net/net.dartNet: starts the routes, knows who can be reached, and is what the rest of the app sends through.

The routes are tried in the person's order (Settings › Routes, drawn by lib/ui/network.dart); where they have chosen none it is the hub, the direct route, the local network, then SMS (Switchboard.order). One is passed over when it is off, down, can't reach that person, can't hold the packet, or costs money and the message isn't one allowed to. Three routes are written: the hub, the direct route and SMS. The order names a local-network route (lan) that has no carrier yet.

Forward secrecy

A packet to a friend used to be sealed with the pair's key alone, which comes from the two accounts' long-term keys. Whoever later learned an account's words and had kept the packets could open them all. ForwardSecrecy (lib/net/forward_secrecy.dart) closes that:

A circle's key is changed when someone is put out of it (lib/circles/circle_keys.dart). docs/FORWARD_SECRECY.md in the repository is the whole design.

The direct route

The direct route (P2pCarrier, id p2p, shown as Direct) carries the same sealed packets between devices themselves. The relay still comes first: it is the fast path and the one that keeps things for someone who is away. Direct is a way through when the relay can't carry something, and what the relay is checked over.

PartWhereWhat it does
The corenative/p2p (Rust, on iroh)A node: a key made on the device, whose public half is its node id. It dials, gets through NATs, falls back to a link helper (iroh's relay server, which is not Uplink's relay), and turns away any node the app has not allowed. It publishes nothing and looks nobody up.
The contractlib/net/p2p/node.dartP2pNode: what the Dart above relies on. The real one is IrohNode over dart:ffi (node_ffi.dart, node_ffi_io.dart), made by makeP2pNode() (node_factory.dart); tests use a stand-in mesh (test/support/fake_p2p.dart); a browser has none. On Android P2pCore.kt loads the library when the first node starts, and not before.
Device cardslib/net/p2p/card.dartDeviceCard: an account's signed word that a node id is one of its devices. Anyone can check one with nothing but the card.
Who links, and whenlib/net/p2p/p2p.dartP2p: links only with the account's own devices and with friends. Cards and whereabouts are told in sealed envelopes of kind p2p (card, card?, meet). P2pPolicy says when a node runs: a computer's stays up, a phone's is started for something to say and stopped two minutes after its last stream closes.
The carryinglib/net/p2p/p2p_carrier.dartSends a packet to every device a card is held for, on a stream that is open or dialled by where the device last said it was. Each end of a stream proves whose device it is before anything is taken. It never keeps anything.

Link helpers are named by the relay as an app signs in to its hub (HubCarrier.helpers, from the relay's GHOST_LINK_HELPERS). With none, devices link only where they can reach each other's addresses as they are.

Checking the relay

The relay is trusted with little, and two parts check what is left.

Settings › Routes shows what both found (relayCheckSection, lib/ui/network.dart).

Friends on another relay

An app talks to one relay. Anyone can run their own, and relays can pass sealed packets to each other, so two friends need not share one.

Every packet still goes through the app's own relay. The passing on is the relay's work. Usernames, account backups, circles, spaces and calls stay on the relay they were made on.

Who someone is

Circles, spaces and calls

A space (in the code, a hangout or voice channel) is 32 random bytes, its seed. The room's name on the hub, the token that lets someone in and the key everything in it is sealed with are all made from the seed (VoiceChannel, lib/voice/voice.dart), so whoever holds a space's link holds all three and the relay holds none.

Other networks

lib/inbox puts other services' chats in the same list. Each is an InboxNetwork (lib/inbox/inbox.dart) with its own way of connecting:

NetworkHow
TelegramTDLib, loaded into the app through dart:ffi (lib/inbox/td_json.dart, td_json_io.dart).
Signal, WhatsApp, MatrixA helper program each (sidecar/), started by the app and spoken to in lines of JSON over its input and output. Each helper's PROTOCOL.md says what is said. Their chats are written to disk off the drawing thread by KeptWriter (lib/inbox/kept_writer.dart).
Messenger, Instagram, Discord, X, SlackAn account helper each (sidecar/messenger, instagram, discord, twitter, slack), all speaking one protocol (sidecar/ACCOUNT_HELPERS.md), so one class drives them all: AccountHelper (lib/inbox/account_helper.dart), told apart by a HelperService. None of these services allows other apps. A helper signs in as the person, with the cookies of a browser signed in to their account, and the app says so first.
Google Chat, Microsoft TeamsTheir own web APIs, straight from the app.
Bluesky, MastodonWritten (bluesky.dart, mastodon.dart), listed as coming soon and never started.

The cookies an account helper signs in with come one of two ways. Pasted: a request copied from the browser's developer tools, read by lib/inbox/cookie_paste.dart. Or synced: the browser extension (extension/) reads them, seals them with a key only the account's devices have, and keeps them on the relay; each device reads them back and signs in (CurlSync, lib/inbox/curl_sync.dart).

lib/inbox/human_check.dart holds a first message from someone new on a chosen network until its sender answers a small question. Several networks are also cards in the Marketplace, sharing one switch with Settings (lib/plugins/networks.dart).

No chat from these networks goes through Uplink's relay. The sealed cookies are the one thing of theirs it keeps, and it can't read them. A browser has no helper programs, so the web client has none of these networks.

A computer paired with a phone shows the phone's texts by asking the phone for them. The computer's half is lib/desktop/link (PhoneLink, LinkSession); the phone's is DeskSession.kt. They connect over the local network where they can and through the relay's pairing channel where they can't, and either way every frame is sealed with keys made from the pairing, so the relay passes bytes it can't read. What the computer has read is kept sealed on its disk (lib/desktop/cache.dart).

Plugins and the Marketplace

A plugin adds to the conversations list and to texts through a few fixed points (lib/plugins/plugin.dart): tagging a message, a section or tab in the list, a button, a rule for what arrives. The built-in ones are Dart classes (lib/plugins/registry.dart). One from another developer is data, never code: a JSON file (lib/plugins/pack) the app reads into those same points, held to what it declared by GatedHost.

Which plugins are on is synced between an account's devices (PluginSync, lib/plugins/plugin_sync.dart): a list in the same sealed slot on the relay as the extension's cookies. A circle can hold some plugins for all its members: the soundboard and the auto leveler are on in a circle's spaces when the circle has them on.

The Marketplace (lib/market, and relay/lib/market.dart on the server) lists reviewed plugins. An approval is a reviewer's signature over the plugin's id, version and its file's SHA-256, checked against keys the app ships with, at install and at every start: the server can withhold a plugin but can't make one look reviewed.

The relay server

relay/bin/relay.dart reads its options and environment, makes each part over one data folder, and starts one HTTP server; relay/lib/relay.dart sends each request to its part.

PartFileWhat it does
Pairing channelsrelay.dartPasses sealed frames between a phone and its computer while both are connected. Keeps no frame.
The hubhub.dartWhere installs find each other: signing in with a key, packets passed or held for whoever is away, presence, rooms. A sign-in can be bound to the host the app dialled (v2, where the relay is told its names with GHOST_HUB_NAMES), so it is no use at another relay. A connection is a HubSocket, which need not be a WebSocket.
The doorsws_door.dartEvery WebSocket's upgrade and dial, with a ceiling on a message's length checked from the frames' headers, before a byte of it is held. WireBudget bounds what all connections hold together.
Other relaysfederation.dart, fed_dial.dart, home_record.dartLinks to other relays, off unless GHOST_FED is open or list. Each relay has a key and proves it; a packet for someone whose home record names another relay is passed there, and what another relay passes on is taken only for people whose record names that relay. fed_dial.dart holds every address dialled to public hosts, checked before the dial and dialled as checked.
The directoryhandles.dart, accounts.dart, texts.dart, invites.dart, invite_words.dartUsernames, linked handles, number verification by a texting service, sealed account backups and each account's list of devices, the extension's sealed cookies, invitations and circles' invite words. Reached through the hub's connection.
Filesfiles.dart, files_roster.dartFiles spaces' sealed pieces and their log.
Marketplacemarket.dart, market_pack.dart, market_store.dartPlugins' submissions, review and listing, and reports of a person or a message (POST /market/abuse; the app's half is lib/safety/abuse_report.dart).
Calls' fallbackturn.dartMakes the short-lived TURN username and password the hub hands out with a room, from a secret shared with a TURN server (coturn) its keeper runs. Without the secret, calls are direct only.
The app in a browserweb_app.dartServes the folder tool/build-web.mjs built as plain files under /app/, with the page's security headers, where the relay is started with --web. Below.
Pushes, feedback, bountiespushes.dart, feedback.dart, bounty.dartA "New message" push to an iPhone something is held for; feedback sent from the app; souls granted for a tester's fixed bug by a signed POST /bounty. Souls one person sends another by a signed POST /souls/send are souls_send.dart; the counts and receipts are in handles.dart. None does anything without its variables.
Keepingkept_log.dartA keyed store on disk as a log of changes, appended as they happen and written whole again now and then in an isolate.
Arithmeticp256.dart, secp256k1.dart, sha256.dart, sha1.dart, keccak.dartSignature checking and hashes, written out so the relay depends on nothing.

What it can see is the same throughout: which installs talk, when, and how much. Linked to other relays, it also sees which of its people talk to people on which relay. Its HTTP routes and its WebSocket protocols are documented in full, and docs/SELF_HOSTING.md in the repository says how to run one and what a relay of your own reaches.

The app in a browser

The web client is the same Dart, built by dart2js from its own entry (lib/web/main.dart), running as one more device of an account. It is the standalone way of running: lib/web/app.dart sets StandaloneCalls over the browser's store and calls startPeople, as a computer with no phone linked does.

PartWhereWhat it does
The startlib/web/app.dartOpens the store, works out the hub's address (the one the build names, or /hub beside a page served at /app/), and starts only what a page can run.
The storelib/web/store.dartWebStandaloneStore: every record in IndexedDB sealed with AES-256-GCM under a key the browser made as not extractable. The recovery words and the password's key are not kept at all.
The browserlib/web/browser.dart, browser_web.dartWhat the app asks of the browser: somewhere to keep things, being the only tab of itself, opening a link, starting again. browser_web.dart is the one file that speaks to JavaScript.
HTTP, emoji, Aboutlib/web/http.dart, emoji.dart, settings.dartThe page's own fetch for a report and feedback; an emoji font fetched when first wanted; Settings › About, which says what the browser keeps and what isn't there.
The pageweb/, tool/web/headers.jsonindex.html with its content policy, the loader (flutter_bootstrap.js: no service worker, fallback fonts from beside the page), the Argon2id worker, and the headers every server of it must send.

Code that can't compile or run in a browser is split, and the whole of lib/ goes through the split:

Guard tests read the source to hold it to this (test/platform_info_test.dart, test/aside_test.dart, test/source_guards_test.dart), and the Android and Mac releases run them before they build.

Not in a browser, as its own About says (notInBrowserYet, lib/web/settings.dart): calls, voice messages and sounds, Files spaces, plugins and the Marketplace, chats on other networks, and texts through a phone. It has no direct route either, so it keeps no ledger.

Screens

The app's own API

lib/api is a registry of methods (conversations.list, messages.send…), each with its parameters, what it answers and an example. The same methods are called from Settings' own test area, over HTTP on the device, and from anywhere through the relay, sealed. See API overview and Postman.

Something wrong or missing here? Tell us in the Alpha testers circle, or at the app's GitHub.