# qaravparlaq-afk/nexa-messenger architecture

> Architecture diagram of the GitHub repository qaravparlaq-afk/nexa-messenger, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/qaravparlaq-afk/nexa-messenger
- Repository: https://github.com/qaravparlaq-afk/nexa-messenger

## Overview

NEXA is an early-stage, privacy-first Android and iOS messenger. Its intended user workflow is device identity and prekey setup, authenticated session establishment, encrypted message creation and delivery, then local encrypted persistence and receipt; the sampled backend supports authenticated prekey and relay operations. The graph separates mobile clients, cryptographic protocol stages, and gateway services. Attachments, push, calling, verification/revocation, and wallet capabilities are documented goals, not demonstrated end-to-end implementations in the sampled source. Some subsystem wiring is therefore left unspecified.

Main entry points: [`backend/src/main.rs`](https://github.com/qaravparlaq-afk/nexa-messenger/blob/main/backend/src/main.rs) (Backend gateway), [`core/session/src/lib.rs`](https://github.com/qaravparlaq-afk/nexa-messenger/blob/main/core/session/src/lib.rs) (Session setup), [`core/identity/src/lib.rs`](https://github.com/qaravparlaq-afk/nexa-messenger/blob/main/core/identity/src/lib.rs) (Device identity), [`apps/android/app/src/main/java/org/nexa/messenger/MainActivity.kt`](https://github.com/qaravparlaq-afk/nexa-messenger/blob/main/apps/android/app/src/main/java/org/nexa/messenger/MainActivity.kt) (Android app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["Mobile clients"]
  node_android["Android app<br/>[MainActivity.kt]"]
  node_ios["iOS app"]
end

subgraph group_protocol["Secure messaging core"]
  node_identity["Device identity<br/>[lib.rs]"]
  node_prekey_primitives["Prekey primitives<br/>[prekeys.rs]"]
  node_session["Session setup<br/>[lib.rs]"]
  node_protocol_types["Protocol types<br/>[lib.rs]"]
  node_ratchet["Message ratchet<br/>[lib.rs]"]
  node_envelope["Wire envelope<br/>[lib.rs]"]
  node_local_storage[("Encrypted storage<br/>[lib.rs]")]
  node_transport["Transport frames<br/>[lib.rs]"]
end

subgraph group_gateway["Relay services"]
  node_gateway["Backend gateway<br/>[main.rs]"]
  node_auth["Request authentication<br/>[auth.rs]"]
  node_prekey_service[("Prekey directory<br/>[prekeys.rs]")]
  node_relay_service[("Message relay<br/>[relay.rs]")]
end

subgraph group_capabilities["Planned capabilities"]
  node_attachments["Encrypted attachments"]
  node_push["Private push"]
  node_calling["Voice and video"]
  node_wallet["Non-custodial wallet<br/>[lib.rs]"]
  node_verification["Verification and revocation<br/>[lib.rs]"]
end

node_person(("Messenger user"))

node_person -->|"uses"| node_android
node_person -->|"uses"| node_ios
node_identity -->|"creates keys"| node_prekey_primitives
node_session -->|"uses identity"| node_identity
node_session -->|"validates bundles"| node_protocol_types
node_ratchet -->|"uses root"| node_session
node_envelope -->|"encodes messages"| node_protocol_types
node_local_storage -->|"stores snapshots"| node_ratchet
node_gateway -->|"authenticates requests"| node_auth
node_gateway -->|"serves prekeys"| node_prekey_service
node_gateway -->|"relays messages"| node_relay_service
node_gateway -->|"frames websocket data"| node_transport
node_attachments -.->|"planned encrypted payloads"| node_envelope
node_push -.->|"planned notifications"| node_gateway
node_calling -.->|"planned client feature"| node_android
node_calling -.->|"planned client feature"| node_ios
node_wallet -.->|"planned client feature"| node_android
node_wallet -.->|"planned client feature"| node_ios
node_verification -.->|"planned lifecycle feature"| node_identity

click node_android "https://github.com/qaravparlaq-afk/nexa-messenger/blob/main/apps/android/app/src/main/java/org/nexa/messenger/MainActivity.kt"
click node_ios "https://github.com/qaravparlaq-afk/nexa-messenger/tree/main/apps/ios"
click node_identity "https://github.com/qaravparlaq-afk/nexa-messenger/blob/main/core/identity/src/lib.rs"
click node_prekey_primitives "https://github.com/qaravparlaq-afk/nexa-messenger/blob/main/core/identity/src/prekeys.rs"
click node_session "https://github.com/qaravparlaq-afk/nexa-messenger/blob/main/core/session/src/lib.rs"
click node_protocol_types "https://github.com/qaravparlaq-afk/nexa-messenger/blob/main/core/protocol/src/lib.rs"
click node_ratchet "https://github.com/qaravparlaq-afk/nexa-messenger/blob/main/core/ratchet/src/lib.rs"
click node_envelope "https://github.com/qaravparlaq-afk/nexa-messenger/blob/main/core/envelope/src/lib.rs"
click node_local_storage "https://github.com/qaravparlaq-afk/nexa-messenger/blob/main/core/storage/src/lib.rs"
click node_transport "https://github.com/qaravparlaq-afk/nexa-messenger/blob/main/core/transport/src/lib.rs"
click node_gateway "https://github.com/qaravparlaq-afk/nexa-messenger/blob/main/backend/src/main.rs"
click node_auth "https://github.com/qaravparlaq-afk/nexa-messenger/blob/main/backend/src/auth.rs"
click node_prekey_service "https://github.com/qaravparlaq-afk/nexa-messenger/blob/main/backend/src/prekeys.rs"
click node_relay_service "https://github.com/qaravparlaq-afk/nexa-messenger/blob/main/backend/src/relay.rs"
click node_attachments "https://github.com/qaravparlaq-afk/nexa-messenger/tree/main/core"
click node_push "https://github.com/qaravparlaq-afk/nexa-messenger/tree/main/core"
click node_calling "https://github.com/qaravparlaq-afk/nexa-messenger/tree/main/core"
click node_wallet "https://github.com/qaravparlaq-afk/nexa-messenger/blob/main/core/wallet/src/lib.rs"
click node_verification "https://github.com/qaravparlaq-afk/nexa-messenger/blob/main/core/identity/src/lib.rs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_android,node_ios,node_person toneBlue
class node_identity,node_prekey_primitives,node_session,node_protocol_types,node_ratchet,node_envelope,node_local_storage,node_transport toneAmber
class node_gateway,node_auth,node_prekey_service,node_relay_service toneMint
class node_attachments,node_push,node_calling,node_wallet,node_verification toneRose
```

## Components

### Mobile clients

- [Android app](https://github.com/qaravparlaq-afk/nexa-messenger/blob/main/apps/android/app/src/main/java/org/nexa/messenger/MainActivity.kt): `apps/android/app/src/main/java/org/nexa/messenger/MainActivity.kt`
- [iOS app](https://github.com/qaravparlaq-afk/nexa-messenger/tree/main/apps/ios): `apps/ios`

### Secure messaging core

- [Device identity](https://github.com/qaravparlaq-afk/nexa-messenger/blob/main/core/identity/src/lib.rs): `core/identity/src/lib.rs`
- [Prekey primitives](https://github.com/qaravparlaq-afk/nexa-messenger/blob/main/core/identity/src/prekeys.rs): `core/identity/src/prekeys.rs`
- [Session setup](https://github.com/qaravparlaq-afk/nexa-messenger/blob/main/core/session/src/lib.rs): `core/session/src/lib.rs`
- [Protocol types](https://github.com/qaravparlaq-afk/nexa-messenger/blob/main/core/protocol/src/lib.rs): `core/protocol/src/lib.rs`
- [Message ratchet](https://github.com/qaravparlaq-afk/nexa-messenger/blob/main/core/ratchet/src/lib.rs): `core/ratchet/src/lib.rs`
- [Wire envelope](https://github.com/qaravparlaq-afk/nexa-messenger/blob/main/core/envelope/src/lib.rs): `core/envelope/src/lib.rs`
- [Encrypted storage](https://github.com/qaravparlaq-afk/nexa-messenger/blob/main/core/storage/src/lib.rs): `core/storage/src/lib.rs`
- [Transport frames](https://github.com/qaravparlaq-afk/nexa-messenger/blob/main/core/transport/src/lib.rs): `core/transport/src/lib.rs`

### Relay services

- [Backend gateway](https://github.com/qaravparlaq-afk/nexa-messenger/blob/main/backend/src/main.rs): `backend/src/main.rs`
- [Request authentication](https://github.com/qaravparlaq-afk/nexa-messenger/blob/main/backend/src/auth.rs): `backend/src/auth.rs`
- [Prekey directory](https://github.com/qaravparlaq-afk/nexa-messenger/blob/main/backend/src/prekeys.rs): `backend/src/prekeys.rs`
- [Message relay](https://github.com/qaravparlaq-afk/nexa-messenger/blob/main/backend/src/relay.rs): `backend/src/relay.rs`

### Planned capabilities

- [Encrypted attachments](https://github.com/qaravparlaq-afk/nexa-messenger/tree/main/core): `core`
- [Private push](https://github.com/qaravparlaq-afk/nexa-messenger/tree/main/core): `core`
- [Voice and video](https://github.com/qaravparlaq-afk/nexa-messenger/tree/main/core): `core`
- [Non-custodial wallet](https://github.com/qaravparlaq-afk/nexa-messenger/blob/main/core/wallet/src/lib.rs): `core/wallet/src/lib.rs`
- [Verification and revocation](https://github.com/qaravparlaq-afk/nexa-messenger/blob/main/core/identity/src/lib.rs): `core/identity/src/lib.rs`

### Other components

- **Messenger user**

## Connections

- Messenger user → Android app: uses
- Messenger user → iOS app: uses
- Device identity → Prekey primitives: creates keys
- Session setup → Device identity: uses identity
- Session setup → Protocol types: validates bundles
- Message ratchet → Session setup: uses root
- Wire envelope → Protocol types: encodes messages
- Encrypted storage → Message ratchet: stores snapshots
- Backend gateway → Request authentication: authenticates requests
- Backend gateway → Prekey directory: serves prekeys
- Backend gateway → Message relay: relays messages
- Backend gateway → Transport frames: frames websocket data
- Encrypted attachments → Wire envelope: planned encrypted payloads
- Private push → Backend gateway: planned notifications
- Voice and video → Android app: planned client feature
- Voice and video → iOS app: planned client feature
- Non-custodial wallet → Android app: planned client feature
- Non-custodial wallet → iOS app: planned client feature
- Verification and revocation → Device identity: planned lifecycle feature
