# luke-jr/libbase58 architecture

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

- Interactive diagram: https://gitdiagram.com/luke-jr/libbase58
- Repository: https://github.com/luke-jr/libbase58

## Overview

##### Project type and purpose
- This is an open-source C library (libbase58) plus a CLI tool (clitool.c) for encoding/decoding Base58 and Base58Check data.
- It exposes a C API (b58tobin, b58enc, b58check, b58check_enc) and requires the integrator to supply a SHA256 function when using Base58Check.

##### File structure
- Top-level source files:
– base58.c / libbase58.h: core algorithms
– clitool.c: command-line interface linking against libbase58
- Build infrastructure:
– autogen.sh / configure.ac / Makefile.am: Autotools setup
– .travis.yml: CI configuration
- Packaging:
– libbase58.pc.in: pkg-config template
- Tests:
– tests/*.sh: shell scripts invoking encode/decode scenarios
- Other:
– COPYING, AUTHORS, INSTALL: standard project metadata

##### README for additional insights
- Describes initialization hook (b58_sha256_impl) for Base58Check → extensibility point
- Details API usage patterns for encoding/decoding

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Integrating Application
    subgraph "Integrating Application"
        App["Integrating App"]:::external
    end

    %% Core Library
    subgraph "libbase58 Core Library"
        Base58C["base58.c"]:::core
        LibHdr["libbase58.h"]:::core
    end

    %% SHA256 Plugin
    subgraph "SHA256 Plugin"
        SHA256["User SHA256 Implementation"]:::plugin
    end

    %% CLI Tool
    subgraph "CLI Tool"
        CLI["clitool.c"]:::tool
    end

    %% Test Suite
    subgraph "Test Suite"
        Tests["tests/"]:::test
    end

    %% Build System and Packaging
    subgraph "Build System & Packaging"
        Autogen["autogen.sh"]:::build
        Configure["configure.ac"]:::build
        Makefile["Makefile.am"]:::build
        Pkg["libbase58.pc.in"]:::build
        Travis[".travis.yml"]:::build
        subgraph "Project Metadata"
            README["README.md"]:::build
            Authors["AUTHORS"]:::build
            Copy["COPYING"]:::build
            Install["INSTALL"]:::build
        end
    end

    %% Relationships
    App -->|"b58tobin(), b58enc(), b58check() calls"| Base58C
    Base58C -.->|"b58_sha256_impl() hook"| SHA256
    CLI -->|"links & invokes libbase58 API"| Base58C
    Tests -->|"./clitool encode/decode"| CLI
    Autogen --> Configure --> Makefile
    Makefile -->|"build & install artifacts"| Base58C
    Makefile -->|"build & install artifacts"| CLI
    Makefile -->|"generate pkg-config"| Pkg
    Travis -->|"runs tests"| Tests

    %% Click Events
    click Base58C "https://github.com/luke-jr/libbase58/blob/master/base58.c"
    click LibHdr "https://github.com/luke-jr/libbase58/blob/master/libbase58.h"
    click CLI "https://github.com/luke-jr/libbase58/blob/master/clitool.c"
    click Tests "https://github.com/luke-jr/libbase58/tree/master/tests/"
    click Autogen "https://github.com/luke-jr/libbase58/blob/master/autogen.sh"
    click Configure "https://github.com/luke-jr/libbase58/blob/master/configure.ac"
    click Makefile "https://github.com/luke-jr/libbase58/blob/master/Makefile.am"
    click Pkg "https://github.com/luke-jr/libbase58/blob/master/libbase58.pc.in"
    click Travis "https://github.com/luke-jr/libbase58/blob/master/.travis.yml"
    click README "https://github.com/luke-jr/libbase58/blob/master/README.md"
    click Authors "https://github.com/luke-jr/libbase58/tree/master/AUTHORS"
    click Copy "https://github.com/luke-jr/libbase58/tree/master/COPYING"
    click Install "https://github.com/luke-jr/libbase58/tree/master/INSTALL"

    %% Styles
    classDef core fill:#cce5ff,stroke:#004085;
    classDef plugin fill:#d4edda,stroke:#155724;
    classDef build fill:#e2e3e5,stroke:#6c757d;
    classDef tool fill:#ffe5b4,stroke:#cc8400;
    classDef test fill:#fff3cd,stroke:#856404;
    classDef external fill:#f5f5f5,stroke:#333;
```
