# youseffayez20/secure-communication-suite architecture

> Architecture diagram of the GitHub repository youseffayez20/secure-communication-suite, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/youseffayez20/secure-communication-suite
- Repository: https://github.com/youseffayez20/secure-communication-suite

## Overview

#### Purpose and Entry Points
This is a Python secure-communication coursework project combining messaging, authentication, cryptography, certificates, and local persistence. The apparent executable roles are server and client:
- `server.py` hosts the communication service.
- `client.py` connects to it and participates in secure messaging.
- `main.py` may provide an alternate orchestration entry point.
Legacy implementations are retained in `server_old.py` and `client_old.py`.

#### Client–Server Communication Boundary
The core runtime boundary is a networked client/server model. Clients submit authentication and messaging requests; the server is responsible for accepting connections, validating users, and coordinating protected communication.
- `client.py`
- `server.py`
- `main.py`

Transport protection is intended to use TLS/SSL and certificate material, rather than exposing cryptographic operations solely as local utilities.

#### Cryptographic Protection Layer
Cryptographic code is separated under `crypto/`, providing the primitives used to protect message confidentiality, integrity, and authenticity:
- `crypto/aes.py` supplies symmetric encryption for message/data confidentiality.
- `crypto/rsaEnDe.py` handles RSA encryption/decryption, likely for protected key exchange or asymmetric payload handling.
- `crypto/hash.py` provides message digest/integrity operations.
- `crypto/signing.py` supports signing and signature verification.

The intended flow is asymmetric cryptography or certificates to establish trust/protect keys, AES for bulk message encryption, and hashes/signatures to detect modification and authenticate content.

#### Certificate Authority and Trust Material
A local certificate authority subsystem supports certificate-based identity and TLS trust:
- `crypto/ca.py`
- `crypto/certificates/ca_cert.pem`
- `crypto/certificates/server_cert.pem`

The repository includes CA private-key material and issued certificates, including `crypto/certificates/moh.crt` and `crypto/certificates/moh2.crt`. Server key material also exists at repository root: `server_private.pem` and `server_public.pem`. These are sensitive runtime assets and form a hard trust boundary between trusted service identity and untrusted network peers.

#### Authentication and User Identity
Authentication is implemented separately from transport and cryptographic primitives:
- `utils/auth.py`
- `data/auth.txt`
- `data/users.txt`

This suggests file-backed credential/user validation. Authentication gates access to the server’s messaging or protected-service functionality; certificate mechanisms may provide an additional identity path.

#### Key Management
Key generation, loading, and distribution concerns are isolated in:
- `utils/keys.py`
- `crypto/rsaEnDe.py`
- `crypto/certificates/`

This layer bridges persistent key/certificate files and the client/server protocol. It is responsible for ensuring that encryption keys and asymmetric identities are available to the communication layer without embedding key logic directly in application flow.

#### Persistence and Runtime Dependencies
Local persistence appears SQLite- and file-based rather than dependent on external infrastructure:
- `Database.py`
- `DataBase.db`
- `data/`

`Database.py` likely encapsulates database access, while `DataBase.db` stores application state. No cloud service, message broker, web framework, or external managed identity provider is represented in the repository tree; the system runs as local Python processes with local keys, certificates, flat files, and SQLite storage.

