# shashi1910/enclypt architecture

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

- Interactive diagram: https://gitdiagram.com/shashi1910/enclypt
- Repository: https://github.com/shashi1910/enclypt

## Overview

##### Main components
- Client/User Interface: Represented by the HTML templates and static assets (CSS, JS, images) that form the web front-end.
- Flask Application (app.py): Acts as the central web server handling HTTP requests, routing, and the core encryption/decryption logic.
- Encryption/Decryption Engine: The logic embedded within the Flask app that utilizes the Fernet algorithm to encrypt and decrypt files.
- File Storage: Although not all subdirectories (like uploads, keys, logs) are visible in the provided file tree, the README explains that the system stores encrypted/decrypted files, keys, and logs. These are critical for showing how the system manages state and security.
- Temporary Files: The “temp/” folder present in the file tree indicates temporary file storage – which might serve non-production or testing purposes.
- Configuration & Environment Management: The project uses a .env file (as described in the README) to manage secrets and configuration like the SECRET_KEY and PORT.

##### Relationships & Interactions
- The Client (browser) interacts with the Flask Application via HTTP endpoints (e.g., encrypt and decrypt pages).
- The Flask Application processes file uploads, then passes the file data to the Encryption/Decryption Engine.
- Once processed, the application stores resulting files either in an “uploads” directory (for the output files) and keys in a “keys” directory, while recording activities in the “logs” directory.
- The Encryption/Decryption Engine uses the Fernet algorithm to secure files, and its operations are triggered by user actions on the web interface.
- The static and templates directories supply all necessary assets and layout views to the user.

##### Architectural Patterns/Design Principles
- MVC-Like Separation: While not a strict MVC pattern, the separation between the templates (view), the Flask logic in app.py (controller), and the (implicit) model of file storage (data) is evident.
- Layered Architecture: The separation of web interface, business logic (encryption/decryption), and storage (files, keys, and logs).
- Security-Focused Design: Given the emphasis on secure key management and file size restrictions, security is an integral design principle.

##### Relevant Technologies & Frameworks
- Flask (Python Web Framework) handles routing and request management.
- Frontend assets (HTML, CSS, JS) provided in the templates and static directories.
- Fernet encryption from Python’s cryptography library.
- The use of a .env file for configuration management.

##### Elements
- For each identified component, use clear labels (e.g., “Client Browser”, “Flask App”, “Encryption Module”, “File Storage (uploads/keys/logs)”, “Temp Files”).
- From the client to the web server for initiating encryption/decryption operations.
- From the encryption module to file storage (and vice versa for decryption).
- A note on configuration management (e.g., .env file) and error logging.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Client Layer"
        CB["Client Browser"]:::client
    end

    subgraph "Server Layer"
        FA["Flask App"]:::server
        EE["Encryption/Decryption Engine"]:::engine
        HT["HTML Templates"]:::frontend
        SA["Static Assets"]:::frontend
        CFG["Configuration (.env)"]:::config
    end

    subgraph "Storage Layer"
        FS["File Storage (Uploads/Keys/Logs)"]:::storage
        TF["Temp Files"]:::temp
    end

    CB -->|"HTTPRequest"| FA
    FA -->|"ProcessFile"| EE
    FA -->|"RendersView"| HT
    FA -->|"ServesAssets"| SA
    CFG -->|"Configures"| FA
    EE -->|"StoresResults"| FS
    EE -->|"UsesTempStorage"| TF

    %% Click Events
    click HT "https://github.com/shashi1910/enclypt/tree/main/templates/"
    click SA "https://github.com/shashi1910/enclypt/tree/main/static/"
    click FA "https://github.com/shashi1910/enclypt/blob/main/app.py"
    click TF "https://github.com/shashi1910/enclypt/tree/main/temp/"

    %% Styles
    classDef client fill:#f9c,stroke:#333,stroke-width:2px;
    classDef server fill:#bbf,stroke:#333,stroke-width:2px;
    classDef engine fill:#bfb,stroke:#333,stroke-width:2px;
    classDef frontend fill:#ff9,stroke:#333,stroke-width:2px;
    classDef config fill:#ddd,stroke:#333,stroke-width:2px;
    classDef storage fill:#cfc,stroke:#333,stroke-width:2px;
    classDef temp fill:#fcf,stroke:#333,stroke-width:2px;
```
