Architecture

Transport is public. Content never is.

MNDO separates who carries a message from who can read it. Relays forward signed envelopes; only the two Signal ratchets hold the keys to decrypt them.

Core dependencies

Five packages carry the core architecture. Everything else is UI and platform glue.

Flutter (Dart)
flutter
Single codebase powering the mobile and desktop clients.
Nostr Protocol
dart_nostr
Signed events published to and read from independent relays over WebSocket.
Signal Protocol
libsignal_protocol_dart
X3DH key agreement and Double Ratchet for per-message forward secrecy.
Drift + SQLCipher
sqlcipher_flutter_libs
Typed local SQLite database with AES-256 encryption at rest.
Provider
provider
Root MultiProvider dependency graph. UI never constructs services directly.

Four-layer dependency rule

Dependencies point downward only. UI talks to State, State calls Services, and Services persist to Data.

  1. 01UI
    lib/ui/

    Screens, widgets, and theme. Renders state only; never touches crypto or network transport.

  2. 02State
    lib/providers/

    ChangeNotifier providers (AuthProvider, ChatProvider, DiscoverProvider). The only layer UI reads from.

  3. 03Services
    lib/services/

    NostrRelayService, SignalMessagingService, CryptoService, and SignalStore. Handles transport and cryptography.

  4. 04Data
    lib/database/

    Drift over SQLCipher for encrypted messages and ratchet state, plus flutter_secure_storage for root keys.

X3DH and the Double Ratchet

PreKeys (X3DH) let you start an encrypted conversation with someone who is offline. Each device publishes a signed bundle of one-time public keys as a Nostr event. A sender fetches a bundle, derives a shared secret, and encrypts the first message without waiting for a handshake round-trip.

The Double Ratchet derives a fresh symmetric key for every single message. One ratchet advances per message sent; the Diffie-Hellman ratchet steps whenever a reply arrives with new key material. Exposing one message key reveals one message—never past messages and never future ones.

In the Flutter codebase, session logic lives in SignalMessagingService and ratchet state persists through SignalStore into the SQLCipher database.

Nostr relay mesh vs. a central server

Relays act as interchangeable WebSocket mailboxes. You can swap or add relays without changing your cryptographic identity.

Centralized server

  • Holds your contact graph and metadata, typically tied to a phone number.
  • Can be compelled to log, throttle, or suspend accounts.
  • Creates a single point of failure for everyone on the service.

Nostr relay mesh

  • Your identity is your keypair; switching relays does not break your handle.
  • Relays see signed ciphertext envelopes and public keys, never plaintext.
  • Publish across multiple relays and read from whichever responds first.