# vio-eli/rnum architecture

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

- Interactive diagram: https://gitdiagram.com/vio-eli/rnum
- Repository: https://github.com/vio-eli/rnum

## Overview

##### Project Type and Overall Purpose
- RNum is a library for scientific computing and symbolic mathematical operations in Rust. Its design emphasizes compile‐time computations, natural syntax, and zero runtime cost.
- The README highlights its application in both general mathematical computing and potentially in machine learning, focusing on symbolic differentiation and function manipulation.

##### Primary Components
a. Core Library (rnum):
- Modules for handling symbolic functions:
- “function” module: Contains submodules such as display, pretty printing, conversion to tokens, and standard operations (abs, exp, ln, log, pow, root, trig, etc.).
- Modules for symbolic differentiation:
- “deriv” module: Implements forward and backward differentiation algorithms plus partial derivatives and an interface for derivative-related operations.
- Miscellaneous utilities:
- “misc” module: Includes helper functions like a tree printer and possibly other support utilities.
- Testing components:
- “tests” module within the src tree to validate differentiation and core functionality.

b. Macros Library (rnum_macros):
- This crate facilitates macros that likely enable the symbolic and compile-time aspects (enabling a Mathematica-like or LaTeX-like syntax). The macros help integrate the core library with Rust’s compile-time system.

c. Build, Testing, and Documentation:
- Cargo configuration files (Cargo.toml) are present at the root and within each crate, ensuring reproducible builds and dependency management.
- Benchmarks (in benches/ folder of the core library) which are critical for performance profiling.
- Contribution guidelines and licenses that indicate an open-source, community-driven process.

##### Relationships and Interactions
- Within the Core Library block, create subdivisions for the “Function”, “Deriv”, and “Misc” modules along with a separate section for “Tests/Benchmarks”.
- Data flow between the “Function” and “Deriv” modules—symbolic representations often pass through function manipulation before differentiation.
- Cargo build system as a metadata component affecting both crates.

##### Architectural Patterns
- Modular Architecture: The clear separation into submodules (function operations, symbolic differentiation, utilities) should be visually distinct.
- Test and Benchmark Integration: Emphasize that the system design includes evaluation (tests/benchmarks) for accuracy and performance.

## Diagram (Mermaid)

```mermaid
graph TD
    Cargo["Cargo Build System"]:::build
    Macros["RNum Macros Library"]:::macro
    Core["RNum Core Library"]:::core

    subgraph "Core Library Modules"
        Func["Function Module"]:::function
        Deriv["Deriv Module"]:::differentiation
        Misc["Misc Utilities Module"]:::misc
        Tests["Tests Module"]:::tests
        Bench["Benchmarks"]:::bench
    end

    Cargo --> Core
    Cargo --> Macros
    Macros -->|"compile-time generation"| Core
    Core -->|"handles functions"| Func
    Core -->|"symbolic differentiation"| Deriv
    Core --> Misc
    Core --> Tests
    Core --> Bench
    Func -->|"prepares data for differentiation"| Deriv

    %% Click Events
    click Core "https://github.com/vio-eli/rnum/tree/main/rnum"
    click Func "https://github.com/vio-eli/rnum/tree/main/rnum/src/function"
    click Deriv "https://github.com/vio-eli/rnum/tree/main/rnum/src/deriv"
    click Misc "https://github.com/vio-eli/rnum/tree/main/rnum/src/misc"
    click Tests "https://github.com/vio-eli/rnum/tree/main/rnum/src/tests"
    click Bench "https://github.com/vio-eli/rnum/tree/main/rnum/benches"
    click Macros "https://github.com/vio-eli/rnum/tree/main/rnum_macros"

    %% Styles
    classDef build fill:#f9e79f,stroke:#b7950b,color:#000,stroke-width:2px
    classDef core fill:#aed6f1,stroke:#2471a3,color:#000,stroke-width:2px
    classDef function fill:#a9dfbf,stroke:#28b463,color:#000,stroke-width:2px
    classDef differentiation fill:#f5b7b1,stroke:#c0392b,color:#000,stroke-width:2px
    classDef misc fill:#d7bde2,stroke:#8e44ad,color:#000,stroke-width:2px
    classDef tests fill:#fad7a0,stroke:#e67e22,color:#000,stroke-width:2px
    classDef bench fill:#f0b27a,stroke:#d35400,color:#000,stroke-width:2px
    classDef macro fill:#d5f5e3,stroke:#27ae60,color:#000,stroke-width:2px
```
