# minahermina/bignum architecture

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

- Interactive diagram: https://gitdiagram.com/minahermina/bignum
- Repository: https://github.com/minahermina/bignum

## Overview

##### Project type and purpose
- This is a C99 library (“BigNum Library”) for arbitrary-precision integer arithmetic.
- It is intended as a foundational component (e.g., for RSA encryption in future projects), not a stand-alone application.

##### File structure
- Top-level files:
- Makefile, LICENSE, .gitignore (build & project meta)
- README.md (project description)
- main.c (demo or example driver)
- Directories:
- / – public headers
- src/ – implementation modules
- Within src/: modules are grouped by operation type (addition/subtraction, bitwise, multiplication/division/modulus, utilities).

##### README for additional insights
- Core arithmetic operations are split across multiple source files.
- Some functions (div, mod, gcd, mod-exp, mod-inverse) are not yet implemented.
- The library is inspired by OpenSSL’s BIGNUM.

##### Important details to capture
- Distinguish between header files (expose API) and C files (implement functionality).
- That all arithmetic modules share the same allocator and utils.
- In-progress status by annotating unimplemented modules or functions.
- Makefile as the entry point for building the library.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Public Interface Layer
    subgraph "Public Interface Layer"
        API_bignum["bignum.h"]:::interface
        API_arena["arena_allocator.h"]:::interface
        API_utils_hdr["utils.h"]:::interface
    end

    %% Core Modules
    subgraph "Core Modules"
        Core_allocator["arena_allocator (implementation)"]:::core
        Core_utils["utils.c"]:::utility
        Core_bignum_def["bignum.c"]:::core
    end

    %% Arithmetic Modules
    subgraph "Arithmetic Modules"
        AddSub["bignum_add_sub"]:::arithmetic
        Bitwise["bignum_bitwise"]:::arithmetic
        MulDivMod["bignum_mul_div_mod"]:::arithmetic
    end

    %% Example and Build
    Example["main.c"]:::example
    Build["Makefile"]:::build

    %% Dependencies
    API_bignum -->|"declares"| Core_bignum_def
    API_bignum -->|"declares"| AddSub
    API_bignum -->|"declares"| Bitwise
    API_bignum -->|"declares"| MulDivMod
    API_arena -->|"declares"| Core_allocator
    API_utils_hdr -->|"declares"| Core_utils

    AddSub -->|"allocates"| Core_allocator
    Bitwise -->|"allocates"| Core_allocator
    MulDivMod -->|"allocates"| Core_allocator

    AddSub -->|"uses"| Core_utils
    Bitwise -->|"uses"| Core_utils
    MulDivMod -->|"uses"| Core_utils

    Example -->|"invokes API"| API_bignum

    Build -->|"compiles"| Core_bignum_def
    Build -->|"compiles"| Core_utils
    Build -->|"compiles"| AddSub
    Build -->|"compiles"| Bitwise
    Build -->|"compiles"| MulDivMod
    Build -->|"builds demo"| Example

    %% Click Events
    click API_bignum "https://github.com/minahermina/bignum/blob/main/include/bignum.h"
    click API_arena "https://github.com/minahermina/bignum/blob/main/include/arena_allocator.h"
    click API_utils_hdr "https://github.com/minahermina/bignum/blob/main/include/utils.h"
    click Core_utils "https://github.com/minahermina/bignum/blob/main/src/utils.c"
    click Core_bignum_def "https://github.com/minahermina/bignum/blob/main/src/bignum.c"
    click AddSub "https://github.com/minahermina/bignum/blob/main/src/bignum_add_sub.c"
    click Bitwise "https://github.com/minahermina/bignum/blob/main/src/bignum_bitwise.c"
    click MulDivMod "https://github.com/minahermina/bignum/blob/main/src/bignum_mul_div_mod.c"
    click Example "https://github.com/minahermina/bignum/blob/main/main.c"
    click Build "https://github.com/minahermina/bignum/tree/main/Makefile"

    %% Styles
    classDef interface fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef core fill:#90EE90,stroke:#333,stroke-width:1px
    classDef utility fill:#98AFC7,stroke:#333,stroke-width:1px
    classDef arithmetic fill:#FFFF99,stroke:#333,stroke-width:1px
    classDef example fill:#D3D3D3,stroke:#333,stroke-width:1px
    classDef build fill:#D3D33,stroke:#333,stroke-width:1px
```
