# bh-altsysrq/hasher-cli architecture

> Architecture diagram of the GitHub repository bh-altsysrq/hasher-cli, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bh-altsysrq/hasher-cli
- Repository: https://github.com/bh-altsysrq/hasher-cli

## Overview

#### Purpose and Entry Point

`hasher-cli` is a native command-line utility that computes a file’s SHA-256 digest. Its executable entry point and all runtime logic are in `hasher-cli.c`; users invoke it with one file-path argument.

Paths:
- `hasher-cli.c`
- `README.md`

#### Build and Runtime Boundary

The project is compiled through `make`, with build rules defined in `Makefile`. It requires OpenSSL development headers and links against OpenSSL’s crypto facilities. The produced binary runs directly on the host; there is no server, persistent storage, or application framework.

Paths:
- `Makefile`
- `hasher-cli.c`

#### Command-Line Input Stage

The program receives the target filename from process arguments. Argument handling establishes the primary user boundary: an invalid invocation or inaccessible path should terminate before digest output. The supplied path is treated as a local filesystem resource.

Paths:
- `hasher-cli.c`

#### File Streaming Stage

The target file is opened and read from the operating system filesystem. Content is expected to be processed incrementally rather than modeled as application-domain data, keeping memory use independent of file size and separating file I/O failures from cryptographic failures.

Paths:
- `hasher-cli.c`

#### SHA-256 Digest Stage

Hash computation is delegated to the OpenSSL EVP API, rather than implementing SHA-256 internally. The EVP context lifecycle—creation, SHA-256 initialization, repeated updates from file chunks, and finalization—forms the central control flow.

Paths:
- `hasher-cli.c`

#### Output and Error Boundaries

After finalization, the binary digest is rendered as a human-readable hexadecimal SHA-256 value and written to standard output. Usage, file-access, allocation, and OpenSSL operation failures are command-line error boundaries and should be reported through standard error with a non-success exit status.

Paths:
- `hasher-cli.c`

#### External Dependencies

OpenSSL is the only material external service/library dependency, specifically its EVP cryptographic interface and development headers. Host filesystem access supplies the hashed bytes; shell invocation and standard streams provide the interface contract.

Paths:
- `hasher-cli.c`
- `Makefile`

