plexus / messenger
ENGINEERING CASE STUDY · MESSENGER + AI ASSISTANT

How Plexus Messenger works

Plexus is a production messenger for web and Android: direct and group chats, calls, files, live location and an integrated AI assistant. This compact version keeps only the important parts: the service architecture, the path of one message and the end-to-end encryption boundary.

Java 21 · Spring Boot 4 PostgreSQL 18 · Flyway Kafka event bus Vue 3 + TypeScript WebCrypto · AES-256-GCM Android · Kotlin Compose WebRTC Docker · Caddy
sender device→ seal→ plexus-core→ recipient device→ decrypt

This is an engineering walkthrough of the production implementation as of November 2026 — not a user guide, a security audit or an availability guarantee. Details may change.

SCROLL ↓
01 — Overview

What the messenger does

The product is already a full messenger rather than a chat demo. The short version:

chats

web + Android
  • direct and group chats with delivery/read state
  • replies, pins, reactions, drafts and scheduled messages
  • files, voice messages and expiring live location

protection

explicit trust boundary
  • optional end-to-end encrypted direct chats
  • encrypted attachments and location envelopes
  • verified devices, QR linking and fingerprint warnings

calls

WebRTC
  • 1:1 and group calls in client mesh topology up to 6 participants
  • DTLS-SRTP by default; TURN only as a permission-gated fallback
  • optional frame transform for supported web 1:1 calls

assistant

separate AI service
  • assistant chats, e-mail replies and @mentions in groups
  • transcription, translation, model routing and budgets through plexus-ai
  • mail and push are separate token-scoped satellite services
02 — System architecture

The messenger inside the production topology

Two zoom levels matter here: the messenger boundary itself, then the whole production platform it shares with reader, map and VPN. Identity is centralised in plexus-auth; AI, mail and push are separate services; Kafka carries user events between nodes.

Messenger core and satellites

The focused diagram shows the messenger boundary: clients use the session API, while mail, AI and push reach only their token-scoped internal routes or Kafka.

Whole production platform

Production service topology of the Plexus platform

Read the diagram by lanes: clients and edge on the left, the Docker Compose host in the centre and external providers on the right. Solid lines are runtime traffic; low-contrast dotted lines are operations and control-plane paths. Click the diagram to open it full size.

03 — Follow one message

"See you at eight" — eleven processing steps

A sealed chat, an offline recipient, one short sentence. This is the actual path it takes through the system.

Device · compose

The sender hits send

The UI builds the payload — text, quote, attachment descriptors — as UTF-8 JSON. The message content has not left the device yet.

Device · seal

A fresh key per message

WebCrypto mints a 256-bit content key K and AES-256-GCM-encrypts the payload under a random IV.

Device · wrap

One wrap per recipient device

For each of their devices: wrapKey = SHA-256(ECDH(myPriv, theirPub) ‖ "plexus-e2e-wrap" ‖ ids), then AES-GCM-seal K under it. Phone and tablet each get their own copy.

Device → Core

POST /api/chats/{id}/messages

The envelope — {v, s, c, w{…}} — goes up over the session. Attachments travel as separately keyed blobs (plexus-e2e-file-v1 AAD).

Core · store

Ciphertext meets ciphertext

The row lands in assistant_messages under the at-rest enc1 key — a second envelope around an envelope the server already cannot open.

Core · fan-out

The event hits Kafka

A message-posted user event lands on plexus-user-events; both core nodes consume it, so the recipient's node can answer regardless of which one took the POST.

Core → Device

SSE delivers in real time

Any connected device gets the envelope on its /api/events stream — delivery and later read receipts are distributed as their own events to the participating devices.

Push satellite

The offline phone wakes

plexus-push sees the event on the topic, asks /internal/push/targets who to wake — dormant accounts skipped, dead tokens reported back — and FCM delivers a silent data push.

Their device · unwrap

ECDH produces the wrap key

Their device recomputes ECDH(theirPriv, yourPub), unwraps K from its personal w[device] entry. The wrap key is not stored; it is recomputed on the recipient device.

Their device · read

"See you at eight"

AES-256-GCM verifies and decrypts; the bubble renders — and your ticks flip to delivered, then read.

Everywhere else

What travelled on the wire

The Caddy edge, the database, Kafka and the push satellite all handle metadata and ciphertext. None of them needs the message plaintext.

04 — End-to-end encryption

End-to-end encryption, in plain language

Imagine the sender locks the letter in a small safe before it leaves the phone. Plexus servers move that safe, know who sent it and when, but do not hold the key. Only verified recipient devices carry their own wrapped copy of the key.

// This applies to protected direct chats. Assistant chats and groups with bots are intentionally server-readable so the assistant can answer; the server still sees delivery metadata such as participants, time and size.
Show the algorithm and envelope formatHide the algorithm and envelope format

The e2e1 spec is implemented in WebCrypto and Kotlin against the same binary format, so a phone can unwrap what a browser sealed. The mechanism protects content from a passive server. Because the server operates the key directory, fingerprint verification is the user's defence against key substitution.

{
  "v": 1,    // spec version
  "s": "dev-a7",  // sender device id
  "c": "iv‖AES-256-GCM(K, payload)",  // the ciphertext
  "w": {                    // K, wrapped per device
    "dev-b2": "iv‖GCM(wrapKey_b2, K)",
    "dev-b9": "iv‖GCM(wrapKey_b9, K)"
  }
}
stored verbatim in assistant_messages — inside its own enc1 at-rest wrap
what actually left your device See you at eight — bring the good umbrella.
setup

Each device brings its own key

An ECDH P-256 pair is generated locally; the public half registers at /api/crypto/keys. The private half never leaves the device unencrypted; encrypted link or backup bundles may carry it.

link

New devices are adopted, not trusted

Scan a QR code on an already-trusted device — it seals identity material for the new device through a short-lived link session. Key-set changes remain visible through fingerprint warnings; a changed device key set also triggers a notification to the registered e-mail address.

verify

Fingerprints, remembered

Each client remembers the peer key-set fingerprint it first trusted; a changed set raises a verify dialog instead of silently re-sealing. The encrypted key backup rides a separate backup blob.

scope

Messages, attachments and coordinates in an E2E direct chat

Attachments get their own content key and integrity hash; shared coordinates travel inside the same envelope — the server can still process metadata such as participants, time, size and delivery state; the message content remains hidden inside the E2E envelope.