Main entry points: [`server.py`](https://github.com/youseffayez20/secure-communication-suite/blob/master/server.py) (Server), [`client.py`](https://github.com/youseffayez20/secure-communication-suite/blob/master/client.py) (Client), [`utils/auth.py`](https://github.com/youseffayez20/secure-communication-suite/blob/master/utils/auth.py) (Authentication), [`crypto/rsaEnDe.py`](https://github.com/youseffayez20/secure-communication-suite/blob/master/crypto/rsaEnDe.py) (RSA protection)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime"]
  node_client["Client<br/>Python entry point<br/>[client.py]"]
  node_server["Server<br/>Python service<br/>[server.py]"]
  node_main["Alternate entry<br/>Python entry point<br/>[main.py]"]
end

subgraph group_security["Security &amp; Trust"]
  node_tls{{"TLS transport<br/>network security boundary"}}
  node_key_management["Key management<br/>key loading and distribution<br/>[keys.py]"]
  node_rsa["RSA protection<br/>asymmetric cryptography<br/>[rsaEnDe.py]"]
  node_aes["AES encryption<br/>symmetric cryptography<br/>[aes.py]"]
  node_integrity["Hashing &amp; signing<br/>integrity and authenticity<br/>[signing.py]"]
  node_hash["Hash functions<br/>message digest<br/>[hash.py]"]
  node_ca["Certificate authority<br/>local CA<br/>[ca.py]"]
  node_certificates["Certificates<br/>trust material"]
  node_server_keys["Server keypair<br/>service identity keys<br/>[server_private.pem]"]
end

subgraph group_identity["Identity &amp; Persistence"]
  node_auth["Authentication<br/>credential validation<br/>[auth.py]"]
  node_credentials["User credentials<br/>flat-file identity store<br/>[auth.txt]"]
  node_users["User records<br/>flat-file user store<br/>[users.txt]"]
  node_database["Database access<br/>SQLite adapter<br/>[Database.py]"]
  node_sqlite[("Application state<br/>SQLite database<br/>[DataBase.db]")]
end

node_main -.->|"orchestrates"| node_client
node_main -.->|"orchestrates"| node_server
node_client -->|"secure connection"| node_tls
node_tls -->|"protected requests"| node_server
node_server -->|"authenticates"| node_auth
node_auth -->|"validates"| node_credentials
node_auth -->|"loads users"| node_users
node_server -->|"persists state"| node_database
node_database -->|"reads and writes"| node_sqlite
node_client -->|"encrypts messages"| node_aes
node_server -->|"decrypts messages"| node_aes
node_client -->|"signs content"| node_integrity
node_server -->|"verifies content"| node_integrity
node_integrity -->|"uses digests"| node_hash
node_key_management -->|"manages asymmetric keys"| node_rsa
node_key_management -->|"loads trust material"| node_certificates
node_ca -->|"issues trust material"| node_certificates
node_certificates -->|"establishes trust"| node_tls
node_server_keys -->|"server identity"| node_rsa
node_rsa -.->|"protects session keys"| node_aes

click node_client "https://github.com/youseffayez20/secure-communication-suite/blob/master/client.py"
click node_server "https://github.com/youseffayez20/secure-communication-suite/blob/master/server.py"
click node_main "https://github.com/youseffayez20/secure-communication-suite/blob/master/main.py"
click node_auth "https://github.com/youseffayez20/secure-communication-suite/blob/master/utils/auth.py"
click node_credentials "https://github.com/youseffayez20/secure-communication-suite/blob/master/data/auth.txt"
click node_users "https://github.com/youseffayez20/secure-communication-suite/blob/master/data/users.txt"
click node_database "https://github.com/youseffayez20/secure-communication-suite/blob/master/Database.py"
click node_sqlite "https://github.com/youseffayez20/secure-communication-suite/blob/master/DataBase.db"
click node_key_management "https://github.com/youseffayez20/secure-communication-suite/blob/master/utils/keys.py"
click node_rsa "https://github.com/youseffayez20/secure-communication-suite/blob/master/crypto/rsaEnDe.py"
click node_aes "https://github.com/youseffayez20/secure-communication-suite/blob/master/crypto/aes.py"
click node_integrity "https://github.com/youseffayez20/secure-communication-suite/blob/master/crypto/signing.py"
click node_hash "https://github.com/youseffayez20/secure-communication-suite/blob/master/crypto/hash.py"
click node_ca "https://github.com/youseffayez20/secure-communication-suite/blob/master/crypto/ca.py"
click node_server_keys "https://github.com/youseffayez20/secure-communication-suite/blob/master/server_private.pem"

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_client,node_server,node_main toneBlue
class node_tls,node_key_management,node_rsa,node_aes,node_integrity,node_hash,node_ca,node_certificates,node_server_keys toneAmber
class node_auth,node_credentials,node_users,node_database,node_sqlite toneMint
```

## Components

### Runtime

- [Client](https://github.com/youseffayez20/secure-communication-suite/blob/master/client.py): Python entry point · Connects and participates in secure messaging. · `client.py`
- [Server](https://github.com/youseffayez20/secure-communication-suite/blob/master/server.py): Python service · Accepts connections and coordinates protected communication. · `server.py`
- [Alternate entry](https://github.com/youseffayez20/secure-communication-suite/blob/master/main.py): Python entry point · `main.py`

### Security & Trust

- **TLS transport**: network security boundary · Protects client-server transport using certificate material.
- [Key management](https://github.com/youseffayez20/secure-communication-suite/blob/master/utils/keys.py): key loading and distribution · Bridges persistent asymmetric identities and the protocol. · `utils/keys.py`
- [RSA protection](https://github.com/youseffayez20/secure-communication-suite/blob/master/crypto/rsaEnDe.py): asymmetric cryptography · Protects keys or asymmetric payloads. · `crypto/rsaEnDe.py`
- [AES encryption](https://github.com/youseffayez20/secure-communication-suite/blob/master/crypto/aes.py): symmetric cryptography · Encrypts message payloads. · `crypto/aes.py`
- [Hashing & signing](https://github.com/youseffayez20/secure-communication-suite/blob/master/crypto/signing.py): integrity and authenticity · Provides digests, signatures, and verification. · `crypto/signing.py`
- [Hash functions](https://github.com/youseffayez20/secure-communication-suite/blob/master/crypto/hash.py): message digest · `crypto/hash.py`
- [Certificate authority](https://github.com/youseffayez20/secure-communication-suite/blob/master/crypto/ca.py): local CA · Issues or manages trusted certificate identities. · `crypto/ca.py`
- **Certificates**: trust material · CA and issued certificates used for TLS trust and identity.
- [Server keypair](https://github.com/youseffayez20/secure-communication-suite/blob/master/server_private.pem): service identity keys · Sensitive private/public key material for server identity. · `server_private.pem`

### Identity & Persistence

- [Authentication](https://github.com/youseffayez20/secure-communication-suite/blob/master/utils/auth.py): credential validation · Gates access to messaging functionality. · `utils/auth.py`
- [User credentials](https://github.com/youseffayez20/secure-communication-suite/blob/master/data/auth.txt): flat-file identity store · `data/auth.txt`
- [User records](https://github.com/youseffayez20/secure-communication-suite/blob/master/data/users.txt): flat-file user store · `data/users.txt`
- [Database access](https://github.com/youseffayez20/secure-communication-suite/blob/master/Database.py): SQLite adapter · `Database.py`
- [Application state](https://github.com/youseffayez20/secure-communication-suite/blob/master/DataBase.db): SQLite database · `DataBase.db`

## Connections

- Alternate entry → Client: orchestrates
- Alternate entry → Server: orchestrates
- Client → TLS transport: secure connection
- TLS transport → Server: protected requests
- Server → Authentication: authenticates
- Authentication → User credentials: validates
- Authentication → User records: loads users
- Server → Database access: persists state
- Database access → Application state: reads and writes
- Client → AES encryption: encrypts messages
- Server → AES encryption: decrypts messages
- Client → Hashing & signing: signs content
- Server → Hashing & signing: verifies content
- Hashing & signing → Hash functions: uses digests
- Key management → RSA protection: manages asymmetric keys
- Key management → Certificates: loads trust material
- Certificate authority → Certificates: issues trust material
- Certificates → TLS transport: establishes trust
- Server keypair → RSA protection: server identity
- RSA protection → AES encryption: protects session keys
