# samuelgodoy/arca architecture

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

- Interactive diagram: https://gitdiagram.com/samuelgodoy/arca
- Repository: https://github.com/samuelgodoy/arca

## Overview

##### Project type and purpose
- ARCA is a native command‐line encryption tool (an open-source CLI utility), not a multi-tier web app.
- Its sole purpose is to securely encrypt/decrypt a local “vault” of secrets using AES-GCM-SIV + Scrypt, with zero external dependencies and maximum portability (polyglot binary via cosmocc).

##### File structure
- Top-level directories:
- cmd/        – (empty or future subcommands)
- /    – public headers: aes.h, scrypt.h, trng.h, mensagens.h
- src/        – implementation modules: main.c, aes.c, scrypt.c, trng.c
- img/        – README illustrations
- Taskfile.yml – build/task runner (invokes cosmocc)
- Pattern: a simple multi-module C project with a CLI “frontend” (main.c) and three core engine modules (AES, Scrypt, TRNG).
- Build and packaging handled by Taskfile.yml and cosmocc to create a single polyglot binary.

##### Key insights from the README
- Core algorithms: AES-GCM-SIV (encryption), Scrypt (key derivation), TRNG (secure random).
- Cross-platform, zero dependencies, polyglot single binary.
- Future extension point: user-defined AEAD authenticated data.

##### Detail without over-complicating
- Module separately; don’t lump all crypto into one monolith.
- Both the offline build flow (Taskfile.yml → cosmocc → final binary) and the runtime flow (user → CLI → modules → disk).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User
    User["User"]:::external

    %% CLI Frontend
    CLI["CLI Frontend"]:::frontend

    %% Crypto Engine Layer
    subgraph "Crypto Engine"
        direction TB
        TRNG["TRNG Module"]:::crypto
        Scrypt["Scrypt KDF Module"]:::crypto
        AES["AES Cipher Module"]:::crypto
    end

    %% Storage Layer
    FileIO["File I/O"]:::storage
    Vault["Vault File"]:::storage

    %% Build & Packaging
    Build["Build & Packaging"]:::build
    OS["OS Abstraction (cosmocc)"]:::os

    %% Extension & Documentation
    Future["Future CLI Subcommands"]:::placeholder
    Img["Illustrations & Diagrams"]:::illustration
    API["Public API Headers"]:::api

    %% Runtime Flow
    User -->|"commands + passphrase"| CLI
    CLI -->|"generate nonce/IV"| TRNG
    CLI -->|"derive key"| Scrypt
    CLI -->|"encrypt/decrypt data"| AES
    CLI -->|"read/write vault"| FileIO
    FileIO -->|"reads/writes"| Vault
    CLI -->|"uses OS abstraction"| OS

    %% Build Flow
    Build -->|"invokes cosmocc"| OS
    Build -->|"produces binary"| CLI

    %% CLI Extras
    CLI --> Future
    CLI --> API
    CLI --> Img

    %% Click Events
    click CLI "https://github.com/samuelgodoy/arca/blob/main/src/main.c"
    click AES "https://github.com/samuelgodoy/arca/blob/main/src/aes.c"
    click Scrypt "https://github.com/samuelgodoy/arca/blob/main/src/scrypt.c"
    click TRNG "https://github.com/samuelgodoy/arca/blob/main/src/trng.c"
    click Build "https://github.com/samuelgodoy/arca/blob/main/Taskfile.yml"
    click Future "https://github.com/samuelgodoy/arca/tree/main/cmd/"
    click Img "https://github.com/samuelgodoy/arca/tree/main/img/"
    click API "https://github.com/samuelgodoy/arca/tree/main/include/"

    %% Styles
    classDef external fill:#ddf,stroke:#669,color:#000;
    classDef frontend fill:#dfd,stroke:#383,color:#000;
    classDef crypto fill:#ddf,stroke:#336,color:#000;
    classDef storage fill:#ffeb99,stroke:#cc9,color:#000;
    classDef build fill:#ccc,stroke:#888,color:#000;
    classDef os fill:#eee,stroke:#aaa,color:#000;
    classDef placeholder fill:#f9f,stroke:#c6c,color:#000;
    classDef illustration fill:#fee,stroke:#f99,color:#000;
    classDef api fill:#eef,stroke:#99c,color:#000;
```
