# krish-legend13/sentra-app architecture

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

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

## Overview

SENTRA is an end-to-end encrypted messaging product with desktop and Flask web interfaces. Its main workflow is account registration or login, multi-factor authentication, local identity-key protection, secure conversation setup, encrypted messaging, server-side routing, and recipient delivery. Separate branches provide backups, presence, audit/forensic views, and account settings. The graph reflects README-documented capabilities and sampled call/import evidence; unsampled modules are included where the README or source index establishes their role, but their internal wiring is not assumed.

Main entry points: [`web/app.py`](https://github.com/krish-legend13/sentra-app/blob/main/web/app.py) (Web application), [`messaging/service.py`](https://github.com/krish-legend13/sentra-app/blob/main/messaging/service.py) (Messaging service), [`web/session_manager.py`](https://github.com/krish-legend13/sentra-app/blob/main/web/session_manager.py) (Web sessions), [`ui/registration.py`](https://github.com/krish-legend13/sentra-app/blob/main/ui/registration.py) (Registration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["User interfaces"]
  node_desktop["Desktop app<br/>[main.py]"]
  node_registration["Registration<br/>[registration.py]"]
  node_desktop_login["Desktop login<br/>[login.py]"]
  node_dashboard["Messaging dashboard<br/>[dashboard.py]"]
  node_forensics_ui["Security views<br/>[forensic_view.py]"]
end

subgraph group_identity["Accounts and identity"]
  node_verification["Phone verification"]
  node_account_manager["Account management<br/>[manager.py]"]
  node_totp["TOTP authentication<br/>[totp.py]"]
  node_identity_keys["Identity keys<br/>[keys.py]"]
  node_vault[("Encrypted identity vault<br/>[vault.py]")]
end

subgraph group_messaging["Secure messaging"]
  node_crypto["Cryptographic primitives<br/>[encryption.py]"]
  node_certificates["Conversation certificates<br/>[certificates.py]"]
  node_messaging_service["Messaging service<br/>[service.py]"]
  node_tcp_router["TCP message router<br/>[server.py]"]
  node_offline_queue["Offline message queue<br/>[server.py]"]
end

subgraph group_platform["Storage and security"]
  node_local_database[("Local data store<br/>[database.py]")]
  node_queries["Message and conversation data<br/>[queries.py]"]
  node_audit["Audit and forensic logging<br/>[logging.py]"]
end

subgraph group_web["Web experience"]
  node_web_app["Web application<br/>[app.py]"]
  node_web_auth["Web authentication<br/>[auth.py]"]
  node_web_sessions["Web sessions<br/>[session_manager.py]"]
  node_web_conversations["Web conversations<br/>[conversations.py]"]
  node_web_backup["Web backups<br/>[backup.py]"]
  node_web_forensics["Web forensics<br/>[forensics.py]"]
  node_web_settings["Web settings<br/>[settings.py]"]
  node_web_dashboard["Web dashboard<br/>[dashboard.py]"]
end

node_person(("User"))
node_recipient(("Recipient"))
node_web_client(("Web user"))

node_person -->|"uses"| node_desktop
node_desktop -->|"opens"| node_registration
node_registration -.->|"verifies phone"| node_verification
node_registration -.->|"registers account"| node_account_manager
node_desktop -->|"opens"| node_desktop_login
node_desktop_login -.->|"checks code"| node_totp
node_desktop_login -.->|"unlocks identity"| node_vault
node_registration -.->|"creates identity"| node_identity_keys
node_identity_keys -.->|"stores protected key"| node_vault
node_person -->|"uses"| node_dashboard
node_dashboard -->|"sends messages"| node_messaging_service
node_messaging_service -.->|"establishes conversations"| node_certificates
node_messaging_service -->|"encrypts messages"| node_crypto
node_messaging_service -->|"routes packets"| node_tcp_router
node_tcp_router -->|"queues offline"| node_offline_queue
node_tcp_router -->|"delivers envelopes"| node_recipient
node_messaging_service -->|"reads and writes"| node_queries
node_queries -->|"uses database"| node_local_database
node_dashboard -->|"opens security views"| node_forensics_ui
node_dashboard -->|"shows security events"| node_audit
node_person -->|"uses"| node_web_client
node_web_client -->|"accesses"| node_web_app
node_web_app -->|"registers routes"| node_web_auth
node_web_app -->|"registers routes"| node_web_dashboard
node_web_app -->|"registers routes"| node_web_conversations
node_web_app -->|"registers routes"| node_web_forensics
node_web_app -->|"registers routes"| node_web_backup
node_web_app -->|"registers routes"| node_web_settings
node_web_auth -->|"verifies code"| node_totp
node_web_auth -->|"unlocks identity"| node_vault
node_web_auth -->|"creates session"| node_web_sessions
node_web_conversations -->|"uses session"| node_web_sessions
node_web_conversations -->|"uses messaging"| node_messaging_service
node_web_backup -->|"uses session"| node_web_sessions
node_web_forensics -->|"uses session"| node_web_sessions
node_web_settings -->|"uses session"| node_web_sessions
node_web_conversations -->|"reads and writes"| node_queries
node_web_backup -->|"records events"| node_audit
node_web_forensics -->|"reads audit data"| node_audit

click node_desktop "https://github.com/krish-legend13/sentra-app/blob/main/main.py"
click node_registration "https://github.com/krish-legend13/sentra-app/blob/main/ui/registration.py"
click node_desktop_login "https://github.com/krish-legend13/sentra-app/blob/main/ui/login.py"
click node_dashboard "https://github.com/krish-legend13/sentra-app/blob/main/ui/dashboard.py"
click node_forensics_ui "https://github.com/krish-legend13/sentra-app/blob/main/ui/forensic_view.py"
click node_verification "https://github.com/krish-legend13/sentra-app/blob/main/account/phone_verification.py"
click node_account_manager "https://github.com/krish-legend13/sentra-app/blob/main/account/manager.py"
click node_totp "https://github.com/krish-legend13/sentra-app/blob/main/auth/totp.py"
click node_identity_keys "https://github.com/krish-legend13/sentra-app/blob/main/identity/keys.py"
click node_vault "https://github.com/krish-legend13/sentra-app/blob/main/identity/vault.py"
click node_crypto "https://github.com/krish-legend13/sentra-app/blob/main/crypto/encryption.py"
click node_certificates "https://github.com/krish-legend13/sentra-app/blob/main/messaging/certificates.py"
click node_messaging_service "https://github.com/krish-legend13/sentra-app/blob/main/messaging/service.py"
click node_tcp_router "https://github.com/krish-legend13/sentra-app/blob/main/network/server.py"
click node_offline_queue "https://github.com/krish-legend13/sentra-app/blob/main/network/server.py"
click node_local_database "https://github.com/krish-legend13/sentra-app/blob/main/database/database.py"
click node_queries "https://github.com/krish-legend13/sentra-app/blob/main/database/queries.py"
click node_audit "https://github.com/krish-legend13/sentra-app/blob/main/security/logging.py"
click node_web_app "https://github.com/krish-legend13/sentra-app/blob/main/web/app.py"
click node_web_auth "https://github.com/krish-legend13/sentra-app/blob/main/web/routes/auth.py"
click node_web_sessions "https://github.com/krish-legend13/sentra-app/blob/main/web/session_manager.py"
click node_web_conversations "https://github.com/krish-legend13/sentra-app/blob/main/web/routes/conversations.py"
click node_web_backup "https://github.com/krish-legend13/sentra-app/blob/main/web/routes/backup.py"
click node_web_forensics "https://github.com/krish-legend13/sentra-app/blob/main/web/routes/forensics.py"
click node_web_settings "https://github.com/krish-legend13/sentra-app/blob/main/web/routes/settings.py"
click node_web_dashboard "https://github.com/krish-legend13/sentra-app/blob/main/web/routes/dashboard.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_desktop,node_registration,node_desktop_login,node_dashboard,node_forensics_ui,node_person,node_web_client toneBlue
class node_verification,node_account_manager,node_totp,node_identity_keys,node_vault toneAmber
class node_crypto,node_certificates,node_messaging_service,node_tcp_router,node_offline_queue toneMint
class node_local_database,node_queries,node_audit toneRose
class node_web_app,node_web_auth,node_web_sessions,node_web_conversations,node_web_backup,node_web_forensics,node_web_settings,node_web_dashboard,node_recipient toneIndigo
```

## Components

### User interfaces

- [Desktop app](https://github.com/krish-legend13/sentra-app/blob/main/main.py): `main.py`
- [Registration](https://github.com/krish-legend13/sentra-app/blob/main/ui/registration.py): `ui/registration.py`
- [Desktop login](https://github.com/krish-legend13/sentra-app/blob/main/ui/login.py): `ui/login.py`
- [Messaging dashboard](https://github.com/krish-legend13/sentra-app/blob/main/ui/dashboard.py): `ui/dashboard.py`
- [Security views](https://github.com/krish-legend13/sentra-app/blob/main/ui/forensic_view.py): `ui/forensic_view.py`

### Accounts and identity

- [Phone verification](https://github.com/krish-legend13/sentra-app/blob/main/account/phone_verification.py): `account/phone_verification.py`
- [Account management](https://github.com/krish-legend13/sentra-app/blob/main/account/manager.py): `account/manager.py`
- [TOTP authentication](https://github.com/krish-legend13/sentra-app/blob/main/auth/totp.py): `auth/totp.py`
- [Identity keys](https://github.com/krish-legend13/sentra-app/blob/main/identity/keys.py): `identity/keys.py`
- [Encrypted identity vault](https://github.com/krish-legend13/sentra-app/blob/main/identity/vault.py): `identity/vault.py`

### Secure messaging

- [Cryptographic primitives](https://github.com/krish-legend13/sentra-app/blob/main/crypto/encryption.py): `crypto/encryption.py`
- [Conversation certificates](https://github.com/krish-legend13/sentra-app/blob/main/messaging/certificates.py): `messaging/certificates.py`
- [Messaging service](https://github.com/krish-legend13/sentra-app/blob/main/messaging/service.py): `messaging/service.py`
- [TCP message router](https://github.com/krish-legend13/sentra-app/blob/main/network/server.py): `network/server.py`
- [Offline message queue](https://github.com/krish-legend13/sentra-app/blob/main/network/server.py): `network/server.py`

### Storage and security

- [Local data store](https://github.com/krish-legend13/sentra-app/blob/main/database/database.py): `database/database.py`
- [Message and conversation data](https://github.com/krish-legend13/sentra-app/blob/main/database/queries.py): `database/queries.py`
- [Audit and forensic logging](https://github.com/krish-legend13/sentra-app/blob/main/security/logging.py): `security/logging.py`

### Web experience

- [Web application](https://github.com/krish-legend13/sentra-app/blob/main/web/app.py): `web/app.py`
- [Web authentication](https://github.com/krish-legend13/sentra-app/blob/main/web/routes/auth.py): `web/routes/auth.py`
- [Web sessions](https://github.com/krish-legend13/sentra-app/blob/main/web/session_manager.py): `web/session_manager.py`
- [Web conversations](https://github.com/krish-legend13/sentra-app/blob/main/web/routes/conversations.py): `web/routes/conversations.py`
- [Web backups](https://github.com/krish-legend13/sentra-app/blob/main/web/routes/backup.py): `web/routes/backup.py`
- [Web forensics](https://github.com/krish-legend13/sentra-app/blob/main/web/routes/forensics.py): `web/routes/forensics.py`
- [Web settings](https://github.com/krish-legend13/sentra-app/blob/main/web/routes/settings.py): `web/routes/settings.py`
- [Web dashboard](https://github.com/krish-legend13/sentra-app/blob/main/web/routes/dashboard.py): `web/routes/dashboard.py`

### Other components

- **User**
- **Recipient**
- **Web user**

## Connections

- User → Desktop app: uses
- Desktop app → Registration: opens (evidence: `main.py`)
- Registration → Phone verification: verifies phone
- Registration → Account management: registers account
- Desktop app → Desktop login: opens (evidence: `main.py`)
- Desktop login → TOTP authentication: checks code
- Desktop login → Encrypted identity vault: unlocks identity
- Registration → Identity keys: creates identity
- Identity keys → Encrypted identity vault: stores protected key
- User → Messaging dashboard: uses
- Messaging dashboard → Messaging service: sends messages (evidence: `ui/dashboard.py`)
- Messaging service → Conversation certificates: establishes conversations
- Messaging service → Cryptographic primitives: encrypts messages (evidence: `messaging/service.py`)
- Messaging service → TCP message router: routes packets (evidence: `messaging/service.py`)
- TCP message router → Offline message queue: queues offline (evidence: `network/server.py`)
- TCP message router → Recipient: delivers envelopes
- Messaging service → Message and conversation data: reads and writes (evidence: `messaging/service.py`)
- Message and conversation data → Local data store: uses database (evidence: `database/queries.py`)
- Messaging dashboard → Security views: opens security views (evidence: `ui/dashboard.py`)
- Messaging dashboard → Audit and forensic logging: shows security events (evidence: `ui/dashboard.py`)
- User → Web user: uses
- Web user → Web application: accesses
- Web application → Web authentication: registers routes (evidence: `web/app.py`)
- Web application → Web dashboard: registers routes (evidence: `web/app.py`)
- Web application → Web conversations: registers routes (evidence: `web/app.py`)
- Web application → Web forensics: registers routes (evidence: `web/app.py`)
- Web application → Web backups: registers routes (evidence: `web/app.py`)
- Web application → Web settings: registers routes (evidence: `web/app.py`)
- Web authentication → TOTP authentication: verifies code (evidence: `web/routes/auth.py`)
- Web authentication → Encrypted identity vault: unlocks identity (evidence: `web/routes/auth.py`)
- Web authentication → Web sessions: creates session (evidence: `web/routes/auth.py`)
- Web conversations → Web sessions: uses session (evidence: `web/routes/conversations.py`)
- Web conversations → Messaging service: uses messaging (evidence: `web/routes/conversations.py`)
- Web backups → Web sessions: uses session (evidence: `web/routes/backup.py`)
- Web forensics → Web sessions: uses session (evidence: `web/routes/forensics.py`)
- Web settings → Web sessions: uses session (evidence: `web/routes/settings.py`)
- Web conversations → Message and conversation data: reads and writes (evidence: `web/routes/conversations.py`)
- Web backups → Audit and forensic logging: records events (evidence: `web/routes/backup.py`)
- Web forensics → Audit and forensic logging: reads audit data (evidence: `web/routes/forensics.py`)
