# meynrun/zapfiles architecture

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

- Interactive diagram: https://gitdiagram.com/meynrun/zapfiles
- Repository: https://github.com/meynrun/zapfiles

## Overview

##### Project Overview
- ZapFiles is a Python-based client-server application focused on secure, end-to-end encrypted file transfers.
- It supports two main modes – “Get files” (client mode for downloading) and “Host files” (server mode for sharing).
- The project also includes configuration management, multilingual support, and several experimental features.

##### Main Components
a. Client Component:
- Files: cli.py, client.py, and main.py are likely to manage the user interface/command-line interactions and initiate file transfers.
- Functionality: The client handles user inputs (e.g., selecting mode, entering a server key) and coordinates communication with the server.
b. Server Component:
- File: server.py acts as the server side for hosting files.
- Functionality: Listens for incoming client connections, manages file transfers, and possibly coordinates encryption/decryption.
c. Configuration Module:
- Directory: config/ (includes app_configuration.py, base_configuration.py, experiments_configuration.py)
- Role: Manages various application settings (update checks, language preferences, file paths, experimental options).
d. Shared Utilities:
- Directory: shared/ (auto_update.py, file_hash.py, localization.py)
- Role: Provides common functionalities used by both client and server such as auto-update routines, file integrity checks (hashing), and localization handling.
e. Language Resources:
- Directory: lang/ (en.json, ru.json)
- Role: Store language strings for internationalization.
f. Build & Deployment:
- Files: build.py and setup_script.iss (for Inno Setup on Windows) indicate automated build processes and packaging.
g. Environment Management:
- Files: .python-version and env.py show that there is some environment configuration and handling logic.

##### Relationships & Interactions
- The Client module interacts with the Server module through network communications (using secure channels as implied by “end-to-end encryption”).
- Both modules load settings from the Configuration module to tailor behaviors based on defined parameters.
- The Shared module functions operate in both client and server contexts – ensuring that file transfers are secure (file_hash) and that updates and localization are consistent.
- The language resources are used by the Shared localization service to dynamically show UI text based on the chosen language.
- The Build process (build.py and setup_script.iss) ties into the overall deployment cycle, packaging the application for distribution.

##### Architectural Patterns and Design Principles
- A clear separation of concerns: user interaction (client), data hosting and retrieval (server), configuration, and utility functions are isolated in separate modules/directories.
- Modular design: utilities and configurations are factored into separate, reusable modules – a common practice for maintainability.
- Client-server pattern with explicit directions of data flow: user commands and file requests from the client are handled by the server.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Client Components"
        clientAgg["Client (CLI Interface)"]:::network
        cli["cli.py"]:::network
        clientFile["client.py"]:::network
        main["main.py"]:::network
        clientAgg -->|"contains"| cli
        clientAgg -->|"contains"| clientFile
        clientAgg -->|"contains"| main
    end

    subgraph "Server Components"
        serverAgg["Server (File Host)"]:::network
        serverF["server.py"]:::network
        serverAgg -->|"runs"| serverF
    end

    subgraph "Configuration Module"
        configMod["Config Module"]:::config
    end

    subgraph "Shared Utilities"
        sharedU["Shared Utils"]:::utility
    end

    subgraph "Language Resources"
        langRes["Language Files"]:::utility
    end

    subgraph "Encryption/Security"
        encryption["Encryption Layer"]:::security
    end

    subgraph "Build & Deployment"
        buildPy["build.py"]:::build
        setupISS["setup_script.iss"]:::build
    end

    subgraph "Environment Management"
        pyVersion[".python-version"]:::env
        envFile["env.py"]:::env
    end

    %% Connections between components
    clientAgg -->|"FileRequest"| encryption
    encryption -->|"SecureTransfer"| serverAgg
    serverAgg -->|"FileDelivery"| clientAgg

    clientAgg -->|"loads"| configMod
    serverAgg -->|"loads"| configMod

    clientAgg -->|"utilizes"| sharedU
    serverAgg -->|"utilizes"| sharedU

    sharedU -->|"localizes"| langRes

    buildPy -->|"packages"| clientAgg
    buildPy -->|"packages"| serverAgg
    setupISS -->|"packages"| clientAgg
    setupISS -->|"packages"| serverAgg

    clientAgg -->|"reads"| pyVersion
    clientAgg -->|"reads"| envFile
    serverAgg -->|"reads"| pyVersion
    serverAgg -->|"reads"| envFile

    %% Click events for mapped components
    click cli "https://github.com/meynrun/zapfiles/blob/master/cli.py"
    click clientFile "https://github.com/meynrun/zapfiles/blob/master/client.py"
    click main "https://github.com/meynrun/zapfiles/blob/master/main.py"
    click serverF "https://github.com/meynrun/zapfiles/blob/master/server.py"
    click configMod "https://github.com/meynrun/zapfiles/tree/master/config/"
    click sharedU "https://github.com/meynrun/zapfiles/tree/master/shared/"
    click langRes "https://github.com/meynrun/zapfiles/tree/master/lang/"
    click buildPy "https://github.com/meynrun/zapfiles/blob/master/build.py"
    click setupISS "https://github.com/meynrun/zapfiles/blob/master/setup_script.iss"
    click pyVersion "https://github.com/meynrun/zapfiles/blob/master/.python-version"
    click envFile "https://github.com/meynrun/zapfiles/blob/master/env.py"

    %% Styles
    classDef network fill:#89CFF0,stroke:#000,stroke-width:2px;
    classDef config fill:#FFD700,stroke:#000,stroke-width:2px;
    classDef utility fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef build fill:#FFB6C1,stroke:#000,stroke-width:2px;
    classDef env fill:#D3D3D3,stroke:#000,stroke-width:2px;
    classDef security fill:#FF6347,stroke:#000,stroke-width:2px;
```
