# felipebonezi/cipherizy-lib architecture

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

- Interactive diagram: https://gitdiagram.com/felipebonezi/cipherizy-lib
- Repository: https://github.com/felipebonezi/cipherizy-lib

## Overview

##### Project Type and Purpose
- This project is a cryptography library written in Java (with compatibility for Kotlin and Scala) designed to simplify the encryption and decryption of sensitive data.
- The project exposes a clear API by way of an interface (ICipher) and uses the factory design pattern (CipherFactory) to instantiate concrete cipher implementations (e.g., AESCipher, Base16Cipher, Base32Cipher, Base64Cipher).
- Its primary purpose is to provide encryption/decryption functionality for client applications. It integrates well into Maven, Gradle, or SBT projects.

##### File Structure Analysis
- The top-level directories include configuration files (like build.gradle, settings.gradle), CI/CD setup (.github/workflows directories), and the core source code under src/main/java.
- The package structure under src/main/java/io/github/felipebonezi/cipherizy reveals separation by component: a core package with exception handling (CipherException), an interface (ICipher), and an algorithm sub-package containing the actual encryption algorithm implementations.
- Testing is thoroughly supported under src/test with a parallel structure, indicating that unit tests are considered a key part of the design.

##### Key Components
a. Core Library Components:
- ICipher: The main interface defining encryption and decryption methods.
- CipherFactory: The factory class responsible for instantiating cipher implementations. It encapsulates an algorithm selection mechanism.
- Cipher Algorithms: Each algorithm (AESCipher, Base16Cipher, Base32Cipher, Base64Cipher – including Base64URLSafe variant) should be represented as a concrete component implementing ICipher.
- Exception Handling: Include CipherException as the handling mechanism for errors during cipher operations.

b. Supporting Components:
- Continuous Integration/CD: Represent the GitHub Workflows (.github/workflows) that administer CI/CD processes such as continuous integration and artifact purging.
- Testing Suite: Represent the test packages and associated resources, indicating the importance of unit tests for each cipher algorithm.

##### Relationships and Interactions
- Each concrete algorithm class (AESCipher, Base16Cipher, etc.) implements the ICipher interface.
- Error handling is managed by use of CipherException across the system.
- The testing component should be depicted as validating each algorithm’s functionality, ensuring that encryption and decryption works as expected.

##### Architectural Patterns and Design Principles
- Factory Design Pattern: Clearly illustrate how CipherFactory centralizes the instantiation process.
- Interface-based design: Show that ICipher serves as the contract for all encryption algorithms.
- CI/CD Integration: Although not part of the runtime, include a note on how external tools (GitHub Actions workflows) assist in the code quality and release process.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Integration
    Client["Client Application"]:::client

    %% Core Library
    subgraph "Core Library"
        ICipher["ICipher (Interface)"]:::interface
        CipherException["CipherException (Error Handling)"]:::error
        CipherFactory["CipherFactory (Factory)"]:::factory
        subgraph "Implementations"
            AESCipher["AESCipher"]:::impl
            Base16Cipher["Base16Cipher"]:::impl
            Base32Cipher["Base32Cipher"]:::impl
            Base64Cipher["Base64Cipher"]:::impl
        end
    end

    %% Auxiliary Tools
    subgraph "Auxiliary Tools"
        Build["Build & Dependency Management"]:::build
        CI["CI/CD Pipelines"]:::ci
        Testing["Testing Suite"]:::test
    end

    %% Relationships
    Client -->|"instantiates"| CipherFactory
    CipherFactory -->|"creates"| AESCipher
    CipherFactory -->|"creates"| Base16Cipher
    CipherFactory -->|"creates"| Base32Cipher
    CipherFactory -->|"creates"| Base64Cipher
    AESCipher -->|"implements"| ICipher
    Base16Cipher -->|"implements"| ICipher
    Base32Cipher -->|"implements"| ICipher
    Base64Cipher -->|"implements"| ICipher
    CipherFactory -->|"handlesErrorsVia"| CipherException
    Testing -->|"tests"| ICipher
    Testing -->|"tests"| AESCipher
    Testing -->|"tests"| Base16Cipher
    Testing -->|"tests"| Base32Cipher
    Testing -->|"tests"| Base64Cipher

    %% Click Events
    click ICipher "https://github.com/felipebonezi/cipherizy-lib/blob/main/src/main/java/io/github/felipebonezi/cipherizy/ICipher.java"
    click CipherFactory "https://github.com/felipebonezi/cipherizy-lib/blob/main/src/main/java/io/github/felipebonezi/cipherizy/algorithm/CipherFactory.java"
    click AESCipher "https://github.com/felipebonezi/cipherizy-lib/blob/main/src/main/java/io/github/felipebonezi/cipherizy/algorithm/AESCipher.java"
    click Base16Cipher "https://github.com/felipebonezi/cipherizy-lib/blob/main/src/main/java/io/github/felipebonezi/cipherizy/algorithm/Base16Cipher.java"
    click Base32Cipher "https://github.com/felipebonezi/cipherizy-lib/blob/main/src/main/java/io/github/felipebonezi/cipherizy/algorithm/Base32Cipher.java"
    click Base64Cipher "https://github.com/felipebonezi/cipherizy-lib/blob/main/src/main/java/io/github/felipebonezi/cipherizy/algorithm/Base64Cipher.java"
    click CipherException "https://github.com/felipebonezi/cipherizy-lib/blob/main/src/main/java/io/github/felipebonezi/cipherizy/CipherException.java"
    click Build "https://github.com/felipebonezi/cipherizy-lib/blob/main/build.gradle"
    click Build "https://github.com/felipebonezi/cipherizy-lib/blob/main/settings.gradle"
    click CI "https://github.com/felipebonezi/cipherizy-lib/tree/main/.github/workflows"
    click Testing "https://github.com/felipebonezi/cipherizy-lib/tree/main/src/test"

    %% Styles
    classDef client fill:#ffefc1,stroke:#333,stroke-width:2px;
    classDef interface fill:#c1f0ff,stroke:#333,stroke-width:2px;
    classDef factory fill:#ffe0e0,stroke:#333,stroke-width:2px;
    classDef impl fill:#e0ffe0,stroke:#333,stroke-width:2px;
    classDef error fill:#fca5a5,stroke:#333,stroke-width:2px;
    classDef build fill:#d1e8e2,stroke:#333,stroke-width:2px;
    classDef ci fill:#e2d1e8,stroke:#333,stroke-width:2px;
    classDef test fill:#e8e2d1,stroke:#333,stroke-width:2px;
```
