# krish-legend13/sentra architecture

> Architecture diagram of the GitHub repository krish-legend13/sentra, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/krish-legend13/sentra
- Repository: https://github.com/krish-legend13/sentra

## Overview

SENTRA is a secure messaging system with Ed25519 identity, challenge-response authentication, optional TOTP, mTLS transport, signed envelopes, and client-side end-to-end encryption. The principal workflow is a user starting a client, authenticating to the server, then exchanging encrypted messages that the server routes without seeing plaintext. The graph also preserves identity vaults, registration, offline delivery, sessions, and security monitoring. Edges reflect the sampled excerpts, SOURCE INDEX references, or explicit source documentation; unsampled subsystems are included where the tree and index establish them, without guessing their internal calls.

Main entry points: [`network/server.py`](https://github.com/krish-legend13/sentra/blob/main/network/server.py) (Messaging server), [`network/client.py`](https://github.com/krish-legend13/sentra/blob/main/network/client.py) (Messaging client), [`identity/manager.py`](https://github.com/krish-legend13/sentra/blob/main/identity/manager.py) (Identity manager), [`main.py`](https://github.com/krish-legend13/sentra/blob/main/main.py) (Application flow)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Application entry"]
  node_main_app["Application flow<br/>[main.py]"]
end

subgraph group_transport["Messaging transport"]
  node_client["Messaging client<br/>[client.py]"]
  node_server["Messaging server<br/>[server.py]"]
  node_framing["Packet framing<br/>[framing.py]"]
  node_tls["TLS configuration<br/>[tls_config.py]"]
  node_offline_queue["Offline queue<br/>[offline_queue.py]"]
  node_sessions["Session tracking<br/>[sessions.py]"]
end

subgraph group_identity_auth["Identity and authentication"]
  node_identity_manager["Identity manager<br/>[manager.py]"]
  node_registry[("Identity registry<br/>[registry.py]")]
  node_challenge["Challenge authentication<br/>[challenge.py]"]
  node_totp["TOTP verification<br/>[totp.py]"]
  node_recovery["Account recovery<br/>[recovery.py]"]
end

subgraph group_crypto_signing["Cryptography and signing"]
  node_vault["Key vault<br/>[vault.py]"]
  node_key_management["Key management<br/>[keys.py]"]
  node_signatures["Ed25519 signatures<br/>[signatures.py]"]
  node_encryption["Payload encryption<br/>[encryption.py]"]
  node_envelope["Signed envelopes<br/>[envelope.py]"]
end

subgraph group_security_ops["Security operations"]
  node_incidents["Incident detection"]
  node_security_events["Security event log<br/>[security_events.py]"]
end

node_user(("User"))

node_user -->|"starts"| node_main_app
node_main_app -->|"loads identity"| node_identity_manager
node_main_app -->|"starts client"| node_client
node_main_app -->|"starts server"| node_server
node_client -->|"exchanges packets"| node_server
node_client -->|"uses identity"| node_identity_manager
node_client -->|"frames packets"| node_framing
node_client -->|"configures TLS"| node_tls
node_client -->|"signs challenge"| node_challenge
node_client -->|"encrypts payload"| node_encryption
node_client -->|"creates envelope"| node_envelope
node_server -->|"reads packets"| node_framing
node_server -->|"configures TLS"| node_tls
node_server -->|"registers identities"| node_registry
node_server -->|"verifies challenge"| node_challenge
node_server -->|"verifies TOTP"| node_totp
node_server -->|"queues delivery"| node_offline_queue
node_server -->|"tracks sessions"| node_sessions
node_server -->|"checks activity"| node_incidents
node_server -->|"logs events"| node_security_events
node_identity_manager -->|"loads keys"| node_key_management
node_identity_manager -->|"protects private key"| node_vault
node_identity_manager -->|"decrypts payload"| node_encryption
node_identity_manager -->|"signs data"| node_signatures
node_registry -->|"uses key utilities"| node_key_management
node_challenge -->|"uses Ed25519"| node_signatures
node_encryption -->|"uses canonical bytes"| node_signatures
node_envelope -->|"signs fields"| node_signatures
node_incidents -->|"reports detections"| node_security_events

click node_main_app "https://github.com/krish-legend13/sentra/blob/main/main.py"
click node_identity_manager "https://github.com/krish-legend13/sentra/blob/main/identity/manager.py"
click node_client "https://github.com/krish-legend13/sentra/blob/main/network/client.py"
click node_server "https://github.com/krish-legend13/sentra/blob/main/network/server.py"
click node_framing "https://github.com/krish-legend13/sentra/blob/main/network/framing.py"
click node_tls "https://github.com/krish-legend13/sentra/blob/main/network/tls_config.py"
click node_offline_queue "https://github.com/krish-legend13/sentra/blob/main/network/offline_queue.py"
click node_sessions "https://github.com/krish-legend13/sentra/blob/main/network/sessions.py"
click node_registry "https://github.com/krish-legend13/sentra/blob/main/auth/registry.py"
click node_challenge "https://github.com/krish-legend13/sentra/blob/main/auth/challenge.py"
click node_totp "https://github.com/krish-legend13/sentra/blob/main/auth/totp.py"
click node_recovery "https://github.com/krish-legend13/sentra/blob/main/auth/recovery.py"
click node_vault "https://github.com/krish-legend13/sentra/blob/main/crypto/vault.py"
click node_key_management "https://github.com/krish-legend13/sentra/blob/main/crypto/keys.py"
click node_signatures "https://github.com/krish-legend13/sentra/blob/main/crypto/signatures.py"
click node_encryption "https://github.com/krish-legend13/sentra/blob/main/crypto/encryption.py"
click node_envelope "https://github.com/krish-legend13/sentra/blob/main/signing/envelope.py"
click node_incidents "https://github.com/krish-legend13/sentra/blob/main/network/incident_detection.py"
click node_security_events "https://github.com/krish-legend13/sentra/blob/main/network/security_events.py"

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_main_app,node_user toneBlue
class node_client,node_server,node_framing,node_tls,node_offline_queue,node_sessions toneAmber
class node_identity_manager,node_registry,node_challenge,node_totp,node_recovery toneMint
class node_vault,node_key_management,node_signatures,node_encryption,node_envelope toneRose
class node_incidents,node_security_events toneIndigo
```

## Components

### Application entry

- [Application flow](https://github.com/krish-legend13/sentra/blob/main/main.py): `main.py`

### Messaging transport

- [Messaging client](https://github.com/krish-legend13/sentra/blob/main/network/client.py): `network/client.py`
- [Messaging server](https://github.com/krish-legend13/sentra/blob/main/network/server.py): `network/server.py`
- [Packet framing](https://github.com/krish-legend13/sentra/blob/main/network/framing.py): `network/framing.py`
- [TLS configuration](https://github.com/krish-legend13/sentra/blob/main/network/tls_config.py): `network/tls_config.py`
- [Offline queue](https://github.com/krish-legend13/sentra/blob/main/network/offline_queue.py): `network/offline_queue.py`
- [Session tracking](https://github.com/krish-legend13/sentra/blob/main/network/sessions.py): `network/sessions.py`

### Identity and authentication

- [Identity manager](https://github.com/krish-legend13/sentra/blob/main/identity/manager.py): `identity/manager.py`
- [Identity registry](https://github.com/krish-legend13/sentra/blob/main/auth/registry.py): `auth/registry.py`
- [Challenge authentication](https://github.com/krish-legend13/sentra/blob/main/auth/challenge.py): `auth/challenge.py`
- [TOTP verification](https://github.com/krish-legend13/sentra/blob/main/auth/totp.py): `auth/totp.py`
- [Account recovery](https://github.com/krish-legend13/sentra/blob/main/auth/recovery.py): `auth/recovery.py`

### Cryptography and signing

- [Key vault](https://github.com/krish-legend13/sentra/blob/main/crypto/vault.py): `crypto/vault.py`
- [Key management](https://github.com/krish-legend13/sentra/blob/main/crypto/keys.py): `crypto/keys.py`
- [Ed25519 signatures](https://github.com/krish-legend13/sentra/blob/main/crypto/signatures.py): `crypto/signatures.py`
- [Payload encryption](https://github.com/krish-legend13/sentra/blob/main/crypto/encryption.py): `crypto/encryption.py`
- [Signed envelopes](https://github.com/krish-legend13/sentra/blob/main/signing/envelope.py): `signing/envelope.py`

### Security operations

- [Incident detection](https://github.com/krish-legend13/sentra/blob/main/network/incident_detection.py): `network/incident_detection.py`
- [Security event log](https://github.com/krish-legend13/sentra/blob/main/network/security_events.py): `network/security_events.py`

### Other components

- **User**

## Connections

- User → Application flow: starts (evidence: `main.py`)
- Application flow → Identity manager: loads identity (evidence: `main.py`)
- Application flow → Messaging client: starts client (evidence: `main.py`)
- Application flow → Messaging server: starts server (evidence: `main.py`)
- Messaging client → Messaging server: exchanges packets (evidence: `network/client.py`)
- Messaging client → Identity manager: uses identity (evidence: `network/client.py`)
- Messaging client → Packet framing: frames packets (evidence: `network/client.py`)
- Messaging client → TLS configuration: configures TLS (evidence: `network/client.py`)
- Messaging client → Challenge authentication: signs challenge (evidence: `network/client.py`)
- Messaging client → Payload encryption: encrypts payload (evidence: `network/client.py`)
- Messaging client → Signed envelopes: creates envelope (evidence: `network/client.py`)
- Messaging server → Packet framing: reads packets (evidence: `network/server.py`)
- Messaging server → TLS configuration: configures TLS (evidence: `network/server.py`)
- Messaging server → Identity registry: registers identities (evidence: `network/server.py`)
- Messaging server → Challenge authentication: verifies challenge (evidence: `network/server.py`)
- Messaging server → TOTP verification: verifies TOTP (evidence: `network/server.py`)
- Messaging server → Offline queue: queues delivery (evidence: `network/server.py`)
- Messaging server → Session tracking: tracks sessions (evidence: `network/server.py`)
- Messaging server → Incident detection: checks activity (evidence: `network/server.py`)
- Messaging server → Security event log: logs events (evidence: `network/server.py`)
- Identity manager → Key management: loads keys (evidence: `identity/manager.py`)
- Identity manager → Key vault: protects private key (evidence: `identity/manager.py`)
- Identity manager → Payload encryption: decrypts payload (evidence: `identity/manager.py`)
- Identity manager → Ed25519 signatures: signs data (evidence: `identity/manager.py`)
- Identity registry → Key management: uses key utilities (evidence: `auth/registry.py`)
- Challenge authentication → Ed25519 signatures: uses Ed25519 (evidence: `auth/challenge.py`)
- Payload encryption → Ed25519 signatures: uses canonical bytes (evidence: `crypto/encryption.py`)
- Signed envelopes → Ed25519 signatures: signs fields (evidence: `signing/envelope.py`)
- Incident detection → Security event log: reports detections (evidence: `network/incident_detection.py`)
