# nick322/secure-spreadsheet architecture

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

- Interactive diagram: https://gitdiagram.com/nick322/secure-spreadsheet
- Repository: https://github.com/nick322/secure-spreadsheet

## Overview

##### Project type and purpose
- This is an open-source PHP library and accompanying CLI tool named “Secure Spreadsheet.”
- Its purpose is to encrypt and password-protect Office Open XML spreadsheets (XLSX files) using the xlsx-populate library.

##### File structure
- Top level
- index.php – the CLI entrypoint script (alias `secure-spreadsheet`)
- composer.json – defines package metadata, dependencies, and autoloading (PSR-4).
- phpunit.xml, tests/ – unit tests for the core functionality.
- src/
– Encrypt.php – main class that wraps spreadsheet encryption logic.
– secure-spreadsheet.php – CLI bootstrap that maps CLI flags to the Encrypt class.
- secure-spreadsheet (executable) – a bin script that invokes index.php.
- Vendor dependencies (not shown) will include dtjohnson/xlsx-populate for actual encryption.

##### README for additional insights
- Usage modes:
- CLI mode (`secure-spreadsheet run --password ...`).
- Programmatic PHP mode (instantiating `Nick\SecureSpreadsheet\Encrypt`).
- Memory-only mode (no file I/O).

##### Elements
- Clear component labels (e.g., “CLI Runner”, “Encrypt Library”, “xlsx-populate”).
- From CLI → Encrypt → xlsx-populate → File System / Memory.
- From Composer Autoloader → all PHP classes.
- External dependency (xlsx-populate) in another
- I/O (file system/memory buffer) in a third

##### Final recommendations
- Every responsibility boundary: CLI parsing, encryption orchestration, actual encryption engine, I/O.
- Use standard UML or C4 notation to show containers and components clearly.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% CLI Layer
    subgraph "CLI Layer"
        CLI_Exec["CLI Executable Wrapper\n(secure-spreadsheet)"]:::cli
        CLI_Entry["CLI Runner\n(index.php)"]:::cli
        CLI_Bootstrap["CLI Bootstrapper\n(src/secure-spreadsheet.php)"]:::cli
    end

    %% Autoloader
    Autoloader["Composer Autoloader\n(composer.json)"]:::library

    %% Library Core
    subgraph "Library Layer"
        Encrypt["Encrypt Library\n(src/Encrypt.php)"]:::library
    end

    %% External Dependency
    External["xlsx-populate\n(External Encryption Engine)"]:::external

    %% I/O Components
    subgraph "I/O Layer"
        FileSystem["File System\n(Read/Write XLSX)"]:::io
        Memory["Memory Buffer\n(Read/Write XLSX)"]:::io
        SampleFile["Sample Input Spreadsheet\n(Book1.xlsx)"]:::io
    end

    %% Testing Layer
    subgraph "Testing"
        PHPUnitConfig["PHPUnit Config\n(phpunit.xml)"]:::test
        Tests["Unit Tests\n(tests/EncryptorTest.php)"]:::test
    end

    %% Connections
    CLI_Exec -->|"invokes"| CLI_Entry
    CLI_Entry -->|"parses args"| CLI_Bootstrap
    CLI_Bootstrap -->|"loads via"| Autoloader
    Autoloader --> Encrypt
    CLI_Bootstrap -->|"calls encrypt()"| Encrypt
    Encrypt -->|"uses"| External
    Encrypt -->|"reads/writes"| FileSystem
    Encrypt -->|"reads/writes"| Memory
    FileSystem -->|"reads sample"| SampleFile

    Tests -->|"loads via"| Autoloader
    Tests -->|"tests methods of"| Encrypt
    PHPUnitConfig --> Tests

    %% Click Events
    click CLI_Entry "https://github.com/nick322/secure-spreadsheet/blob/master/index.php"
    click CLI_Exec "https://github.com/nick322/secure-spreadsheet/tree/master/secure-spreadsheet"
    click CLI_Bootstrap "https://github.com/nick322/secure-spreadsheet/blob/master/src/secure-spreadsheet.php"
    click Encrypt "https://github.com/nick322/secure-spreadsheet/blob/master/src/Encrypt.php"
    click Autoloader "https://github.com/nick322/secure-spreadsheet/blob/master/composer.json"
    click Tests "https://github.com/nick322/secure-spreadsheet/blob/master/tests/EncryptorTest.php"
    click PHPUnitConfig "https://github.com/nick322/secure-spreadsheet/blob/master/phpunit.xml"
    click SampleFile "https://github.com/nick322/secure-spreadsheet/blob/master/Book1.xlsx"

    %% Styles
    classDef cli fill:#D0E8FF,stroke:#0366D6,stroke-width:1px;
    classDef library fill:#DFF0D8,stroke:#28A745,stroke-width:1px;
    classDef external fill:#FFE5B4,stroke:#F39C12,stroke-width:1px;
    classDef io fill:#FFF3CD,stroke:#E0A800,stroke-width:1px;
    classDef test fill:#F8D7DA,stroke:#C82333,stroke-width:1px;
```
