# inbestigator/enc architecture

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

- Interactive diagram: https://gitdiagram.com/inbestigator/enc
- Repository: https://github.com/inbestigator/enc

## Overview

##### Main Components
- Core Library: Focus on the "libs/core" directory, where the main functionality is implemented.
- Source Files: Under "libs/core/src", you have dedicated modules for each cryptographic operation – for example, encrypt.ts, export.ts, generate.ts, and sign.ts.
- Entry Point: "libs/core/mod.ts" acts as a central exporter that aggregates the functionality provided in the src folder.
- Testing: The "libs/core/tests" directory contains tests (e.g., generate.test.ts) to validate functionality.
- Configuration and Build: The "libs/core/deno.json" sets up the Deno-specific configuration, and the ".github/workflows" folder with a publish.yaml indicates automated CI/CD processes upon publishing.

##### Out Component Relationships
- The Core Library is built on top of the WebCrypto API, so include an external “WebCrypto API” component. Show how the individual functions in src (encrypt, generate, sign, export) interact with the underlying WebCrypto API for secure cryptographic operations.
- Calls from the functions in src (e.g., encrypt.ts) to the WebCrypto API.
- Exports from mod.ts toward client applications that will incorporate Enc.
- Testing interacts directly with the src modules to verify outputs and behavior.

##### Architectural Patterns & Design Principles
- Modularity: Emphasize that the library is organized into independent modules for different cryptographic operations. This modularity facilitates ease of maintenance and testing.
- Abstraction: Highlight how Enc encapsulates complex operations behind simple function calls.
- CI/CD Integration: Include the automated build/publish pipeline managed via GitHub workflows.
- Technology Stack: Note that the project uses Deno as its runtime environment and leverages the built-in WebCrypto API.

## Diagram (Mermaid)

```mermaid
flowchart TD
    A("Client Application"):::client
    B("Enc Core Library"):::core
    C("Entry Point (/mod.ts)"):::entry

    subgraph "Source Modules"
        D1("Encryption Module (encrypt.ts)"):::module
        D2("Signature Module (sign.ts)"):::module
        D3("Key Generation Module (generate.ts)"):::module
        D4("Export Module (export.ts)"):::module
    end

    E("Configuration (deno.json)"):::config
    F("Test Suite"):::test
    G("CI/CD Pipeline"):::cicd
    H("WebCrypto API"):::external

    A -->|"calls"| C
    C -->|"invokes"| D1
    C -->|"invokes"| D2
    C -->|"invokes"| D3
    C -->|"invokes"| D4

    D1 -->|"calls"| H
    D2 -->|"calls"| H
    D3 -->|"calls"| H
    D4 -->|"calls"| H

    F -->|"tests"| D1
    F -->|"tests"| D2
    F -->|"tests"| D3
    F -->|"tests"| D4

    G -->|"publishes"| B

    B --> C
    B --> E
    B --> F
    B --> G

    click B "https://github.com/inbestigator/enc/tree/main/libs/core"
    click C "https://github.com/inbestigator/enc/blob/main/libs/core/mod.ts"
    click D1 "https://github.com/inbestigator/enc/blob/main/libs/core/src/encrypt.ts"
    click D2 "https://github.com/inbestigator/enc/blob/main/libs/core/src/sign.ts"
    click D3 "https://github.com/inbestigator/enc/blob/main/libs/core/src/generate.ts"
    click D4 "https://github.com/inbestigator/enc/blob/main/libs/core/src/export.ts"
    click E "https://github.com/inbestigator/enc/blob/main/libs/core/deno.json"
    click F "https://github.com/inbestigator/enc/tree/main/libs/core/tests"
    click G "https://github.com/inbestigator/enc/blob/main/.github/workflows/publish.yaml"

    classDef client fill:#DCEDC8,stroke:#558B2F,stroke-width:2px;
    classDef core fill:#B3E5FC,stroke:#0277BD,stroke-width:2px;
    classDef entry fill:#BBDEFB,stroke:#0D47A1,stroke-width:2px;
    classDef module fill:#C8E6C9,stroke:#2E7D32,stroke-width:2px;
    classDef external fill:#FFCDD2,stroke:#C62828,stroke-width:2px;
    classDef config fill:#FFF9C4,stroke:#FBC02D,stroke-width:2px;
    classDef test fill:#E1BEE7,stroke:#6A1B9A,stroke-width:2px;
    classDef cicd fill:#D7CCC8,stroke:#5D4037,stroke-width:2px;
```
