# qwexaro/zephyr architecture

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

- Interactive diagram: https://gitdiagram.com/qwexaro/zephyr
- Repository: https://github.com/qwexaro/zephyr

## Overview

Zephyr is an early-stage F# Telegram MTProto library. Its principal documented workflow connects a TCP transport to a three-phase handshake that produces an AuthKey; the README’s sandbox invokes the transport and handshake. Other documented capabilities include TL binary serialization and schemas, cryptographic primitives, and secure session storage. Relationships beyond those shown in the README are omitted or marked unverified: no source excerpts were provided.

Main entry points: [`Core/HandshakeEngine.fs`](https://github.com/qwexaro/zephyr/blob/main/Core/HandshakeEngine.fs) (Handshake engine), [`Core/TcpTransport.fs`](https://github.com/qwexaro/zephyr/blob/main/Core/TcpTransport.fs) (TCP transport), [`Crypto/AesIge.fs`](https://github.com/qwexaro/zephyr/blob/main/Crypto/AesIge.fs) (AES-IGE), [`Crypto/Hash.fs`](https://github.com/qwexaro/zephyr/blob/main/Crypto/Hash.fs) (Hashing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_network["Network and handshake"]
  node_transport["TCP transport<br/>[TcpTransport.fs]"]
  node_handshake["Handshake engine<br/>[HandshakeEngine.fs]"]
  node_authkey["Auth key<br/>[HandshakeEngine.fs]"]
end

subgraph group_crypto["Cryptography"]
  node_aes["AES-IGE<br/>[AesIge.fs]"]
  node_hash["Hashing<br/>[Hash.fs]"]
  node_kdf["Key derivation<br/>[Kdf.fs]"]
  node_prime["Prime mathematics<br/>[Prime.fs]"]
  node_rsa["RSA<br/>[Rsa.fs]"]
end

subgraph group_tl["TL encoding"]
  node_tlwriter["TL writer<br/>[TlWriter.fs]"]
  node_tlreader["TL reader<br/>[TlReader.fs]"]
  node_schema["API schema<br/>[Schema.fs]"]
end

subgraph group_state["Session storage"]
  node_session[("Session manager<br/>[Session.fs]")]
end

node_caller(("Sandbox caller"))
node_telegram(("Telegram DC"))

node_caller -->|"connects"| node_transport
node_caller -->|"runs phases"| node_handshake
node_transport -->|"opens socket"| node_telegram
node_handshake -->|"uses transport"| node_transport
node_handshake -->|"generates"| node_authkey
node_handshake -.->|"may serialize with"| node_tlwriter
node_handshake -.->|"may use"| node_aes
node_handshake -.->|"may use"| node_hash
node_handshake -.->|"may use"| node_kdf
node_handshake -.->|"may use"| node_prime
node_handshake -.->|"may use"| node_rsa

click node_transport "https://github.com/qwexaro/zephyr/blob/main/Core/TcpTransport.fs"
click node_handshake "https://github.com/qwexaro/zephyr/blob/main/Core/HandshakeEngine.fs"
click node_authkey "https://github.com/qwexaro/zephyr/blob/main/Core/HandshakeEngine.fs"
click node_aes "https://github.com/qwexaro/zephyr/blob/main/Crypto/AesIge.fs"
click node_hash "https://github.com/qwexaro/zephyr/blob/main/Crypto/Hash.fs"
click node_kdf "https://github.com/qwexaro/zephyr/blob/main/Crypto/Kdf.fs"
click node_prime "https://github.com/qwexaro/zephyr/blob/main/Crypto/Prime.fs"
click node_rsa "https://github.com/qwexaro/zephyr/blob/main/Crypto/Rsa.fs"
click node_tlwriter "https://github.com/qwexaro/zephyr/blob/main/TL/TlWriter.fs"
click node_tlreader "https://github.com/qwexaro/zephyr/blob/main/TL/TlReader.fs"
click node_schema "https://github.com/qwexaro/zephyr/blob/main/TL/Schema.fs"
click node_session "https://github.com/qwexaro/zephyr/blob/main/Core/Session.fs"

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_transport,node_handshake,node_authkey toneBlue
class node_aes,node_hash,node_kdf,node_prime,node_rsa toneAmber
class node_tlwriter,node_tlreader,node_schema toneMint
class node_session toneRose
class node_caller,node_telegram toneIndigo
```

## Components

### Network and handshake

- [TCP transport](https://github.com/qwexaro/zephyr/blob/main/Core/TcpTransport.fs): `Core/TcpTransport.fs`
- [Handshake engine](https://github.com/qwexaro/zephyr/blob/main/Core/HandshakeEngine.fs): `Core/HandshakeEngine.fs`
- [Auth key](https://github.com/qwexaro/zephyr/blob/main/Core/HandshakeEngine.fs): `Core/HandshakeEngine.fs`

### Cryptography

- [AES-IGE](https://github.com/qwexaro/zephyr/blob/main/Crypto/AesIge.fs): `Crypto/AesIge.fs`
- [Hashing](https://github.com/qwexaro/zephyr/blob/main/Crypto/Hash.fs): `Crypto/Hash.fs`
- [Key derivation](https://github.com/qwexaro/zephyr/blob/main/Crypto/Kdf.fs): `Crypto/Kdf.fs`
- [Prime mathematics](https://github.com/qwexaro/zephyr/blob/main/Crypto/Prime.fs): `Crypto/Prime.fs`
- [RSA](https://github.com/qwexaro/zephyr/blob/main/Crypto/Rsa.fs): `Crypto/Rsa.fs`

### TL encoding

- [TL writer](https://github.com/qwexaro/zephyr/blob/main/TL/TlWriter.fs): `TL/TlWriter.fs`
- [TL reader](https://github.com/qwexaro/zephyr/blob/main/TL/TlReader.fs): `TL/TlReader.fs`
- [API schema](https://github.com/qwexaro/zephyr/blob/main/TL/Schema.fs): `TL/Schema.fs`

### Session storage

- [Session manager](https://github.com/qwexaro/zephyr/blob/main/Core/Session.fs): `Core/Session.fs`

### Other components

- **Sandbox caller**
- **Telegram DC**

## Connections

- Sandbox caller → TCP transport: connects (evidence: `README.md`)
- Sandbox caller → Handshake engine: runs phases (evidence: `README.md`)
- TCP transport → Telegram DC: opens socket (evidence: `README.md`)
- Handshake engine → TCP transport: uses transport (evidence: `README.md`)
- Handshake engine → Auth key: generates (evidence: `README.md`)
- Handshake engine → TL writer: may serialize with
- Handshake engine → AES-IGE: may use
- Handshake engine → Hashing: may use
- Handshake engine → Key derivation: may use
- Handshake engine → Prime mathematics: may use
- Handshake engine → RSA: may use
