# talatberke/schat architecture

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

- Interactive diagram: https://gitdiagram.com/talatberke/schat
- Repository: https://github.com/talatberke/schat

## Overview

SecretChat is a desktop app for room-code-based, end-to-end encrypted chat. Users create or join a room, compare a short authentication code, then exchange text and media; messages stay in RAM unless history saving is enabled. The graph follows the documented UI, room, cryptography, signaling and storage responsibilities, and includes optional networking and customization capabilities. Only main.py and the theme tools were excerpted, so several subsystem links are documented at product level or shown as unverified rather than asserted as inspected calls.

Main entry points: [`secretchat/room.py`](https://github.com/talatberke/schat/blob/main/secretchat/room.py) (Room sessions), [`secretchat/ui.py`](https://github.com/talatberke/schat/blob/main/secretchat/ui.py) (Chat interface), [`main.py`](https://github.com/talatberke/schat/blob/main/main.py) (Application entry), [`secretchat/signaling.py`](https://github.com/talatberke/schat/blob/main/secretchat/signaling.py) (MQTT signaling)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Desktop interface"]
  node_entry["Application entry<br/>[main.py]"]
  node_ui["Chat interface<br/>[ui.py]"]
  node_components["Chat components<br/>[components.py]"]
  node_emoji["Emoji picker<br/>[emoji_picker.py]"]
end

subgraph group_sessions["Room and protocol"]
  node_room["Room sessions<br/>[room.py]"]
  node_messages["Envelope protocol<br/>[messages.py]"]
end

subgraph group_security["Cryptography"]
  node_crypto["Key exchange and encryption<br/>[crypto.py]"]
  node_security["Security validation<br/>[security.py]"]
end

subgraph group_network["Network transport"]
  node_signaling["MQTT signaling<br/>[signaling.py]"]
  node_broker{{"MQTT broker"}}
  node_stun["STUN discovery<br/>[stun.py]"]
  node_p2p["UDP P2P transport<br/>[p2p.py]"]
end

subgraph group_local["Local features"]
  node_storage[("History storage<br/>[storage.py]")]
  node_media["Image handling<br/>[media.py]"]
  node_theme["Theme settings<br/>[theme.py]"]
  node_fonts["Font management<br/>[fonts.py]"]
  node_nicknames["Automatic nicknames<br/>[nicknames.py]"]
  node_config["App configuration<br/>[config.py]"]
end

node_user(("Chat user"))

node_user -->|"launches"| node_entry
node_entry -->|"runs"| node_ui
node_user -->|"creates or joins"| node_ui
node_ui -.->|"starts session"| node_room
node_room -->|"exchanges envelopes"| node_messages
node_room -->|"performs key exchange"| node_crypto
node_room -->|"uses relay channel"| node_signaling
node_signaling -->|"relays ciphertext"| node_broker
node_room -->|"discovers peer address"| node_stun
node_room -->|"uses UDP transport"| node_p2p
node_user -->|"opts into history"| node_storage
node_user -->|"selects image"| node_media
node_user -->|"chooses emoji"| node_emoji
node_user -->|"chooses font"| node_fonts
node_user -->|"changes appearance"| node_theme
node_ui -.->|"renders chat"| node_components
node_ui -.->|"uses generated nickname"| node_nicknames
node_room -.->|"validates session"| node_security
node_room -.->|"saves history"| node_storage
node_room -.->|"transfers images"| node_media
node_room -.->|"uses defaults"| node_config

click node_entry "https://github.com/talatberke/schat/blob/main/main.py"
click node_ui "https://github.com/talatberke/schat/blob/main/secretchat/ui.py"
click node_components "https://github.com/talatberke/schat/blob/main/secretchat/components.py"
click node_emoji "https://github.com/talatberke/schat/blob/main/secretchat/emoji_picker.py"
click node_room "https://github.com/talatberke/schat/blob/main/secretchat/room.py"
click node_messages "https://github.com/talatberke/schat/blob/main/secretchat/messages.py"
click node_crypto "https://github.com/talatberke/schat/blob/main/secretchat/crypto.py"
click node_security "https://github.com/talatberke/schat/blob/main/secretchat/security.py"
click node_signaling "https://github.com/talatberke/schat/blob/main/secretchat/signaling.py"
click node_stun "https://github.com/talatberke/schat/blob/main/secretchat/stun.py"
click node_p2p "https://github.com/talatberke/schat/blob/main/secretchat/p2p.py"
click node_storage "https://github.com/talatberke/schat/blob/main/secretchat/storage.py"
click node_media "https://github.com/talatberke/schat/blob/main/secretchat/media.py"
click node_theme "https://github.com/talatberke/schat/blob/main/secretchat/theme.py"
click node_fonts "https://github.com/talatberke/schat/blob/main/secretchat/fonts.py"
click node_nicknames "https://github.com/talatberke/schat/blob/main/secretchat/nicknames.py"
click node_config "https://github.com/talatberke/schat/blob/main/secretchat/config.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_entry,node_ui,node_components,node_emoji,node_user toneBlue
class node_room,node_messages toneAmber
class node_crypto,node_security toneMint
class node_signaling,node_broker,node_stun,node_p2p toneRose
class node_storage,node_media,node_theme,node_fonts,node_nicknames,node_config toneIndigo
```

## Components

### Desktop interface

- [Application entry](https://github.com/talatberke/schat/blob/main/main.py): `main.py`
- [Chat interface](https://github.com/talatberke/schat/blob/main/secretchat/ui.py): `secretchat/ui.py`
- [Chat components](https://github.com/talatberke/schat/blob/main/secretchat/components.py): `secretchat/components.py`
- [Emoji picker](https://github.com/talatberke/schat/blob/main/secretchat/emoji_picker.py): `secretchat/emoji_picker.py`

### Room and protocol

- [Room sessions](https://github.com/talatberke/schat/blob/main/secretchat/room.py): `secretchat/room.py`
- [Envelope protocol](https://github.com/talatberke/schat/blob/main/secretchat/messages.py): `secretchat/messages.py`

### Cryptography

- [Key exchange and encryption](https://github.com/talatberke/schat/blob/main/secretchat/crypto.py): `secretchat/crypto.py`
- [Security validation](https://github.com/talatberke/schat/blob/main/secretchat/security.py): `secretchat/security.py`

### Network transport

- [MQTT signaling](https://github.com/talatberke/schat/blob/main/secretchat/signaling.py): `secretchat/signaling.py`
- **MQTT broker**
- [STUN discovery](https://github.com/talatberke/schat/blob/main/secretchat/stun.py): `secretchat/stun.py`
- [UDP P2P transport](https://github.com/talatberke/schat/blob/main/secretchat/p2p.py): `secretchat/p2p.py`

### Local features

- [History storage](https://github.com/talatberke/schat/blob/main/secretchat/storage.py): `secretchat/storage.py`
- [Image handling](https://github.com/talatberke/schat/blob/main/secretchat/media.py): `secretchat/media.py`
- [Theme settings](https://github.com/talatberke/schat/blob/main/secretchat/theme.py): `secretchat/theme.py`
- [Font management](https://github.com/talatberke/schat/blob/main/secretchat/fonts.py): `secretchat/fonts.py`
- [Automatic nicknames](https://github.com/talatberke/schat/blob/main/secretchat/nicknames.py): `secretchat/nicknames.py`
- [App configuration](https://github.com/talatberke/schat/blob/main/secretchat/config.py): `secretchat/config.py`

### Other components

- **Chat user**

## Connections

- Chat user → Application entry: launches (evidence: `README.md`)
- Application entry → Chat interface: runs (evidence: `main.py`)
- Chat user → Chat interface: creates or joins (evidence: `README.md`)
- Chat interface → Room sessions: starts session
- Room sessions → Envelope protocol: exchanges envelopes (evidence: `README.md`)
- Room sessions → Key exchange and encryption: performs key exchange (evidence: `README.md`)
- Room sessions → MQTT signaling: uses relay channel (evidence: `README.md`)
- MQTT signaling → MQTT broker: relays ciphertext (evidence: `README.md`)
- Room sessions → STUN discovery: discovers peer address (evidence: `README.md`)
- Room sessions → UDP P2P transport: uses UDP transport (evidence: `README.md`)
- Chat user → History storage: opts into history (evidence: `README.md`)
- Chat user → Image handling: selects image (evidence: `README.md`)
- Chat user → Emoji picker: chooses emoji (evidence: `README.md`)
- Chat user → Font management: chooses font (evidence: `README.md`)
- Chat user → Theme settings: changes appearance (evidence: `README.md`)
- Chat interface → Chat components: renders chat
- Chat interface → Automatic nicknames: uses generated nickname
- Room sessions → Security validation: validates session
- Room sessions → History storage: saves history
- Room sessions → Image handling: transfers images
- Room sessions → App configuration: uses defaults