Main entry points: [`hasher-cli.c`](https://github.com/bh-altsysrq/hasher-cli/blob/main/hasher-cli.c) (Argument validation), [`Makefile`](https://github.com/bh-altsysrq/hasher-cli/blob/main/Makefile) (make)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_build["Build"]
  node_make{{"make<br/>build tool"}}
  node_source["CLI source<br/>C program<br/>[hasher-cli.c]"]
  node_openssl_headers["OpenSSL headers<br/>development dependency"]
end

subgraph group_runtime["CLI runtime"]
  node_binary["hasher-cli<br/>native executable<br/>[hasher-cli.c]"]
  node_user(("Shell user<br/>caller"))
  node_arguments["File-path argument<br/>CLI input<br/>[hasher-cli.c]"]
  node_argument_validation["Argument validation<br/>input boundary<br/>[hasher-cli.c]"]
  node_filesystem[("Host filesystem<br/>external resource")]
  node_file_stream["Chunked file reader<br/>I/O stage<br/>[hasher-cli.c]"]
  node_evp["OpenSSL EVP API<br/>cryptography library"]
  node_digest["SHA-256 digest<br/>binary result<br/>[hasher-cli.c]"]
  node_stdout["Standard output<br/>output boundary<br/>[hasher-cli.c]"]
  node_stderr_exit["Standard error and exit<br/>error boundary<br/>[hasher-cli.c]"]
end

node_make -->|"compiles"| node_source
node_make -->|"requires"| node_openssl_headers
node_source -->|"produces"| node_binary
node_binary -->|"links against"| node_evp
node_user -->|"invokes"| node_binary
node_user -->|"supplies"| node_arguments
node_arguments -->|"validated by"| node_argument_validation
node_argument_validation -->|"opens path"| node_filesystem
node_argument_validation -.->|"invalid invocation"| node_stderr_exit
node_filesystem -->|"reads bytes"| node_file_stream
node_filesystem -.->|"access failure"| node_stderr_exit
node_file_stream -->|"updates with chunks"| node_evp
node_evp -->|"finalizes"| node_digest
node_evp -.->|"operation failure"| node_stderr_exit
node_digest -->|"renders as hexadecimal"| node_stdout

click node_make "https://github.com/bh-altsysrq/hasher-cli/blob/main/Makefile"
click node_source "https://github.com/bh-altsysrq/hasher-cli/blob/main/hasher-cli.c"
click node_binary "https://github.com/bh-altsysrq/hasher-cli/blob/main/hasher-cli.c"
click node_arguments "https://github.com/bh-altsysrq/hasher-cli/blob/main/hasher-cli.c"
click node_argument_validation "https://github.com/bh-altsysrq/hasher-cli/blob/main/hasher-cli.c"
click node_file_stream "https://github.com/bh-altsysrq/hasher-cli/blob/main/hasher-cli.c"
click node_digest "https://github.com/bh-altsysrq/hasher-cli/blob/main/hasher-cli.c"
click node_stdout "https://github.com/bh-altsysrq/hasher-cli/blob/main/hasher-cli.c"
click node_stderr_exit "https://github.com/bh-altsysrq/hasher-cli/blob/main/hasher-cli.c"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_make,node_source,node_openssl_headers toneBlue
class node_binary,node_user,node_arguments,node_argument_validation,node_filesystem,node_file_stream,node_evp,node_digest,node_stdout,node_stderr_exit toneAmber
```

## Components

### Build

- [make](https://github.com/bh-altsysrq/hasher-cli/blob/main/Makefile): build tool · `Makefile`
- [CLI source](https://github.com/bh-altsysrq/hasher-cli/blob/main/hasher-cli.c): C program · Contains the executable entry point and runtime logic. · `hasher-cli.c`
- **OpenSSL headers**: development dependency

### CLI runtime

- [hasher-cli](https://github.com/bh-altsysrq/hasher-cli/blob/main/hasher-cli.c): native executable · Host-run SHA-256 command-line utility. · `hasher-cli.c`
- **Shell user**: caller
- [File-path argument](https://github.com/bh-altsysrq/hasher-cli/blob/main/hasher-cli.c): CLI input · `hasher-cli.c`
- [Argument validation](https://github.com/bh-altsysrq/hasher-cli/blob/main/hasher-cli.c): input boundary · Rejects invalid invocation before digest output. · `hasher-cli.c`
- **Host filesystem**: external resource · Supplies target file bytes.
- [Chunked file reader](https://github.com/bh-altsysrq/hasher-cli/blob/main/hasher-cli.c): I/O stage · Streams file content with memory use independent of file size. · `hasher-cli.c`
- **OpenSSL EVP API**: cryptography library · Owns SHA-256 context creation, updates, and finalization.
- [SHA-256 digest](https://github.com/bh-altsysrq/hasher-cli/blob/main/hasher-cli.c): binary result · `hasher-cli.c`
- [Standard output](https://github.com/bh-altsysrq/hasher-cli/blob/main/hasher-cli.c): output boundary · Receives the hexadecimal digest. · `hasher-cli.c`
- [Standard error and exit](https://github.com/bh-altsysrq/hasher-cli/blob/main/hasher-cli.c): error boundary · Reports usage, I/O, allocation, and OpenSSL failures with non-success status. · `hasher-cli.c`

## Connections

- make → CLI source: compiles
- make → OpenSSL headers: requires
- CLI source → hasher-cli: produces
- hasher-cli → OpenSSL EVP API: links against
- Shell user → hasher-cli: invokes
- Shell user → File-path argument: supplies
- File-path argument → Argument validation: validated by
- Argument validation → Host filesystem: opens path
- Argument validation → Standard error and exit: invalid invocation
- Host filesystem → Chunked file reader: reads bytes
- Host filesystem → Standard error and exit: access failure
- Chunked file reader → OpenSSL EVP API: updates with chunks
- OpenSSL EVP API → SHA-256 digest: finalizes
- OpenSSL EVP API → Standard error and exit: operation failure
- SHA-256 digest → Standard output: renders as hexadecimal
